Changing a Windows User Password Remotely Using .NET

How to change the local password of a local user account using VB.NET/C#?

I looked at the DirectoryEntry class and know how to add users to the group, but I can’t figure out how to change the (local) password.

+3
source share
2 answers

Using .net 3.5:

PrincipalContext context = new PrincipalContext(ContextType.Domain);
UserPrincipal user = UserPrincipal.FindByIdentity(context, "user");

User can change their password:

user.ChangePassword("old", "new");

Or, if you run the AD admin, you can reset it:

user.SetPassword("1234567");
+3
source

Yes,

This may work with .net 3.5 and higher, but this requires the server service (for example, file sharing) to be turned on and running. What if it's not ???

, , ADSI VB.Net( BTW)... :

Dim uName as string = "trgtUser"
Dim uPass as string = "newPass"
Dim user = GetObject("WinNT://./" & uName & ",user")
user.SetPassword(uPass)

, !

;)

+2

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


All Articles