>I'm getting there.... I now have my user object created and I can set most
of the properties that I want to... the problem now is when I'm creating my
user object the user account is disabled by default. I have been looking at
C# examples form the MSDN site...
[C#]
DirectoryEntry usr =
new DirectoryEntry("LDAP://CN=New User,CN=users,DC=fabrikam,DC=com");
int val = (int) usr.Properties["userAccountControl"].Value;
usr.Properties["userAccountControl"].Value = val & ~ADS_UF_ACCOUNTDISABLE;
usr.CommitChanges();The following code example shows how to disable a user
account.
First off - I don't think your users would be created at all - you
have to set at least the "sAMAccountName" property - it's mandatory.
Also, make sure to *not* specify the cn= prefix (as in the user name),
and make sure the SAM Account name is unique in the domain you're
creating the user in.
To create a user, bind to the container it's supposed to be created
in, and then add an entry to the container's "CHildren" property:
DirectoryEntry deContainer = new
DirectoryEntry("LDAP://CN=users,DC=fabrikam,DC=com");
DirectoryEntry deUser = deContainer.Children.Add("cn=New User",
"user");
deUser.Properties["sAMAccountName"].Value = "New_User";
Secondly, you're on the right track to enable the user - I think you
could write something like this (since you're newly creating a user,
you don't really need to read the previously set value of the property
- just set it!):
deUser.Properties["userAccountControl"].Value = UF_NORMAL_ACCOUNT;
And then lastly, commit the changes:
deUser.CommitChanges();
Now you should have a newly created user, with an enabled account.
Does it work??
Marc
================================================== ==============
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch