LDIF Tools

Generate Test Data

The makeldif command uses templates to generate sample data with great flexibility. Default templates are located in the opendj/config/MakeLDIF/ directory.

The quickest way to generate user entries is to use the ds-evaluation setup profile. The profile lets you generate an arbitrary number of Example.com users as part of the setup process.

For details, see Install DS for Evaluation.

  1. Write a template file for your generated LDIF.

    The example.template file used in the examples creates inetOrgPerson entries. To learn how to generate test data that matches your production data more closely, read makeldif-template.

  2. Create additional data files for your template.

    Additional data files are located in the same directory as your template file.

  3. Decide whether to generate the same test data each time you use the same template.

    If so, provide the same randomSeed integer each time you run the command.

  4. Run the makeldif command to generate your LDIF file.

    The following command demonstrates use of the example MakeLDIF template:

    $ makeldif \
     --outputLdif generated.ldif \
     --randomSeed 42 \
     /path/to/opendj/config/MakeLDIF/example.template
    
    LDIF processing complete.

Search LDIF

The ldifsearch command searches for entries in LDIF files:

$ ldifsearch \
 --baseDN dc=example,dc=com \
 generated.ldif \
 "(sn=Grenier)" \
 uid

dn: uid=user.4630,ou=People,dc=example,dc=com
uid: user.4630

Update LDIF

The ldifmodify command applies changes, generating a new version of the LDIF.

In the example that follows, the changes.ldif file contains the following LDIF:

dn: uid=user.0,ou=People,dc=example,dc=com
changetype: modify
replace: description
description: New description.
-
replace: initials
initials: ZZZ

The resulting target LDIF file is approximately the same size as the source LDIF file, but the order of entries in the file is not guaranteed to be identical:

$ ldifmodify \
 --outputLdif new.ldif \
 generated.ldif \
 changes.ldif

Compare LDIF

The ldifdiff command reports differences between two LDIF files in LDIF format:

$ ldifdiff generated.ldif new.ldif

dn: uid=user.0,ou=People,dc=example,dc=com
changetype: modify
delete: description
description: This is the description for Aaccf Amar.
-
add: description
description: New description.
-
delete: initials
initials: AAA
-
add: initials
initials: ZZZ
-

The ldifdiff command reads files into memory to compare their contents. The command is designed to work with small files and fragments, and can quickly run out of memory when calculating the differences between large files.

Use Standard Input

For each LDIF tool, a double dash, --, signifies the end of command options. After the double dash, only trailing arguments are allowed.

To indicate standard input as a trailing argument, use a bare dash, -, after the double dash. How bare dashes are used after a double dash depends on the tool:

ldifdiff

The bare dash can replace either the source LDIF file, or the target LDIF file argument.

To take the source LDIF from standard input, use the following construction:

ldifdiff [options] -- - target.ldif

To take the target LDIF from standard input, use the following construction:

ldifdiff [options] -- source.ldif -
ldifmodify

The bare dash can replace either the source.ldif or changes.ldif file arguments.

To take the source LDIF from standard input, use the following construction:

ldifmodify [options] -- - changes.ldif [changes.ldif ...]

To take the changes in LDIF from standard input, use the following construction:

ldifmodify [options] -- source.ldif -
ldifsearch

The bare dash lets you take the source LDIF from standard input with the following construction:

ldifsearch [options] -- - filter [attributes ...]