1 .TH LDAPSEARCH 1 "RELEASEDATE" "OpenLDAP LDVERSION"
3 .\" Copyright 1998-2018 The OpenLDAP Foundation All Rights Reserved.
4 .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
6 ldapsearch \- LDAP search tool
12 .BI \-d \ debuglevel\fR]
32 .BI \-S \ attribute\fR]
34 .BI \-b \ searchbase\fR]
36 .BR \-s \ { base \||\| one \||\| sub \||\| children }]
38 .BR \-a \ { never \||\| always \||\| search \||\| find }]
40 .BI \-l \ timelimit\fR]
42 .BI \-z \ sizelimit\fR]
56 .BI \-y \ passwdfile\fR]
60 .BI \-h \ ldaphost\fR]
62 .BI \-p \ ldapport\fR]
64 .BR \-P \ { 2 \||\| 3 }]
66 .BR \-e \ [ ! ] \fIext\fP [ =\fIextparam\fP ]]
68 .BR \-E \ [ ! ] \fIext\fP [ =\fIextparam\fP ]]
70 .BI \-o \ opt \fR[= optparam \fR]]
72 .BI \-O \ security-properties\fR]
94 is a shell-accessible interface to the
95 .BR ldap_search_ext (3)
99 opens a connection to an LDAP server, binds, and performs a search
100 using specified parameters. The \fIfilter\fP should conform to
101 the string representation for search filters as defined in RFC 4515.
102 If not provided, the default filter, \fB(objectClass=*)\fP, is used.
106 finds one or more entries, the attributes specified by
107 \fIattrs\fP are returned. If \fB*\fP is listed, all user attributes are
108 returned. If \fB+\fP is listed, all operational attributes are returned.
109 If no \fIattrs\fP are listed, all user attributes are returned. If only
110 1.1 is listed, no attributes will be returned.
112 The search results are displayed using an extended version of LDIF.
113 Option \fI\-L\fP controls the format of the output.
118 If \fB\-VV\fP is given, exit after providing version info. Otherwise proceed
119 with the specified search
122 Set the LDAP debugging level to \fIdebuglevel\fP.
124 must be compiled with LDAP_DEBUG defined for this option to have any effect.
127 Show what would be done, but don't actually perform the search. Useful for
128 debugging in conjunction with \fB\-v\fP.
131 Run in verbose mode, with many diagnostics written to standard output.
134 Continuous operation mode. Errors are reported, but ldapsearch will continue
135 with searches. The default is to exit after reporting an error. Only useful
136 in conjunction with \fB\-f\fP.
139 Include the User Friendly Name form of the Distinguished Name (DN)
143 A single \fB\-t\fP writes retrieved non-printable values to a set of temporary
144 files. This is useful for dealing with values containing non-character
145 data such as jpegPhoto or audio. A second \fB\-t\fP writes all retrieved values to
149 Write temporary files to directory specified by \fIpath\fP (default:
153 URL prefix for temporary files. Default is \fBfile://\fIpath\fP where
154 \fIpath\fP is \fB/var/tmp/\fP or specified with \fB\-T\fP.
157 Retrieve attributes only (no values). This is useful when you just want to
158 see if an attribute is present in an entry and are not interested in the
162 Search results are display in LDAP Data Interchange Format detailed in
164 A single \fB\-L\fP restricts the output to LDIFv1.
165 A second \fB\-L\fP disables comments.
166 A third \fB\-L\fP disables printing of the LDIF version.
167 The default is to use an extended version of LDIF.
170 Sort the entries returned based on \fIattribute\fP. The default is not
171 to sort entries returned. If \fIattribute\fP is a zero-length string (""),
172 the entries are sorted by the components of their Distinguished Name. See
174 for more details. Note that
176 normally prints out entries as it receives them. The use of the \fB\-S\fP
177 option defeats this behavior, causing all entries to be retrieved,
178 then sorted, then printed.
181 Use \fIsearchbase\fP as the starting point for the search instead of
184 .BR \-s \ { base \||\| one \||\| sub \||\| children }
185 Specify the scope of the search to be one of
191 to specify a base object, one-level, subtree, or children search.
196 scope requires LDAPv3 subordinate feature extension.
198 .BR \-a \ { never \||\| always \||\| search \||\| find }
199 Specify how aliases dereferencing is done. Should be one of
205 to specify that aliases are never dereferenced, always dereferenced,
206 dereferenced when searching, or dereferenced only when locating the
207 base object for the search. The default is to never dereference aliases.
210 wait at most \fItimelimit\fP seconds for a search to complete.
218 means the maximum integer allowable by the protocol.
219 A server may impose a maximal timelimit which only
220 the root user may override.
223 retrieve at most \fIsizelimit\fP entries for a search.
231 means the maximum integer allowable by the protocol.
232 A server may impose a maximal sizelimit which only
233 the root user may override.
236 Read a series of lines from \fIfile\fP, performing one LDAP search for
237 each line. In this case, the \fIfilter\fP given on the command line
238 is treated as a pattern where the first and only occurrence of \fB%s\fP
239 is replaced with a line from \fIfile\fP. Any other occurrence of the
240 the \fB%\fP character in the pattern will be regarded as an error.
241 Where it is desired that the search filter include a \fB%\fP character,
242 the character should be encoded as \fB\\25\fP (see RFC 4515).
243 If \fIfile\fP is a single
244 \fB\-\fP character, then the lines are read from standard input.
246 will exit when the first non-successful search result is returned,
247 unless \fB\-c\fP is used.
250 Enable manage DSA IT control.
252 makes control critical.
255 Use simple authentication instead of SASL.
258 Use the Distinguished Name \fIbinddn\fP to bind to the LDAP directory.
259 For SASL binds, the server is expected to ignore this value.
262 Prompt for simple authentication.
263 This is used instead of specifying the password on the command line.
266 Use \fIpasswd\fP as the password for simple authentication.
269 Use complete contents of \fIpasswdfile\fP as the password for
270 simple authentication.
273 Specify URI(s) referring to the ldap server(s);
274 a list of URI, separated by whitespace or commas is expected;
275 only the protocol/host/port fields are allowed.
276 As an exception, if no host/port is specified, but a DN is,
277 the DN is used to look up the corresponding host(s) using the
278 DNS SRV records, according to RFC 2782. The DN must be a non-empty
279 sequence of AVAs whose attribute type is "dc" (domain component),
280 and must be escaped according to RFC 2396.
283 Specify an alternate host on which the ldap server is running.
284 Deprecated in favor of \fB\-H\fP.
287 Specify an alternate TCP port where the ldap server is listening.
288 Deprecated in favor of \fB\-H\fP.
290 .BR \-P \ { 2 \||\| 3 }
291 Specify the LDAP protocol version to use.
293 .BR \-e \ [ ! ] \fIext\fP [ =\fIextparam\fP ]
295 .BR \-E \ [ ! ] \fIext\fP [ =\fIextparam\fP ]
297 Specify general extensions with \fB\-e\fP and search extensions with \fB\-E\fP.
298 \'\fB!\fP\' indicates criticality.
302 [!]assert=<filter> (an RFC 4515 Filter)
303 !authzid=<authzid> ("dn:<dn>" or "u:<user>")
304 [!]bauthzid (RFC 3829 authzid control)
305 [!]chaining[=<resolve>[/<cont>]]
309 [!]postread[=<attrs>] (a comma-separated attribute list)
310 [!]preread[=<attrs>] (a comma-separated attribute list)
312 sessiontracking[=<username>]
313 abandon,cancel,ignore (SIGINT sends abandon/cancel,
314 or ignores response; if critical, doesn't wait for SIGINT.
321 [!]domainScope (domain scope)
322 [!]mv=<filter> (matched values filter)
323 [!]pr=<size>[/prompt|noprompt] (paged results/prompt)
324 [!]sss=[\-]<attr[:OID]>[/[\-]<attr[:OID]>...] (server side sorting)
325 [!]subentries[=true|false] (subentries)
326 [!]sync=ro[/<cookie>] (LDAP Sync refreshOnly)
327 rp[/<cookie>][/<slimit>] (LDAP Sync refreshAndPersist)
328 [!]vlv=<before>/<after>(/<offset>/<count>|:<value>) (virtual list view)
329 [!]deref=derefAttr:attr[,attr[...]][;derefAttr:attr[,attr[...]]]
333 .BI \-o \ opt \fR[= optparam \fR]
337 option or one of the following:
339 nettimeout=<timeout> (in seconds, or "none" or "max")
340 ldif_wrap=<width> (in columns, or "no" for no wrapping)
344 .BI \-O \ security-properties
345 Specify SASL security properties.
348 Enable SASL Interactive mode. Always prompt. Default is to prompt
352 Enable SASL Quiet mode. Never prompt.
355 Do not use reverse DNS to canonicalize SASL host name.
358 Specify the authentication ID for SASL bind. The form of the ID
359 depends on the actual SASL mechanism used.
362 Specify the realm of authentication ID for SASL bind. The form of the realm
363 depends on the actual SASL mechanism used.
366 Specify the requested authorization ID for SASL bind.
368 must be one of the following formats:
369 .BI dn: "<distinguished name>"
374 Specify the SASL mechanism to be used for authentication. If it's not
375 specified, the program will choose the best mechanism the server knows.
378 Issue StartTLS (Transport Layer Security) extended operation. If you use
379 \fB\-ZZ\fP, the command will require the operation to be successful.
381 If one or more entries are found, each entry is written to standard
382 output in LDAP Data Interchange Format or
388 # bjensen, example, net
389 dn: uid=bjensen,dc=example,dc=net
391 objectClass: dcObject
398 If the \fB\-t\fP option is used, the URI of a temporary file
399 is used in place of the actual value. If the \fB\-A\fP option
400 is given, only the "attributename" part is written.
402 The following command:
405 ldapsearch \-LLL "(sn=smith)" cn sn telephoneNumber
408 will perform a subtree search (using the default search base and
409 other parameters defined in
411 for entries with a surname (sn) of smith. The common name (cn), surname
412 (sn) and telephoneNumber values will be retrieved and printed to
414 The output might look something like this if two entries are found:
417 dn: uid=jts,dc=example,dc=com
423 telephoneNumber: 1 555 123\-4567
425 dn: uid=sss,dc=example,dc=com
431 telephoneNumber: 1 555 765\-4321
437 ldapsearch \-LLL \-u \-t "(uid=xyz)" jpegPhoto audio
440 will perform a subtree search using the default search base for entries
441 with user id of "xyz". The user friendly form of the entry's DN will be
442 output after the line that contains the DN itself, and the jpegPhoto
443 and audio values will be retrieved and written to temporary files. The
444 output might look like this if one entry with one value for each of the
445 requested attributes is found:
448 dn: uid=xyz,dc=example,dc=com
449 ufn: xyz, example, com
450 audio:< file:///tmp/ldapsearch\-audio\-a19924
451 jpegPhoto:< file:///tmp/ldapsearch\-jpegPhoto\-a19924
457 ldapsearch \-LLL \-s one \-b "c=US" "(o=University*)" o description
460 will perform a one-level search at the c=US level for all entries
461 whose organization name (o) begins with \fBUniversity\fP.
462 The organization name and description attribute values will be retrieved
463 and printed to standard output, resulting in output similar to this:
466 dn: o=University of Alaska Fairbanks,c=US
467 o: University of Alaska Fairbanks
468 description: Preparing Alaska for a brave new yesterday
469 description: leaf node only
471 dn: o=University of Colorado at Boulder,c=US
472 o: University of Colorado at Boulder
473 description: No personnel information
474 description: Institution of education and research
476 dn: o=University of Colorado at Denver,c=US
477 o: University of Colorado at Denver
481 description: Institute for Higher Learning and Research
483 dn: o=University of Florida,c=US
484 o: University of Florida
486 description: Warper of young minds
491 Exit status is zero if no errors occur.
492 Errors result in a non-zero exit status and
493 a diagnostic message being written to standard error.
502 .BR ldap_search_ext (3),
505 The OpenLDAP Project <http://www.openldap.org/>