查询用户是否有#34;无法更改密码"在Active Directory中签入

时间:2016-07-08 21:10:59

标签: vb.net ldap adsi

我正在尝试检查此信息,以便我开发...

我试图查询userAccountControl,但我已经发现如果AD设置正确,则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。

1 个答案:

答案 0 :(得分:2)

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

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

此处还有一些其他MSDN信息:https://msdn.microsoft.com/en-us/library/aa746398.aspx