1 .TH LDAPSEARCH 1 "RELEASEDATE" "OpenLDAP LDVERSION"
3 .\" Copyright 1998-2009 The OpenLDAP Foundation All Rights Reserved.
4 .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
6 ldapsearch \- LDAP search tool
30 .BI \-S \ attribute\fR]
32 .BI \-d \ debuglevel\fR]
44 .BI \-y \ passwdfile\fR]
48 .BI \-h \ ldaphost\fR]
50 .BI \-p \ ldapport\fR]
52 .BI \-b \ searchbase\fR]
54 .BR \-s \ { base \||\| one \||\| sub \||\| children }]
56 .BR \-a \ { never \||\| always \||\| search \||\| find }]
58 .BR \-P \ { 2 \||\| 3 }]
60 .BR \-e \ [ ! ] \fIext\fP [ =\fIextparam\fP ]]
62 .BR \-E \ [ ! ] \fIext\fP [ =\fIextparam\fP ]]
64 .BI \-l \ timelimit\fR]
66 .BI \-z \ sizelimit\fR]
68 .BI \-O \ security-properties\fR]
88 is a shell-accessible interface to the
89 .BR ldap_search_ext (3)
93 opens a connection to an LDAP server, binds, and performs a search
94 using specified parameters. The \fIfilter\fP should conform to
95 the string representation for search filters as defined in RFC 4515.
96 If not provided, the default filter, (objectClass=*), is used.
100 finds one or more entries, the attributes specified by
101 \fIattrs\fP are returned. If * is listed, all user attributes are
102 returned. If + is listed, all operational attributes are returned.
103 If no \fIattrs\fP are listed, all user attributes are returned. If only
104 1.1 is listed, no attributes will be returned.
106 The search results are displayed using an extended version of LDIF.
107 Option \fI\-L\fP controls the format of the output.
111 Show what would be done, but don't actually perform the search. Useful for
112 debugging in conjunction with -v.
115 Continuous operation mode. Errors are reported, but ldapsearch will continue
116 with searches. The default is to exit after reporting an error. Only useful
117 in conjunction with -f.
120 Include the User Friendly Name form of the Distinguished Name (DN)
124 Run in verbose mode, with many diagnostics written to standard output.
127 A single \fB\-t\fP writes retrieved non-printable values to a set of temporary
128 files. This is useful for dealing with values containing non-character
129 data such as jpegPhoto or audio. A second \fB\-t\fP writes all retrieved values to
133 Write temporary files to directory specified by \fIpath\fP (default:
137 URL prefix for temporary files. Default is \fBfile://\fIpath\fP where
138 \fIpath\fP is \fB/var/tmp/\fP or specified with \fB\-T\fP.
141 Retrieve attributes only (no values). This is useful when you just want to
142 see if an attribute is present in an entry and are not interested in the
146 Search results are display in LDAP Data Interchange Format detailed in
148 A single \fB\-L\fP restricts the output to LDIFv1.
149 A second \fB\-L\fP disables comments.
150 A third \fB\-L\fP disables printing of the LDIF version.
151 The default is to use an extended version of LDIF.
154 Enable manage DSA IT control.
156 makes control critical.
159 Sort the entries returned based on \fIattribute\fP. The default is not
160 to sort entries returned. If \fIattribute\fP is a zero-length string (""),
161 the entries are sorted by the components of their Distinguished Name. See
163 for more details. Note that
165 normally prints out entries as it receives them. The use of the \fB\-S\fP
166 option defeats this behavior, causing all entries to be retrieved,
167 then sorted, then printed.
170 Set the LDAP debugging level to \fIdebuglevel\fP.
172 must be compiled with LDAP_DEBUG defined for this option to have any effect.
175 Read a series of lines from \fIfile\fP, performing one LDAP search for
176 each line. In this case, the \fIfilter\fP given on the command line
177 is treated as a pattern where the first and only occurrence of \fB%s\fP
178 is replaced with a line from \fIfile\fP. Any other occurrence of the
179 the \fB%\fP character in the pattern will be regarded as an error.
180 Where it is desired that the search filter include a \fB%\fP character,
181 the character should be encoded as \fB\\25\fP (see RFC 4515).
182 If \fIfile\fP is a single
183 \fB\-\fP character, then the lines are read from standard input.
185 will exit when the first non-successful search result is returned,
186 unless \fB\-c\fP is used.
189 Use simple authentication instead of SASL.
192 Use the Distinguished Name \fIbinddn\fP to bind to the LDAP directory.
193 For SASL binds, the server is expected to ignore this value.
196 Prompt for simple authentication.
197 This is used instead of specifying the password on the command line.
200 Use \fIpasswd\fP as the password for simple authentication.
203 Use complete contents of \fIpasswdfile\fP as the password for
204 simple authentication.
207 Specify URI(s) referring to the ldap server(s);
208 a list of URI, separated by whitespace or commas is expected;
209 only the protocol/host/port fields are allowed.
210 As an exception, if no host/port is specified, but a DN is,
211 the DN is used to look up the corresponding host(s) using the
212 DNS SRV records, according to RFC 2782. The DN must be a non-empty
213 sequence of AVAs whose attribute type is "dc" (domain component),
214 and must be escaped according to RFC 2396.
217 Specify an alternate host on which the ldap server is running.
218 Deprecated in favor of \fB\-H\fP.
221 Specify an alternate TCP port where the ldap server is listening.
222 Deprecated in favor of \fB\-H\fP.
225 Use \fIsearchbase\fP as the starting point for the search instead of
228 .BR \-s \ { base \||\| one \||\| sub \||\| children }
229 Specify the scope of the search to be one of
235 to specify a base object, one-level, subtree, or children search.
240 scope requires LDAPv3 subordinate feature extension.
242 .BR \-a \ { never \||\| always \||\| search \||\| find }
243 Specify how aliases dereferencing is done. Should be one of
249 to specify that aliases are never dereferenced, always dereferenced,
250 dereferenced when searching, or dereferenced only when locating the
251 base object for the search. The default is to never dereference aliases.
253 .BR \-P \ { 2 \||\| 3 }
254 Specify the LDAP protocol version to use.
256 .BR \-e \ [ ! ] \fIext\fP [ =\fIextparam\fP ]
258 .BR \-E \ [ ! ] \fIext\fP [ =\fIextparam\fP ]
260 Specify general extensions with \fB\-e\fP and search extensions with \fB\-E\fP.
261 \'\fB!\fP\' indicates criticality.
265 [!]assert=<filter> (an RFC 4515 Filter)
266 [!]authzid=<authzid> ("dn:<dn>" or "u:<user>")
270 [!]postread[=<attrs>] (a comma-separated attribute list)
271 [!]preread[=<attrs>] (a comma-separated attribute list)
272 abandon, cancel (SIGINT sends abandon/cancel; not really controls)
277 [!]domainScope (domain scope)
278 [!]mv=<filter> (matched values filter)
279 [!]pr=<size>[/prompt|noprompt] (paged results/prompt)
280 [!]sss=[\-]<attr[:OID]>[/[\-]<attr[:OID]>...] (server side sorting)
281 [!]subentries[=true|false] (subentries)
282 [!]sync=ro[/<cookie>] (LDAP Sync refreshOnly)
283 rp[/<cookie>][/<slimit>] (LDAP Sync refreshAndPersist)
287 wait at most \fItimelimit\fP seconds for a search to complete.
295 means the maximum integer allowable by the protocol.
296 A server may impose a maximal timelimit which only
297 the root user may override.
300 retrieve at most \fIsizelimit\fP entries for a search.
308 means the maximum integer allowable by the protocol.
309 A server may impose a maximal sizelimit which only
310 the root user may override.
312 .BI \-O \ security-properties
313 Specify SASL security properties.
316 Enable SASL Interactive mode. Always prompt. Default is to prompt
320 Enable SASL Quiet mode. Never prompt.
323 Specify the authentication ID for SASL bind. The form of the ID
324 depends on the actual SASL mechanism used.
327 Specify the realm of authentication ID for SASL bind. The form of the realm
328 depends on the actual SASL mechanism used.
331 Specify the requested authorization ID for SASL bind.
333 must be one of the following formats:
334 .BI dn: "<distinguished name>"
339 Specify the SASL mechanism to be used for authentication. If it's not
340 specified, the program will choose the best mechanism the server knows.
343 Issue StartTLS (Transport Layer Security) extended operation. If you use
344 \fB\-ZZ\fP, the command will require the operation to be successful.
346 If one or more entries are found, each entry is written to standard
347 output in LDAP Data Interchange Format or
353 # bjensen, example, net
354 dn: uid=bjensen,dc=example,dc=net
356 objectClass: dcObject
363 If the \fB\-t\fP option is used, the URI of a temporary file
364 is used in place of the actual value. If the \fB\-A\fP option
365 is given, only the "attributename" part is written.
367 The following command:
370 ldapsearch \-LLL "(sn=smith)" cn sn telephoneNumber
373 will perform a subtree search (using the default search base and
374 other parameters defined in
376 for entries with a surname (sn) of smith. The common name (cn), surname
377 (sn) and telephoneNumber values will be retrieved and printed to
379 The output might look something like this if two entries are found:
382 dn: uid=jts,dc=example,dc=com
388 telephoneNumber: 1 555 123\-4567
390 dn: uid=sss,dc=example,dc=com
396 telephoneNumber: 1 555 765\-4321
402 ldapsearch \-LLL \-u \-t "(uid=xyz)" jpegPhoto audio
405 will perform a subtree search using the default search base for entries
406 with user id of "xyz". The user friendly form of the entry's DN will be
407 output after the line that contains the DN itself, and the jpegPhoto
408 and audio values will be retrieved and written to temporary files. The
409 output might look like this if one entry with one value for each of the
410 requested attributes is found:
413 dn: uid=xyz,dc=example,dc=com
414 ufn: xyz, example, com
415 audio:< file:///tmp/ldapsearch\-audio\-a19924
416 jpegPhoto:< file:///tmp/ldapsearch\-jpegPhoto\-a19924
422 ldapsearch \-LLL \-s one \-b "c=US" "(o=University*)" o description
425 will perform a one-level search at the c=US level for all entries
426 whose organization name (o) begins begins with \fBUniversity\fP.
427 The organization name and description attribute values will be retrieved
428 and printed to standard output, resulting in output similar to this:
431 dn: o=University of Alaska Fairbanks,c=US
432 o: University of Alaska Fairbanks
433 description: Preparing Alaska for a brave new yesterday
434 description: leaf node only
436 dn: o=University of Colorado at Boulder,c=US
437 o: University of Colorado at Boulder
438 description: No personnel information
439 description: Institution of education and research
441 dn: o=University of Colorado at Denver,c=US
442 o: University of Colorado at Denver
446 description: Institute for Higher Learning and Research
448 dn: o=University of Florida,c=US
449 o: University of Florida
451 description: Warper of young minds
456 Exit status is zero if no errors occur.
457 Errors result in a non-zero exit status and
458 a diagnostic message being written to standard error.
467 .BR ldap_search_ext (3),
470 The OpenLDAP Project <http://www.openldap.org/>