Modern directory servers like OpenDJ can handle a high load of write requests, replicating changes quickly both on the LAN and over the WAN.
For a complete example corresponding to the excerpts shown below, see ShortLife.java, one of the OpenDJ LDAP SDK examples.
The four basic CRUD operations — create, read, update, and delete — correspond to the LDAP operations add, search, modify (or modify DN), and delete.[8]
An add request is used to create a new entry in an LDAP directory. The entry must have a unique distinguished name that belongs under a base DN served by the directory. The entry must have a list of attributes that are valid according to the directory schema.
Search requests are described in the chapter on Searching & Comparing Directory Data.
A modify request is used to add, delete, or replace attribute values on an entry in an LDAP directory. The resulting entry must be valid according to the directory schema.
A modify DN request is used to rename or move a directory entry.
In both cases the distinguished name changes. Renaming involves changing
the relative distinguished name, for example from
cn=Bob,ou=People,dc=example,dc=com
to
cn=Ted,ou=People,dc=example,dc=com
. Moving
involves changing the container where the entry is found, for example from
cn=Barbara Jensen,ou=People,dc=Old Company,dc=com
to
cn=Barbara Jensen,ou=People,dc=New Company,dc=com
.
Although they are both considered modify DN operations, renaming a leaf entry is generally much simpler than moving a container entry that has child entries. Not all modify DN operations mobilize equivalent resources on the directory server.
A delete request is used to remove an entry from an LDAP directory.
Directory servers can restrict deletes to leaf entries, so that you
cannot remove an entry that has other child entries. For example, you have
to delete uid=bjensen,ou=People,dc=example,dc=com
and
other peer entries before you delete
ou=People,dc=example,dc=com
unless you send a subtree
delete request control.
As a rule, your client application must be authorized to create, update, and delete directory data. Therefore to prepare to change directory data, you first get a connection, and then bind on that connection as a user who is authorized to make the changes you plan to request.
[8] The LDAP bind operation can potentially result in an update. Some directory servers can be configured to write time stamps in order to track successful or failed binds for password policy reasons.