I used the following code to create a new user in active directory. From this, the new user is created in active directory without any error. But, I could not work with that new user using its password, here i am set the password using "userPassword" attribute.
Is this correct way to set password for user using "userPassword" attribute or please guide me the correct workflow to achieve this?
LdapAttributeSet attributeSet = new LdapAttributeSet();
attributeSet.Add(new LdapAttribute("objectclass", "user"));
attributeSet.Add(new LdapAttribute("sAMAccountName", "myuser"));
attributeSet.Add(new LdapAttribute("userPRincipalName", "myuser"));
attributeSet.Add(new LdapAttribute("userAccountControl", (66080).ToString()));
attributeSet.Add(new LdapAttribute("userPassword", "mypassword"));
string dn = "CN=myuser,CN=Users,DC=mydomain,DC=com";
LdapEntry newEntry = new LdapEntry(dn, attributeSet);
LdapConnection ldapConn = new LdapConnection();
ldapConn.Connect(ldapHost, 369);
ldapConn.Bind(loginDN, password);
ldapConn.Add(newEntry);