Examples of using ldapsearch

The following examples us the ldapsearch utility.

About this task

Table 1. Examples of using the ldapsearch utility

Search

Command

All entries on host ldap.renovations.com using port 389, and return all attributes and values

ldapsearch -h ldap.renovations.com "objectClass=*"

All entries on host ldap.renovations,com using port 389, and return attribute names only

ldapsearch -A -h ldap.renovations.com "objectClass=*"

All entries on host ldap.renovations.com using port 389, return all attributes, and de-reference any aliases found

ldapsearch -a always -h ldap.renovations.com "objectClass=*"

All entries on host ldap.renovations.com using port 389, and return attributes=mail, cn, sn, givenname

ldapsearch -h ldap.renovations.com "objectClass=*" mail cn sn givenname

(cn=Mike*) under base "ou=West,o=Renovations, c=US" on host ldap.renovations.com using port 389, and return all attributes and values

ldapsearch -b "ou=West,o=Renovations,c=US" -h ldap.renovations.com "(cn=Mike*)"

One level on host ldap.renovations.com using port 389, and return all attributes and values

ldapsearch -s onelevel -h ldap.renovations.com "objectClass=*"

One level on host ldap.renovations.com using port 389, and return all attributes and values, but with scope limited to base

ldapsearch -s base -h ldap.renovations.com "objectClass=*"

All entries on host ldap.renovations.com using port 389; return all attributes and values; do not exceed the time limit of five seconds

ldapsearch -l 5 -h ldap.renovations.com "objectClass=*"

All entries on host ldap.renovations.com using port 389; return all attributes and values; do not exceed the size limit of five

ldapsearch -z 5 -h ldap.renovations.com "objectClass=*"

All entries on host ldap.renovations.com using port 389, binding as user "cn=John Doe,o=Renovations" with a password of "password", and return all attributes and values in LDIF format

ldapsearch -h ldap.renovations.com -D "cn=john doe,o=renovations" -w password -L "objectClass=*"

Search the host ldap.renovations.com using port 389. All attributes that anonymous are allowed to see are returned for the entry "cn=John Doe,o=Renovations"

ldapsearch -h ldap.renovations.com -s base -b "cn=john doe,o=renovations" "objectClass=*"