A.2. Comparing Entries
ldapcompare
checks entries to see if the specified entry or entries contain an attribute of a specific value. For example, this checks to see if an entry has an sn
value of Smith:
# ldapcompare -D "cn=Directory Manager" -W -p 389 -h server.example.com -x sn:smith uid=bjensen,ou=people,dc=example,dc=com comparing type: "sn" value: "smith" in entry "uid=bjensen,ou=people,dc=example,dc=com" compare FALSE ldapcompare -D "cn=Directory Manager" -W -p 389 -h server.example.com -x sn:smith uid=jsmith,ou=people,dc=example,dc=com comparing type: "sn" value: "smith" in entry "uid=jsmith,ou=people,dc=example,dc=com" compare TRUE
The compare attribute can be specified in one of three ways:
- A single attribute:value statement passed in the command line directly
sn:Smith
- A single attribute::base64value statement passed in the command line directly, for attributes like
jpegPhoto
or to verify certificates or CRLsjpegPhoto:dkdkPDKCDdko0eiofk==
- An attribute:file statement that points to a file containing a list of comparison values for the attribute, and the script iterates through the list
postalCode:/tmp/codes.txt
The compare operation itself has to be run against a specific entry or group of entries. A single entry DN can be passed through the command line, or a list of DNs to be compared can be given using the
-f
option.
Example A.1. Comparing One Attribute Value to One Entry
Both the attribute-value comparison and the DN are passed with the script.
ldapcompare -D "cn=Directory Manager" -W -p 389 -h server.example.com -x sn:smith uid=jsmith,ou=people,dc=example,dc=com comparing type: "sn" value: "smith" in entry "uid=jsmith,ou=people,dc=example,dc=com" compare TRUE
Example A.2. Comparing a List Attribute Values from a File
First, create a file of possible
sn
values.
jensen johnson johannson jackson jorgenson
Then, create a list of entries to compare the values to.
uid=jen200,ou=people,dc=example,dc=com uid=dsj,ou=people,dc=example,dc=com uid=matthewjms,ou=people,dc=example,dc=com uid=john1234,ou=people,dc=example,dc=com uid=jack.son.1990,ou=people,dc=example,dc=com
Then run the script.
# ldapcompare -D "cn=Directory Manager" -W -p 389 -h server.example.com -x sn:/tmp/surnames.txt -f /tmp/names.txt comparing type: "sn" value: "jensen" in entry "uid=jen200,ou=people,dc=example,dc=com" compare TRUE