2011-2013ForgeRock ASldapsearch1OpenDJldapsearchperform LDAP search operationsldapsearchoptionsfilterattributesDescriptionThis utility can be used to perform LDAP search operations in the
directory.OptionsThe following options are supported.Alias dereference policy ('never', 'always', 'search', or 'find')Default value: neverOnly retrieve attribute names but not their valuesUse the LDAP assertion control with the provided filterBase DN format stringContinue processing even if there are errorsUse the persistent search controlCount the number of entries returned by the serverSpecifies geteffectiverights control specific attribute listLDIF file containing the changes to applyUse geteffectiverights control with the provided authzidUse the virtual list view control to retrieve the specified results pageUse a request control with the provided information
For some controloid values,
you can replace object identifiers with user-friendly strings.
The strings are listed here in lower case, but the case is not important.
You can use camelCase if you prefer, for example.
accountusableaccountusabilityAccount Usability Control, Object Identifier: 1.3.6.1.4.1.42.2.27.9.5.8authzidauthorizationidentityAuthorization Identity Request Control, Object Identifier: 2.16.840.1.113730.3.4.16effectiverightsgeteffectiverightsGet Effective Rights Request Control, Object Identifier: 1.3.6.1.4.1.42.2.27.9.5.2managedsaitManage DSAIT Request Control, Object Identifier: 2.16.840.1.113730.3.4.2noopno-opNo-Op Control, Object Identifier: 1.3.6.1.4.1.4203.1.10.2pwpolicypasswordpolicyPassword Policy Control, Object Identifier: 1.3.6.1.4.1.42.2.27.8.5.1realattrsonlyrealattributesonlyReal Attributes Only Request Control, Object Identifier: 2.16.840.1.113730.3.4.17subtreedeletetreedeleteSubtree Delete Request Control, Object Identifier: 1.2.840.113556.1.4.805virtualattrsonlyvirtualattributesonlyVirtual Attributes Only Request Control, Object Identifier: 2.16.840.1.113730.3.4.19Maximum length of time in seconds to allow for the searchDefault value: 0Use the LDAP matched values control with the provided filterShow what would be done but do not perform any operationSearch scope ('base', 'one', 'sub', or 'subordinate')Default value: subsubordinate is an LDAP extension that might
not work with all LDAP servers.Sort the results using the provided sort orderUse the simple paged results control with the given page sizeDefault value: 1000Use the proxied authorization control with the given authorization
IDMaximum number of entries to return from the searchDefault value: 0LDAP Connection OptionsDN to use to bind to the serverDefault value: cn=Directory ManagerUse the authorization identity controlDirectory server hostname or IP addressDefault value: localhost.localdomainBind password file Certificate key store pathNickname of certificate for SSL client authenticationSASL bind optionsDirectory server port numberDefault value: 389Certificate trust store pathUse StartTLS to secure communication with the serverCertificate trust store PINCertificate key store PIN fileCertificate trust store PIN fileUse the password policy request controlLDAP protocol version numberDefault value: 3Password to use to bind to the serverCertificate key store PINTrust all server SSL certificatesUse SSL for secure communication with the serverUtility Input/Output OptionsUse the specified character set for command-line inputNo properties file will be used to get default command line
argument valuesPath to the file containing default property values used for
command line argumentsDo not wrap long linesUse verbose modeGeneral OptionsDisplay version informationDisplay usage informationFilterThe filter argument is a string representation of an LDAP search filter
as in (cn=Babs Jensen), (&(objectClass=Person)(|(sn=Jensen)(cn=Babs J*))), or
(cn:caseExactMatch:=Fred Flintstone).AttributeThe optional attribute list specifies the attributes to return in the
entries found by the search. In addition to identifying attributes by name
such as cn sn mail and so forth, you can use the following
notations, too.*Return all user attributes such as cn,
sn, and mail.+Return all operational attributes such as etag
and pwdPolicySubentry.@objectclassReturn all attributes of the specified object class, where
objectclass is one of the object classes
on the entries returned by the search.Exit Codes0The command completed successfully.ldap-errorAn LDAP error occurred while processing the operation.LDAP result codes are described in RFC
4511. Also see the additional information for details.89An error occurred while parsing the command-line arguments.FilesYou can use ~/.opendj/tools.properties to set
the defaults for bind DN, host name, and port number as in the following
example.hostname=directory.example.com
port=1389
bindDN=uid=kvaughan,ou=People,dc=example,dc=com
ldapcompare.port=1389
ldapdelete.port=1389
ldapmodify.port=1389
ldappasswordmodify.port=1389
ldapsearch.port=1389ExamplesThe following example searches for entries with UID containing
jensen, returning only DNs and uid values.$ ldapsearch -p 1389 -b dc=example,dc=com "(uid=*jensen*)" uid
dn: uid=ajensen,ou=People,dc=example,dc=com
uid: ajensen
dn: uid=bjensen,ou=People,dc=example,dc=com
uid: bjensen
dn: uid=gjensen,ou=People,dc=example,dc=com
uid: gjensen
dn: uid=jjensen,ou=People,dc=example,dc=com
uid: jjensen
dn: uid=kjensen,ou=People,dc=example,dc=com
uid: kjensen
dn: uid=rjensen,ou=People,dc=example,dc=com
uid: rjensen
dn: uid=tjensen,ou=People,dc=example,dc=com
uid: tjensen
Result Code: 0 (Success)You can also use @objectclass notation in the attribute list to return
the attributes of a particular object class. The following example shows
how to return attributes of the inetOrgPerson object
class.$ ldapsearch -p 1389 -b dc=example,dc=com "(uid=bjensen)" @inetorgperson
dn: uid=bjensen,ou=People,dc=example,dc=com
givenName: Barbara
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: top
uid: bjensen
cn: Barbara Jensen
cn: Babs Jensen
telephoneNumber: +1 408 555 1862
sn: Jensen
roomNumber: 0209
mail: bjensen@example.com
l: Cupertino
ou: Product Development
ou: People
facsimileTelephoneNumber: +1 408 555 1992You can use + in the attribute list to return
all operational attributes, as in the following example.$ ldapsearch -p 1389 -b dc=example,dc=com "(uid=bjensen)" +
dn: uid=bjensen,ou=People,dc=example,dc=com
numSubordinates: 0
structuralObjectClass: inetOrgPerson
etag: 0000000073c29972
pwdPolicySubentry: cn=Default Password Policy,cn=Password Policies,cn=config
subschemaSubentry: cn=schema
hasSubordinates: false
entryDN: uid=bjensen,ou=people,dc=example,dc=com
entryUUID: fc252fd9-b982-3ed6-b42a-c76d2546312c