{scrollbar}

This section gives an overview on how to manipulate entries within your directory. Manipulating data with the help of graphical tools is straight forward. This section concentrates on using LDIF and command line tools.

22list

Adding an entry

Let's start with adding a new entry to the "Seven Seas" partition (it is therefore assumed that you have already imported the sample data).

A person to add

The data is inspired by "Peter Pan" and provided by this LDIF file (captain_hook.ldif):

# File captain_hook.ldif dn: cn=James Hook,ou=people,o=sevenSeas objectclass: person objectclass: top cn: James Hook description: A pirate captain and Peter Pan's nemesis sn: Hook userpassword: peterPan

The entry with distinguished name "cn=James Hook,ou=people,o=sevenSeas" describes a person. In the default schema of ApacheDS (as defined in RFC 2256), object class person requires attribute values for cn (common name) and sn (surname). The other attributes are optional. The following screenshot of a schema browser illustrates this:

Using a command line tool to add the entry

It depends on your authorization configuration, which directory users are allowed to add entries (or generally to manipulate data). The administrator uid=admin,ou=system is always allowed to do anything; thus we use him for authentication.

With ldapmodify, the data above can be added to the sample partition like this:

none $ ldapmodify -h zanzibar -p 10389 -D "uid=admin,ou=system" -w secret -a -f captain_hook.ldif adding new entry cn=James Hook,ou=people,o=sevenSeas $

The following table contains descriptions for the options used. See the manpage of ldapmodify for details.

Option

Meaning

-h zanzibar

Hostname

-p 10389

Port

-D "uid=admin,ou=system"

Distinguished name to bind (user with appropriate privileges needed)

-w ******

Password of bind user

-a

add new entries

-f captain_hook.ldif

Name of LDIF file to load

Note that the file contains only one entry, but it is possible to add several entries at once with a single ldapmodify call. An LDIF file can contain an arbitrary number of entries, seperated by an empty line. an ldapmodify call as above would try to add them one by one.

Verification

With the help of the ldapsearch command, you can verify that the entry is indeed present in the directory.

$ ldapsearch -h zanzibar -p 10389 -D "uid=admin,ou=system" -w secret -b "o=sevenSeas" -s sub "(cn=James*)" version: 1 dn: cn=James Hook,ou=people,o=sevenSeas userpassword: peterPan description: A pirate captain and Peter Pan's nemesis objectclass: person objectclass: top sn: Hook cn: James Hook $

Learn more about LDAP search operations here. Another option for verification is to use a graphical tool like Softerra LDAP Browser:

Modifying an entry

Modifications with the help of LDIF

LDIF can either be used to describe complete entries, like Caption Hook in the example before, or to describe a set of changes made (or to be mode) to directory entries. In the following we use the latter variant. We present simple LDIF files with changes to an entry (Hook again, the samples assume his existence within the tree) and apply them to the directory.

Adding attribute values

Let's add a telephone number and a second description to the entry "cn=James Hook,ou=people,o=sevenSeas".
A corresponding LDIF file (captain_hook_modify_addAttrs.ldif) looks like this:

# File captain_hook_modify_addAttrs.ldif dn: cn=James Hook,ou=people,o=sevenSeas changetype: modify add: description description: Wears an iron hook in place of his right hand - add: telephoneNumber telephoneNumber: 254-20 -

We apply these changes to the dircetory with the help of the ldapmodify command:

$ldapmodify -h zanzibar -p 10389 -D "uid=admin,ou=system" -w secret -f captain_hook_modify_addAttrs.ldif modifying entry cn=James Hook,ou=people,o=sevenSeas $

The arguments are the same as in the add example above, execept the missing -a switch (because we perform modifications, not additions).

After successfully applying these changes, we can verify the effect with a search operation.

$ ldapsearch -h zanzibar -p 10389 -D "uid=admin,ou=system" -w secret -b "o=sevenSeas" -s sub "(cn=James Hook)" version: 1 dn: cn=James Hook,ou=people,o=sevenSeas sn: Hook telephonenumber: 254-20 userpassword: peterPan objectclass: person objectclass: top cn: James Hook description: A pirate captain and Peter Pan's nemesis description: Wears an iron hook in place of his right hand $

to be continued

Changing attribute values

Replacing attribute values

Removing attribute values

Recording modify operations with the help of ELBE

Execeution of LDIF files with graphical tools

Deleting an entry

Resources

  • RFC 2849 RFC 2849 - The LDAP Data Interchange Format (LDIF) - Technical Specification
  • RFC 2256 RFC 2256 - A Summary of the X.500(96) User Schema for use with LDAPv3
  • RFC 4511 RFC 4511 - Lightweight Directory Access Protocol (LDAP): The Protocol
  • No labels