4

what I need to do is: Create User account on another machine from my machine using C#. I tried to use DirectoryEntry("WinNt://"....) but it create this account localy in my current machine. I tried many time to add the destination machine name in this method but no way :S. also i googled and found many articles illustrated somethings like this but not actual what i need. any suggestion will be appreciated.

Steve
  • 31,144
  • 19
  • 99
  • 122
Ragaei Mahmoud
  • 447
  • 2
  • 11
  • 26
  • you mean a windows user account? which version? – mpen Jun 15 '11 at 06:39
  • yes windows user account – Ragaei Mahmoud Jun 15 '11 at 06:40
  • version of what?windows?i am currenly using windows XP Prof SP3 but in the future i need to apply my project in a server running w2K3SP2 or W2K8SP1 – Ragaei Mahmoud Jun 15 '11 at 06:41
  • string s_Username = "TestUser"; string s_Password = "password"; string s_Description = "Test User Account"; DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer"); // create a new user DirectoryEntry NewUser = AD.Children.Add(s_Username, "user"); NewUser.Invoke("SetPassword", new object[] { s_Password }); NewUser.Invoke("Put", new object[] { "Description", s_Description }); // commit the changes NewUser.CommitChanges(); lblResult.Text = "Success!!"; – Ragaei Mahmoud Jun 15 '11 at 06:51
  • I tried to replace Environment.MachineName with the remote machine name>>but it failed.both of these two machines are in the same domain – Ragaei Mahmoud Jun 15 '11 at 06:52
  • @KMan : this link gives me :p;age not found :) – Ragaei Mahmoud Jun 15 '11 at 06:58
  • @Ragaei Mahmoud: Look into [WMI](http://msdn.microsoft.com/en-us/library/aa389769%28v=vs.85%29.aspx) – KMån Jun 15 '11 at 07:02

2 Answers2

1

Checkout:

Alternatively, you can spawn a TCP server/service on the server machine, and send commands remotely via messages.

Community
  • 1
  • 1
KMån
  • 9,896
  • 2
  • 31
  • 41
0

I'd say you'd have to go to a little client server architecture where the remote 'server' creates a local user based on the supplied client data.

CodingBarfield
  • 3,392
  • 2
  • 27
  • 54