Change local administrator password in C#

前端 未结 2 489
星月不相逢
星月不相逢 2020-12-09 12:21

I am looking for a way to change the password of a local user account (local Administrator) on a Windows (XP in this case) machine. I have read the CodeProject article about

2条回答
  •  执念已碎
    2020-12-09 13:05

    As Ely noted, you can use the System.DirectoryServices code to accomplish this per MSDN:

    String myADSPath = "LDAP://onecity/CN=Users,
         DC=onecity,DC=corp,DC=fabrikam,DC=com";
    
    // Create an Instance of DirectoryEntry.
    DirectoryEntry myDirectoryEntry = new DirectoryEntry(myADSPath);
    myDirectoryEntry.Username = UserName;
    myDirectoryEntry.Password = SecurelyStoredPassword;
    

提交回复
热议问题