The ldapcompare Command-Line Tool

Perform compare operations in an LDAP directory server. Compare operations may be used to efficiently determine whether a specified entry has a given value.

The exit code for this tool will indicate whether processing was successful or unsuccessful, and to provide a basic indication of the reason for unsuccessful attempts. By default, it will use an exit code of zero (which corresponds to the LDAP 'success' result) if all compare operations completed with a result code of either 'compare false' or 'compare true' (integer values 5 and 6, respectively), but if the --useCompareResultCodeAsExitCode argument is provided, only one compare assertion is performed, and it yields an exit code of 'compare false' or 'compare true', then the numeric value for that result code will be used as the exit code. If any error occurs during processing, then the exit code will be a nonzero value that reflects the first error result that was encountered.

The attribute type and assertion value to use for the compare operations will typically be provided as the first unnamed trailing argument provided on the command line. It should be formatted with the name or OID of the target attribute type followed by a single colon and the string representation of the assertion value. Alternatively, the attribute name or OID may be followed by two colons and the base64-encoded representation of the assertion value, or it may be followed by a colon and a less-than symbol to indicate that the assertion value should be read from a file (in which case the exact bytes of the file, including line breaks, will be used as the assertion value).

The DNs of the entries to compare may either be provided on the command line as additional unnamed trailing arguments after the provided attribute-value assertion, or they may be read from a file whose path is provided using the --dnFile argument.

If the attribute-value assertion is provided on the command line as an unnamed trailing argument, then the same assertion will be performed for all operations. If multiple types of assertions should be performed, then you may use the --assertionFile argument to specify the path to a file containing both attribute-value assertions and entry DNs.

Usage

ldapcompare {arguments} [attribute:value|attribute::base64Value|attribute:<valueFilePath [dn1 [dn2 [ dn3 [ .. ]]]]]

LDAP Connection and Authentication Arguments

Processing Arguments

Bind Control Arguments

Compare Control Arguments

Output Arguments

Additional Arguments

Dependent Argument Sets

Exclusive Argument Sets

Examples

    ldapcompare --hostname ds.example.com --port 636 --useSSL \
         --bindDN uid=admin,dc=example,dc=com l:Austin \
         uid=jdoe,ou=People,dc=example,dc=com
    ldapcompare --hostname ds.example.com --port 636 --useSSL \
         --bindDN uid=admin,dc=example,dc=com --dnFile entry-dns.txt \
         --outputFormat csv --terse title:manager
    ldapcompare --hostname ds.example.com --port 636 --useSSL \
         --bindDN uid=admin,dc=example,dc=com \
         --assertionFile compare-assertions.txt --outputFormat json \
         --outputFile compare-assertion-results.json --verbose