Adding New Entries to an LDAP Directory
LDAP (Lightweight Directory Access Protocol) supports adding and modifying entries such as users and groups. To add a new entry, first bind as a user with permissions to add:
ldap.DN = "DOMAIN\\Administrator";
ldap.Password = "admin";
ldap.Bind();
Next, specify the new DN you'd like to add, and specify all the attributes that will be required in order to add this new entry to the server. Which attributes are required depend on the schema. For Active Directory, a typical user DN add might look like this:
ldap.DN = "cn=NewUser,cn=Users,dc=DOMAIN";
ldap.Attributes.Add(new LDAPAttribute("objectClass", "top"));
ldap.Attributes.Add(new LDAPAttribute("", "person"));
ldap.Attributes.Add(new LDAPAttribute("", "organizationalPerson"));
ldap.Attributes.Add(new LDAPAttribute("", "inetorgperson"));
ldap.Add();
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.