PingDirectory

Adding multiple entries in a single file

About this task

Add multiple entries in your LDIF file by separating each distinguished name (DN) and its entry with a blank line from the next entry.

Steps

  1. Open a text editor and create some entries that conform to your schema.

    Example:

    For example, add the following entries in the file and save the file as add-user3.ldif. Separate each entry with a blank line.

    dn: uid=user.2003,ou=People,dc=example,dc=com
    objectClass: top
    objectClass: person
    objectClass:
    organizationalPerson
    objectClass: inetOrgPerson
    ...(similar attributes to previous examples)...
    
    dn: uid=user.2004,ou=People,dc=example,dc=com
    objectClass: top
    objectClass: person
    objectClass: organizationalPerson
    objectClass: inetOrgPerson
    ...(similar attributes to previous examples)...
  2. To add the entries specified in the LDIF file, run the ldapmodify tool.

    Example:

    This example uses the short form arguments for the ldapmodify tool.

    $ bin/ldapmodify -h server.example.com -p 389 \
      -D "cn=admin,dc=example,dc=com" -w password -a -f add-user3.ldif

    The -h option specifies the host name, the -p option specifies the LDAP listener port, -D specifies the bind DN, -w specifies the bind DN password, -a specifies that entries that omit a changetype are treated as add operations, and -f specifies the path to the input file. If the operation is successful, you will see commented messages (those begining with "#") for each addition.

    Result:

    # Processing ADD request for uid=user.2003,ou=People,dc=example,dc=com
    # ADD operation successful for DN uid=user.2003,ou=People,dc=example,dc=com
    # Processing ADD request for uid=user.2004,ou=People,dc=example,dc=com
    # ADD operation successful for DN uid=user.2004,ou=People,dc=example,dc=com