1 .TH LDAPSEARCH 1 "RELEASEDATE" "OpenLDAP LDVERSION"
3 .\" Copyright 1998-2013 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, only the version information is printed.
121 Set the LDAP debugging level to \fIdebuglevel\fP.
123 must be compiled with LDAP_DEBUG defined for this option to have any effect.
126 Show what would be done, but don't actually perform the search. Useful for
127 debugging in conjunction with \fB\-v\fP.
130 Run in verbose mode, with many diagnostics written to standard output.
133 Continuous operation mode. Errors are reported, but ldapsearch will continue
134 with searches. The default is to exit after reporting an error. Only useful
135 in conjunction with \fB\-f\fP.
138 Include the User Friendly Name form of the Distinguished Name (DN)
142 A single \fB\-t\fP writes retrieved non-printable values to a set of temporary
143 files. This is useful for dealing with values containing non-character
144 data such as jpegPhoto or audio. A second \fB\-t\fP writes all retrieved values to
148 Write temporary files to directory specified by \fIpath\fP (default:
152 URL prefix for temporary files. Default is \fBfile://\fIpath\fP where
153 \fIpath\fP is \fB/var/tmp/\fP or specified with \fB\-T\fP.
156 Retrieve attributes only (no values). This is useful when you just want to
157 see if an attribute is present in an entry and are not interested in the
161 Search results are display in LDAP Data Interchange Format detailed in
163 A single \fB\-L\fP restricts the output to LDIFv1.
164 A second \fB\-L\fP disables comments.
165 A third \fB\-L\fP disables printing of the LDIF version.
166 The default is to use an extended version of LDIF.
169 Sort the entries returned based on \fIattribute\fP. The default is not
170 to sort entries returned. If \fIattribute\fP is a zero-length string (""),
171 the entries are sorted by the components of their Distinguished Name. See
173 for more details. Note that
175 normally prints out entries as it receives them. The use of the \fB\-S\fP
176 option defeats this behavior, causing all entries to be retrieved,
177 then sorted, then printed.
180 Use \fIsearchbase\fP as the starting point for the search instead of
183 .BR \-s \ { base \||\| one \||\| sub \||\| children }
184 Specify the scope of the search to be one of
190 to specify a base object, one-level, subtree, or children search.
195 scope requires LDAPv3 subordinate feature extension.
197 .BR \-a \ { never \||\| always \||\| search \||\| find }
198 Specify how aliases dereferencing is done. Should be one of
204 to specify that aliases are never dereferenced, always dereferenced,
205 dereferenced when searching, or dereferenced only when locating the
206 base object for the search. The default is to never dereference aliases.
209 wait at most \fItimelimit\fP seconds for a search to complete.
217 means the maximum integer allowable by the protocol.
218 A server may impose a maximal timelimit which only
219 the root user may override.
222 retrieve at most \fIsizelimit\fP entries for a search.
230 means the maximum integer allowable by the protocol.
231 A server may impose a maximal sizelimit which only
232 the root user may override.
235 Read a series of lines from \fIfile\fP, performing one LDAP search for
236 each line. In this case, the \fIfilter\fP given on the command line
237 is treated as a pattern where the first and only occurrence of \fB%s\fP
238 is replaced with a line from \fIfile\fP. Any other occurrence of the
239 the \fB%\fP character in the pattern will be regarded as an error.
240 Where it is desired that the search filter include a \fB%\fP character,
241 the character should be encoded as \fB\\25\fP (see RFC 4515).
242 If \fIfile\fP is a single
243 \fB\-\fP character, then the lines are read from standard input.
245 will exit when the first non-successful search result is returned,
246 unless \fB\-c\fP is used.
249 Enable manage DSA IT control.
251 makes control critical.
254 Use simple authentication instead of SASL.
257 Use the Distinguished Name \fIbinddn\fP to bind to the LDAP directory.
258 For SASL binds, the server is expected to ignore this value.
261 Prompt for simple authentication.
262 This is used instead of specifying the password on the command line.
265 Use \fIpasswd\fP as the password for simple authentication.
268 Use complete contents of \fIpasswdfile\fP as the password for
269 simple authentication.
272 Specify URI(s) referring to the ldap server(s);
273 a list of URI, separated by whitespace or commas is expected;
274 only the protocol/host/port fields are allowed.
275 As an exception, if no host/port is specified, but a DN is,
276 the DN is used to look up the corresponding host(s) using the
277 DNS SRV records, according to RFC 2782. The DN must be a non-empty
278 sequence of AVAs whose attribute type is "dc" (domain component),
279 and must be escaped according to RFC 2396.
282 Specify an alternate host on which the ldap server is running.
283 Deprecated in favor of \fB\-H\fP.
286 Specify an alternate TCP port where the ldap server is listening.
287 Deprecated in favor of \fB\-H\fP.
289 .BR \-P \ { 2 \||\| 3 }
290 Specify the LDAP protocol version to use.
292 .BR \-e \ [ ! ] \fIext\fP [ =\fIextparam\fP ]
294 .BR \-E \ [ ! ] \fIext\fP [ =\fIextparam\fP ]
296 Specify general extensions with \fB\-e\fP and search extensions with \fB\-E\fP.
297 \'\fB!\fP\' indicates criticality.
301 [!]assert=<filter> (an RFC 4515 Filter)
302 !authzid=<authzid> ("dn:<dn>" or "u:<user>")
303 [!]bauthzid (RFC 3829 authzid control)
304 [!]chaining[=<resolve>[/<cont>]]
308 [!]postread[=<attrs>] (a comma-separated attribute list)
309 [!]preread[=<attrs>] (a comma-separated attribute list)
311 sessiontracking[=<username>]
312 abandon,cancel,ignore (SIGINT sends abandon/cancel,
313 or ignores response; if critical, doesn't wait for SIGINT.
320 [!]domainScope (domain scope)
321 [!]mv=<filter> (matched values filter)
322 [!]pr=<size>[/prompt|noprompt] (paged results/prompt)
323 [!]sss=[\-]<attr[:OID]>[/[\-]<attr[:OID]>...] (server side sorting)
324 [!]subentries[=true|false] (subentries)
325 [!]sync=ro[/<cookie>] (LDAP Sync refreshOnly)
326 rp[/<cookie>][/<slimit>] (LDAP Sync refreshAndPersist)
327 [!]vlv=<before>/<after>(/<offset>/<count>|:<value>) (virtual list view)
328 [!]deref=derefAttr:attr[,attr[...]][;derefAttr:attr[,attr[...]]]
332 .BI \-o \ opt \fR[= optparam \fR]
334 Specify general options.
338 nettimeout=<timeout> (in seconds, or "none" or "max")
339 ldif-wrap=<width> (in columns, or "no" for no wrapping)
342 .BI \-O \ security-properties
343 Specify SASL security properties.
346 Enable SASL Interactive mode. Always prompt. Default is to prompt
350 Enable SASL Quiet mode. Never prompt.
353 Do not use reverse DNS to canonicalize SASL host name.
356 Specify the authentication ID for SASL bind. The form of the ID
357 depends on the actual SASL mechanism used.
360 Specify the realm of authentication ID for SASL bind. The form of the realm
361 depends on the actual SASL mechanism used.
364 Specify the requested authorization ID for SASL bind.
366 must be one of the following formats:
367 .BI dn: "<distinguished name>"
372 Specify the SASL mechanism to be used for authentication. If it's not
373 specified, the program will choose the best mechanism the server knows.
376 Issue StartTLS (Transport Layer Security) extended operation. If you use
377 \fB\-ZZ\fP, the command will require the operation to be successful.
379 If one or more entries are found, each entry is written to standard
380 output in LDAP Data Interchange Format or
386 # bjensen, example, net
387 dn: uid=bjensen,dc=example,dc=net
389 objectClass: dcObject
396 If the \fB\-t\fP option is used, the URI of a temporary file
397 is used in place of the actual value. If the \fB\-A\fP option
398 is given, only the "attributename" part is written.
400 The following command:
403 ldapsearch \-LLL "(sn=smith)" cn sn telephoneNumber
406 will perform a subtree search (using the default search base and
407 other parameters defined in
409 for entries with a surname (sn) of smith. The common name (cn), surname
410 (sn) and telephoneNumber values will be retrieved and printed to
412 The output might look something like this if two entries are found:
415 dn: uid=jts,dc=example,dc=com
421 telephoneNumber: 1 555 123\-4567
423 dn: uid=sss,dc=example,dc=com
429 telephoneNumber: 1 555 765\-4321
435 ldapsearch \-LLL \-u \-t "(uid=xyz)" jpegPhoto audio
438 will perform a subtree search using the default search base for entries
439 with user id of "xyz". The user friendly form of the entry's DN will be
440 output after the line that contains the DN itself, and the jpegPhoto
441 and audio values will be retrieved and written to temporary files. The
442 output might look like this if one entry with one value for each of the
443 requested attributes is found:
446 dn: uid=xyz,dc=example,dc=com
447 ufn: xyz, example, com
448 audio:< file:///tmp/ldapsearch\-audio\-a19924
449 jpegPhoto:< file:///tmp/ldapsearch\-jpegPhoto\-a19924
455 ldapsearch \-LLL \-s one \-b "c=US" "(o=University*)" o description
458 will perform a one-level search at the c=US level for all entries
459 whose organization name (o) begins begins with \fBUniversity\fP.
460 The organization name and description attribute values will be retrieved
461 and printed to standard output, resulting in output similar to this:
464 dn: o=University of Alaska Fairbanks,c=US
465 o: University of Alaska Fairbanks
466 description: Preparing Alaska for a brave new yesterday
467 description: leaf node only
469 dn: o=University of Colorado at Boulder,c=US
470 o: University of Colorado at Boulder
471 description: No personnel information
472 description: Institution of education and research
474 dn: o=University of Colorado at Denver,c=US
475 o: University of Colorado at Denver
479 description: Institute for Higher Learning and Research
481 dn: o=University of Florida,c=US
482 o: University of Florida
484 description: Warper of young minds
489 Exit status is zero if no errors occur.
490 Errors result in a non-zero exit status and
491 a diagnostic message being written to standard error.
500 .BR ldap_search_ext (3),
503 The OpenLDAP Project <http://www.openldap.org/>