3

我们有一个在独立服务器上运行的员工自助服务应用程序。该应用程序的功能之一是“忘记密码”,因此员工可以重置自己的密码。它适用于所有服务器,但不适用于 Windows Server 2008 R2。下面是我们使用的一段代码:

User.Invoke("SetPassword", new object[] {"#12345Abc"});
User.CommitChanges();

看起来根本无法使其在 Windows Server 2008 R2 中运行。如果有人有它的工作,请帮助。

谢谢

4

2 回答 2

1

我们也试过这个:

PrincipalContext context = new PrincipalContext(ContextType.Machine, "servername");

UserPrincipal up = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, "username");
if (up != null)
{
    up.SetPassword("newpassword");
    // We got the same access denied exception here
    up.Save();
}
于 2010-12-23T18:56:59.127 回答
1

尝试 UserPrincipal.SetPassword。它是更高级别的抽象,因此更智能。它将知道要调用哪个较低级别的函数。调用方式对我来说似乎太脆弱了。

于 2010-12-23T18:48:32.493 回答