Manage directory entries using the following methods:
Add(LdapEntry): Creates a new entry. Supports binary values via DirectoryAttribute.Modify(LdapModifyEntry): Updates an existing entry. Supports operations like LDAP_MOD_REPLACE, LDAP_MOD_ADD, and LDAP_MOD_DELETE.Delete(dn): Removes an entry.Rename(dn, newDn, ...): Renames an entry.
All these methods have Async counterparts (e.g., AddAsync, ModifyAsync, DeleteAsync, RenameAsync).
cn.Add(new LdapEntry
{
Dn = "cn=test,dc=example,dc=com",
Attributes = new Dictionary<string, List<string>>
{
{"sn", new List<string> {"Winston"}},
{"objectclass", new List<string> {"inetOrgPerson"}}
}
});
// Modify an entry
cn.Modify(new LdapModifyEntry
{
Dn = "cn=test,dc=example,dc=com",
Attributes = new List<LdapModifyAttribute>
{
new LdapModifyAttribute { LdapModOperation = LdapModOperation.LDAP_MOD_REPLACE, Type = "givenName", Values = new List<string> {"new_name"} }
}
});