Creating Account on remote machines in a Workgroup
Hi, I'm trying to develop a program in .NET 2.0 that will manage( create, modify) user accounts on remote computers. These computers are not part of a domain and do not have active directory running on them. They are running under their own workgroup Can DirectoryEntry be used? The DirectoryEntry constructor does take username, password for the remote machine. So I think providing the credentials of Administrator on that machine should have worked. But it does not. I'm using System.DirectoryServices. DirectoryEntry Ad =new System.DirectoryServices.DirectoryEntry( "WinNT://" +"Machine2","Administrator","ewrerseadr21321!@#",System.DirectoryServices.AuthenticationTypes.Secure); Can anybody comment? Thanks |
absolutely. Try this:
//create user account:
DirectoryEntry theEntry = new DirectoryEngry("WinNT://" + Environment.MachineName + ",computer", "AuthenticationUsername", "AuthenticationPassword");
DirectoryEntry theUser = theEntry.Children.Add("username", "user");
theUser.Invoke("SetPassword", new object[] { "password"});
theUser.Invoke("Put", new object[] { "Description", "User Description"});
theUser.CommitChanges();
you can replace "Environment.MachineName" with the computer name you wish to access, hopefully if you have access rights
does this help?
Could you plz clarify "hopefully if you have access rights"? Is it not sufficient that "AuthenticationUsername" is an Administrator on that machine?
I thought the above works only in case of ActiveDirectory( i.e. the machines are on a domain)?
no it can work locally also. What I meant by "hopefully if you have access rights" is if the computer (remote) has rights for you to modify its properties etc... remotely. It should be ok, making sure you supply the admin account credentials as stated in the first line of code :-)
try it and see what happens!
Thanks ahmedilyas
You are right it can work locally too.
Actually the problem was that the lan on which I tried earlier could not browse workgroup computers. There is some problem with that lan in which I could ping the other pc's on the lan but cannot browse the workgroup. I tried it on another lan and it worked 