Reset Password for Windows Server 2008 R2

We have a Self Service Employee application running on a standalone server. One of the features of the application is the "forgotten password", so employees can reset to use their own passwords. It works fine on all servers, but not on Windows Server 2008 R2. The following is a snippet of the code we use:

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

It seems that it is generally impossible to get it to work in Windows Server 2008 R2. If this works for someone, please help.

thank

+3
source share
2 answers

UserPrincipal.SetPassword. , , . , . .

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

Source: https://habr.com/ru/post/1781886/


All Articles