OpenLDAP client tools Query LDAP directories
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
ldapsearch -x -H ldap://<host> -b <base>
ldapsearch -x -H <uri> -D <binddn> -W -b
<base>
ldapsearch -x -b <base>
"(uid=<name>)"
ldapsearch -x -b <base> "(cn=*)" cn
mail
ldapsearch -LLL -x -b <base>
ldapsearch -x -s base -b "" -H <uri>
+
ldapwhoami -x -H <uri> -D <binddn> -W
ldapmodify -x -H <uri> -D <binddn> -W -f
<file>
Concepts
- Connect -H uri, -Z StartTLS
- Bind -x -D -W or SASL
- Search -b base -s scope filter
- Entries attrs, LDIF output
Connect and bind
-H ldap://<host>[:<port>]
-H ldaps://<host>
-H ldapi:///-x-D <binddn>
-W-y <file>-w <password>
-ZZ-Y EXTERNAL -H ldapi:///
-Y GSSAPI-P 3-o nettimeout=<s>
Searching
-b <base>-b ""-s base / one / sub / children
"(<attr>=<value>)"
"(<attr>=<pre>*)"
"(<attr>=*)"
"(&(<f1>)(<f2>))"
"(|(<f1>)(<f2>))"
"(!(<f>))"
"(<attr>>=<n>)"
"(<attr>~=<value>)"
-z <n>-l <seconds>
-a always\28 \29 \2a \5c-f <file> "(uid=%s)"
Attributes and output
... <filter> cn mail
"*" "+"
1.1-LLL-L-A-S <attr>-o ldif_wrap=no-t-u-E pr=<n>/noprompt
-E sss=<attr>
-E vlv=<b>/<a>/<off>/<cnt>
-v-d 1-nChange entries
ldapadd -x -D <binddn> -W -f <file>
ldapmodify -x -D <binddn> -W -f <file>
ldapdelete -x -D <binddn> -W
"<dn>"
ldapdelete -r "<dn>"
ldapmodrdn -x -D <binddn> -W "<dn>"
"<newrdn>"
ldappasswd -x -D <binddn> -W -S
"<dn>"
ldappasswd -A -S
ldapwhoami -x -D <binddn> -W
ldapmodify -c -S <skipfile>
ldapmodify -aldapmodify -n -v
ldapcompare -x "<dn>"
<attr>:<value>
| Line | Meaning |
|---|---|
dn: <dn> |
Entry to change |
changetype: modify |
Modify (also add, delete, modrdn) |
add: / replace: / delete: <attr>
|
Operation on an attribute |
- |
Ends one operation block |
Recipes
# dump a whole subtree to a fileldapsearch -x -LLL -H ldaps://<host> -D <binddn> -W \ -b "<base>" "(objectClass=*)" > backup.ldif
# find the naming contexts the server offersldapsearch -x -LLL -H ldap://<host> -s base -b "" \ namingContexts supportedSASLMechanisms
# members of a group, only mail addressesldapsearch -x -LLL -ZZ -H ldap://<host> -D <binddn> -W -b <base> \ "(&(objectClass=person)(memberOf=<groupdn>))" mail
# change a mail addresscat > fix.ldif <<'EOF'dn: <dn>changetype: modifyreplace: mailmail: <new>EOFldapmodify -x -D <binddn> -W -f fix.ldif



