Hey,
Does anyone know where a list of active directory property key names can be found? Here is my problem:
I'm trying to write users to a Server 2003 active directory. Here is the code I have so far...
DirectoryEntry OU= entry.Children.Find("CN=USERS");
DirectoryEntry NewUser = OU.Children.Add("CN=TESTUSER", "User");
NewUser.Properties["sAMAccountName"].Value = "TEST";
NewUser.Properties["userPrincipalName"].Add("TESTUSER@test.com"); NewUser.Properties"GivenName"].Add "FirstName");
NewUser.Properties["initials"].Add("TU");
NewUser.Properties["sn"].Add("LASTNAME");
NewUser.Properties["displayName"].Add("TEST");
NewUser.Properties["description"].Add("TEST");
NewUser.CommitChanges();
NewUser.Invoke("SetPassword", "temp");
NewUser.Properties["PwdLastSet"].Value = 0;
NewUser.CommitChanges();
The problem here is that this will create a new user, but the account is disabled. What i really need to do is create the account but also set the account as active. I can't seem to find out what the key word is for that property setting. Any help would be great,
Thanks,
Brandon
Does anyone know where a list of active directory property key names can be found? Here is my problem:
I'm trying to write users to a Server 2003 active directory. Here is the code I have so far...
DirectoryEntry OU= entry.Children.Find("CN=USERS");
DirectoryEntry NewUser = OU.Children.Add("CN=TESTUSER", "User");
NewUser.Properties["sAMAccountName"].Value = "TEST";
NewUser.Properties["userPrincipalName"].Add("TESTUSER@test.com"); NewUser.Properties"GivenName"].Add "FirstName");
NewUser.Properties["initials"].Add("TU");
NewUser.Properties["sn"].Add("LASTNAME");
NewUser.Properties["displayName"].Add("TEST");
NewUser.Properties["description"].Add("TEST");
NewUser.CommitChanges();
NewUser.Invoke("SetPassword", "temp");
NewUser.Properties["PwdLastSet"].Value = 0;
NewUser.CommitChanges();
The problem here is that this will create a new user, but the account is disabled. What i really need to do is create the account but also set the account as active. I can't seem to find out what the key word is for that property setting. Any help would be great,
Thanks,
Brandon