简体   繁体   中英

Creating local users on remote windows server using c#

Provided I have admin access, I need a way to manage (Create, modify, remove) local accounts in a remote machine from an ASP.NET client.

I'm clueless in how to approach this. Is WMI a possibility (System.Management namespace)? Any pointers?

Give this a try:

DirectoryEntry directoryEntry = new DirectoryEntry("WinNT://ComputerName" & ",computer", "AdminUN", "AdminPW");
DirectoryEntry user = directoryEntry.Children.Add("username", "user");
user.Invoke("SetPassword", new object[] { "password"});
ser.CommitChanges();

If you do need to go the Active Directory route, you can change the directoryEntry path string to something like this: LDAP://CN=ComputerName,DC=MySample,DC=com

I used System.DirectoryServices to get data from users in an ActiveDirectory (LDAP). I don't know if that's the kind of thing you're looking for.
Hope it helps.

您应该可以通过DirectoryEntry执行此操作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM