Hi,
I am trying to create new user account in AD by using SDS.P.
I was following this sample, which I found here in another post:
SDS.P
LdapConnection con = new LdapConnection("fabrikam.com");
//this allows LDAP pwd changes!
con.SessionOptions.Sealing = true;
con.Bind();
DirectoryAttribute samName = new DirectoryAttribute("sAMAccountName", "User1Acct");
DirectoryAttribute objectClass = new DirectoryAttribute("objectClass", "user");
DirectoryAttribute sn = new DirectoryAttribute("sn", "User");
DirectoryAttribute givenName = new DirectoryAttribute("givenName", "One");
//fancy formatting for password data
byte[] pwdData = Encoding.Unicode.GetBytes("\"pAssw0rdO1\"");
DirectoryAttribute unicodePwd = new DirectoryAttribute("unicodePwd", pwdData);
DirectoryAttribute pwdLastSet = new DirectoryAttribute("pwdLastSet", "0");
DirectoryAttribute uac = new DirectoryAttribute("userAccountControl", "512");
DirectoryAttribute[] dirAttribs = new DirectoryAttribute[]
{samName, objectClass, sn, givenName, unicodePwd, pwdLastSet, uac};
AddRequest add =
new AddRequest("CN=User1Acct,ou=TechWriters,dc=fabrikam,dc=com", dirAttribs);
con.SendRequest(add);
The problem I have is with the password attribute. If I remove password from the list, user account is created successfully.
When password is in the list of attributes, I have this error:
DirectoryOperationException in CreateObject: UnwillingToPerform - [The server cannot handle directory requests.]
Here is my connection object:
_ldapConnObject = new LdapConnection(_adServerPath);
_ldapConnObject.AuthType = AuthType.Negotiate;
cred = new NetworkCredential(adminAcct, adminPassword, domain);
_ldapConnObject.Credential = cred;
_ldapConnObject.SessionOptions.Sealing = true;
Thank you in advance for any help.