dde*_*ant 5 c# asp.net passwords active-directory
我正在运行一个更改用户密码的 ASP.NET 应用程序。PasswordException “指定的网络密码不正确。” 每次调用 ChangePassword 方法时都会抛出,即使当前密码已经过验证。
如果我输入的当前密码无效,则会引发异常。这是预期的结果。
如果我输入一个有效的当前密码,则会抛出异常,但密码仍然会被更改(我已经测试过在更改后立即验证它)。
代码非常简单:
var context = new PrincipalContext(ContextType.Domain, "domain.net");
var valid = context.ValidateCredentials(username, oldPassword);
var userPrincipal = UserPrincipal.FindByIdentity(context, username);
userPrincipal.ChangePassword(oldPassword, newPassword);
Run Code Online (Sandbox Code Playgroud)
这导致每次都抛出以下异常,无论当前密码是否正确:
System.DirectoryServices.AccountManagement.PasswordException: The specified network password is not correct. (Exception from HRESULT: 0x80070056) ---> System.Runtime.InteropServices.COMException: The specified network password is not correct. (Exception from HRESULT: 0x80070056)
--- End of inner exception stack trace ---
at System.DirectoryServices.AccountManagement.SDSUtils.ChangePassword(DirectoryEntry de, String oldPassword, String newPassword)
at System.DirectoryServices.AccountManagement.ADStoreCtx.ChangePassword(AuthenticablePrincipal p, String oldPassword, String newPassword)
at StudentAccountManager.ChangeUserPassword(String username, String oldPassword, String newPassword)
Run Code Online (Sandbox Code Playgroud)
有用的信息:
我最好的猜测是凭证验证和正在发送的更改密码请求存在时间问题。是否有可能针对尚未收到更改密码请求的域控制器验证新凭据?这将导致抛出异常,但密码仍在更改。
小智 5
有一个类似的问题,并相信它与 MS16-014 https://support.microsoft.com/en-us/kb/3134228相关 - 它确实在此 KB 中指出存在问题 –(“例如,问题可以当您尝试从加入“域 A”的计算机更改“域 B”密码并且未配置从域 A 到域 B 的信任时发生。”)但它被列为 kb3126041 的问题
需要在我受影响的系统上删除以下更新
kb3126593 kb3126587
操作系统:Windows 2008 R2 SP1
希望这可以帮助。
| 归档时间: |
|
| 查看次数: |
10752 次 |
| 最近记录: |