小编Dir*_*irk的帖子

DirectoryServices.AccountManagement"旧"密码在密码更改后仍然有效

在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

directoryservices active-directory account-management

5
推荐指数
2
解决办法
8464
查看次数