Can someone lead me through creating a user object in AD.
I have tried creating one through LDAP and ADSI (WinNT://) but nothing
happens.
Where do you want to create it at ?? (what location in your AD?)
You will need to bind to the container you want to create your user in
- e.g. like this (sample in C#):
DirectoryEntry deOU = new
DirectoryEntry("LDAP://ou=Finance,ou=HQ,dc=SomeCorp,dc=com");
Then, you need to specify that you want to create a user, by adding it
to the list of children of that container - you need to specify the
name of the new object (first parameter, in LDAP style, including the
cn= prefix for a group or user!), and the type of the object (second
parameter):
DirectoryEntry deNewUser = deOU.Children.Add("cn=New User", "user");
Then, you need to specify at least all the mandatory properties of
that newly created object, for a user object, that's at least the
samACcountName (which has to be unique in the entire domain):
deNewUser.Properties["samAccountName"].Value = "newUser";
Then, you need to store the user object back to the directory store:
deNewUser.CommitChanges();
And you're done!!
PS: Avoid the WinNT: provider whenever you can - it's deprecated, and
should *only* ever be used if you have no other choice - LDAP: is MUCH
preferred!
HTH
Marc
================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch