【问题标题】:Query if user has "Cannot change password" checked in Active Directory查询用户是否在 Active Directory 中选中了“无法更改密码”
【发布时间】:2016-11-11 13:00:13
【问题描述】:

我正在尝试为我正在开发的应用检查此信息...

我正在尝试查询 userAccountControl,但我发现如果设置了 AD,它不会正确更新它。

这是我目前搜索 UserAccountControl 的方式

 If (res.Properties.Contains("userAccountControl")) Then
            userAccountControl = doespasswordexpire(res.Properties("userAccountControl").Item(0))
            userAccountControlPNR = PasswordNotRequired(res.Properties("userAccountControl").Item(0))
            userAccountControlSCR = SmartCardRequired(res.Properties("userAccountControl").Item(0))
        Else
            userAccountControl = ""
            userAccountControlPNR = ""
            userAccountControlSCR = ""
 End If

我将如何在 ADSI 或 LDAP 中执行此操作?我不想使用 PrincipalContext。

【问题讨论】:

    标签: vb.net ldap adsi


    【解决方案1】:

    您不能使用userAccountControl 属性来修改,甚至查询“不能更改密码”设置。它在 Microsoft 的文档中被列为可能的标志,但它不起作用(不确定它是否曾经打算这样做?)。

    要检查是否已设置,您必须在其 DACL 中解析出用户的 ACE。您可以从用户的ntSecurityDescriptor 属性中获取它并以编程方式对其进行解析。 this thread 中有一个很好的开始示例。

    这里有一些额外的 MSDN 信息:https://msdn.microsoft.com/en-us/library/aa746398.aspx

    【讨论】:

    • 第一个例子是在 VBS 中,所以我有点困惑。 MSDN 示例有点……在我头上。我一直在向谷歌搜索示例,但没有找到任何我能理解的内容。
    • VB.NET 绝对不是我的强项,但 this 似乎是一个可能有帮助的例子。跟随它直到列出' Get the DACL from the security descriptor. 的try 块的开头。然后,您需要在 DiscretionaryAcl 实例上迭代 ACE,并检查控制它的特定 ACE,它的 ACE 对象类型 GUID 似乎为 {AB721A53-1E2F-11D0-9819-00AA0040529B}
    猜你喜欢
    • 1970-01-01
    • 2013-09-11
    • 2016-10-17
    • 1970-01-01
    • 2012-06-26
    • 1970-01-01
    • 2013-02-26
    • 1970-01-01
    • 2010-09-28
    相关资源
    最近更新 更多