Dir*_*irk 5 directoryservices active-directory account-management
在Active Directory中重置用户密码后,如果用户尝试使用旧密码登录,则以下代码验证为True:
Dim up As UserPrincipal = GetAdUser(objContext, arg_strBA, arg_strUsername)
If up IsNot Nothing Then
Dim valid As Boolean = up.Context.ValidateCredentials(
up.UserPrincipalName, arg_strPassword, ContextOptions.Negotiate)
If (valid) Then strReturn = up.SamAccountName
End If
Run Code Online (Sandbox Code Playgroud)
我们正在使用以下代码重置密码:
Dim objUser As New DirectoryEntry(arg_strLDAPPath)
If Not objUser Is Nothing Then
objUser.AuthenticationType = AuthenticationTypes.Secure
objUser.Invoke("SetPassword", arg_strNewPW)
objUser.CommitChanges()
end if
Run Code Online (Sandbox Code Playgroud)
密码重置工作正常,用户可以使用新密码登录,但旧密码仍不能验证.
当上述ValidateCredentials适用于旧密码时,我们将凭据分配给Web服务调用,然后失败并显示"401:Unauthorized"错误.
有人见过这样的事吗?
谢谢Dirk
我在这里找到了答案
从链接...
“但是,重要的是 ContextOption 不能确保仅使用 Kerberos。事实证明,在某些情况下(例如,如果您指定 AD 而不是本地,并且您有足够最新的服务器),代码会选择不管怎样,都要进行协商。从这个意义上说,指定 Sealing 可能意味着它将使用 Kerberos,但不一定是排他性的。真正重要的标志被隐藏在其之下的几层。在幕后,此方法最终会建立一个 LdapConnection,设置连接的网络凭据,设置 AuthType(重要的实际标志!),最后调用 Bind() 方法。LdapConnection.Bind() 方法使用指定的凭据建立到 AD 服务器之一的经过身份验证的连接。问题是,当PrincipalContext.ValidateCredentials设置此调用时(在您的场景中),它总是设置AuthType = Negotiate。在这种情况下,Kerberos实际上确实被使用,并最终失败,但系统回退到NTLM。 ”
| 归档时间: |
|
| 查看次数: |
8464 次 |
| 最近记录: |