How do I add, replace, or delete attributes for an existing LDAP entry?

To add, replace, or delete attributes for an existing LDAP entry, first bind as a user with permissions to modify ldap.DN = "DOMAIN\\Administrator"; ldap.Password = "admin"; ldap.Bind(); Next, specify the attributes you'd like to add, replace, or delete. For example, to add: ldap.DN = "cn=SomeUser,cn=Users,dc=DOMAIN"; ldap.Attributes.Add(new LDAPAttribute("description", "added")); ldap.Modify(); To replace, the procedure is the same - just specify the ModOp for the attribute in question: ldap.DN = "cn=SomeUser,cn=Users,dc=DOMAIN"; ldap.Attributes.Add(new LDAPAttribute("description", "added", LDAPAttributeModOps.amoReplace)); ldap.Modify(); To delete, again, the procedure is the same - just specify the ModOp for the attribute in question: ldap.DN = "cn=SomeUser,cn=Users,dc=DOMAIN"; ldap.Attributes.Add(new LDAPAttribute("description", "added", LDAPAttributeModOps.amoDelete)); ldap.Modify(); Note: when modifying multi-valued attributes, like "url", only specify the type of the attr once. For example: ldap.Attributes.Add(new LDAPAttribute("url", "www.chalupas.com")); ldap.Attributes.Add(new LDAPAttribute("", "www.taquitos.com")); A replace on a multi-valued attribute will replace all values with the new one(s). A replace on any attribute with no value will have the same result as a delete with no value - all values of the attribute type in question will be deleted.

We appreciate your feedback.  If you have any questions, comments, or suggestions about this article please contact our support team at kb@nsoftware.com.