【发布时间】:2012-08-01 12:38:19
【问题描述】:
我需要重置用户密码。为此,我使用以下代码:
DirectoryEntry de = ..
de.AuthenticationType = AuthenticationType.Secure
de.Password = txtPassword.text
de.CommitChanges()
当我运行代码时 - 没有任何反应。用户密码不变,不抛出异常。
如果我使用以下方法:
de.Invoke("SetPassword", .. );
当我运行代码时,我收到一条消息:请插入智能卡...
我对用户帐户拥有管理员权限。 用户没有为智能卡设置无人机。
有什么想法吗?
【问题讨论】:
-
如果可能,请使用
System.DirectoryServices.AccountManagement命名空间,它更容易使用。UserPrincipal对象有一个 ChangePassword() 方法。
标签: c# directoryservices