簡體   English   中英

在Windows Server 2008 R2上重置密碼

[英]Reset password on Windows Server 2008 R2

我們在獨立服務器上運行了一個Employee Self Service應用程序。 該應用程序的一個功能是“忘記密碼”,因此員工可以重置自己的密碼。 它適用於所有服務器,但不適用於Windows Server 2008 R2。 下面是我們使用的代碼片段:

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

看起來根本無法使其在Windows Server 2008 R2中運行。 如果有人有它,請幫忙。

謝謝

嘗試UserPrincipal.SetPassword。 它是更高級別的抽象,因此更智能。 它將知道要調用的低級函數。 調用方式對我來說似乎太脆弱了。

我們也試過這個:

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();
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM