1 .TH LDAPSEARCH 1 "RELEASEDATE" "OpenLDAP LDVERSION"
3 .\" Copyright 1998-2007 The OpenLDAP Foundation All Rights Reserved.
4 .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
6 ldapsearch \- LDAP search tool
32 .BI \-S \ attribute\fR]
34 .BI \-d \ debuglevel\fR]
46 .BI \-y \ passwdfile\fR]
50 .BI \-h \ ldaphost\fR]
52 .BI \-p \ ldapport\fR]
54 .BI \-b \ searchbase\fR]
56 .BI \-s \ base\fR\||\|\fIone\fR\||\|\fIsub\fR\||\|\fIchildren\fR]
58 .BI \-a \ never\fR\||\|\fIalways\fR\||\|\fIsearch\fR\||\|\fIfind\fR]
60 .BI \-P \ 2\fR\||\|\fI3\fR]
62 .BR \-e \ [!]ext[=extparam]]
64 .BR \-E \ [!]ext[=extparam]]
66 .BI \-l \ timelimit\fR]
68 .BI \-z \ sizelimit\fR]
70 .BR \-O \ security-properties ]
90 is a shell-accessible interface to the
91 .BR ldap_search_ext (3)
95 opens a connection to an LDAP server, binds, and performs a search
96 using specified parameters. The \fIfilter\fP should conform to
97 the string representation for search filters as defined in RFC 4515.
98 If not provided, the default filter, (objectClass=*), is used.
102 finds one or more entries, the attributes specified by
103 \fIattrs\fP are returned. If * is listed, all user attributes are
104 returned. If + is listed, all operational attributes are returned.
105 If no \fIattrs\fP are listed, all user attributes are returned. If only
106 1.1 is listed, no attributes will be returned.
110 Show what would be done, but don't actually perform the search. Useful for
111 debugging in conjunction with -v.
114 Continuous operation mode. Errors are reported, but ldapsearch will continue
115 with searches. The default is to exit after reporting an error. Only useful
116 in conjunction with -f.
119 Include the User Friendly Name form of the Distinguished Name (DN)
123 Run in verbose mode, with many diagnostics written to standard output.
126 A single -t writes retrieved non-printable values to a set of temporary
127 files. This is useful for dealing with values containing non-character
128 data such as jpegPhoto or audio. A second -t writes all retrieved values to
132 Write temporary files to directory specified by \fIpath\fP (default:
136 URL prefix for temporary files. Default is file://\fIpath\fP/ where
137 \fIpath\fP is /var/tmp/ or specified with -T.
140 Retrieve attributes only (no values). This is useful when you just want to
141 see if an attribute is present in an entry and are not interested in the
145 Chase referrals (anonymously).
148 Search results are display in LDAP Data Interchange Format detailed in
150 A single -L restricts the output to LDIFv1.
151 A second -L disables comments.
152 A third -L disables printing of the LDIF version.
153 The default is to use an extended version of LDIF.
156 Enable manage DSA IT control.
158 makes control critical.
161 Sort the entries returned based on \fIattribute\fP. The default is not
162 to sort entries returned. If \fIattribute\fP is a zero-length string (""),
163 the entries are sorted by the components of their Distinguished Name. See
165 for more details. Note that
167 normally prints out entries as it receives them. The use of the
169 option defeats this behavior, causing all entries to be retrieved,
170 then sorted, then printed.
173 Set the LDAP debugging level to \fIdebuglevel\fP.
175 must be compiled with LDAP_DEBUG defined for this option to have any effect.
178 Read a series of lines from \fIfile\fP, performing one LDAP search for
179 each line. In this case, the \fIfilter\fP given on the command line
180 is treated as a pattern where the first and only occurrence of \fB%s\fP
181 is replaced with a line from \fIfile\fP. Any other occurence of the
182 the \fB%\fP character in the pattern will be regarded as an error.
183 Where it is desired that the search filter include a \fB%\fP character,
184 the character should be encoded as \fB\\25\fP (see RFC 4515).
185 If \fIfile\fP is a single
186 \fI-\fP character, then the lines are read from standard input.
188 will exit when the first non-successful search result is returned,
192 Use simple authentication instead of SASL.
195 Use the Distinguished Name \fIbinddn\fP to bind to the LDAP directory.
198 Prompt for simple authentication.
199 This is used instead of specifying the password on the command line.
202 Use \fIpasswd\fP as the password for simple authentication.
205 Use complete contents of \fIpasswdfile\fP as the password for
206 simple authentication.
209 Specify URI(s) referring to the ldap server(s);
210 a list of URI, separated by whitespace or commas is expected;
211 only the protocol/host/port fields are allowed.
212 As an exception, if no host/port is specified, but a DN is,
213 the DN is used to look up the corresponding host(s) using the
214 DNS SRV records, according to RFC 2782. The DN must be a non-empty
215 sequence of AVAs whose attribute type is "dc" (domain component),
216 and must be escaped according to RFC 2396.
219 Specify an alternate host on which the ldap server is running.
220 Deprecated in favor of -H.
223 Specify an alternate TCP port where the ldap server is listening.
224 Deprecated in favor of -H.
227 Use \fIsearchbase\fP as the starting point for the search instead of
230 .BI \-s \ base\fR\||\|\fIone\fR\||\|\fIsub\fR\||\|\fIchildren
231 Specify the scope of the search to be one of
237 to specify a base object, one-level, subtree, or children search.
242 scope requires LDAPv3 subordinate feature extension.
244 .BI \-a \ never\fR\||\|\fIalways\fR\||\|\fIsearch\fR\||\|\fIfind
245 Specify how aliases dereferencing is done. Should be one of
251 to specify that aliases are never dereferenced, always dereferenced,
252 dereferenced when searching, or dereferenced only when locating the
253 base object for the search. The default is to never dereference aliases.
255 .BI \-P \ 2\fR\||\|\fI3
256 Specify the LDAP protocol version to use.
258 .B \-e \fI[!]ext[=extparam]\fP
260 .B \-E \fI[!]ext[=extparam]\fP
262 Specify general extensions with -e and search extensions with -E.
263 \'!\' indicates criticality.
267 [!]assert=<filter> (an RFC 4515 Filter)
268 [!]authzid=<authzid> ("dn:<dn>" or "u:<user>")
272 [!]postread[=<attrs>] (a comma-separated attribute list)
273 [!]preread[=<attrs>] (a comma-separated attribute list)
274 abandon, cancel (SIGINT sends abandon/cancel; not really controls)
279 [!]domainScope (domain scope)
280 [!]mv=<filter> (matched values filter)
281 [!]pr=<size>[/prompt|noprompt] (paged results/prompt)
282 [!]subentries[=true|false] (subentries)
283 [!]sync=ro[/<cookie>] (LDAP Sync refreshOnly)
284 rp[/<cookie>][/<slimit>] (LDAP Sync refreshAndPersist)
288 wait at most \fItimelimit\fP seconds for a search to complete.
296 means the maximum integer allowable by the protocol.
297 A server may impose a maximal timelimit which only
298 the root user may override.
301 retrieve at most \fIsizelimit\fP entries for a search.
309 means the maximum integer allowable by the protocol.
310 A server may impose a maximal sizelimit which only
311 the root user may override.
313 .BI \-O \ security-properties
314 Specify SASL security properties.
317 Enable SASL Interactive mode. Always prompt. Default is to prompt
321 Enable SASL Quiet mode. Never prompt.
324 Specify the authentication ID for SASL bind. The form of the ID
325 depends on the actual SASL mechanism used.
328 Specify the realm of authentication ID for SASL bind. The form of the realm
329 depends on the actual SASL mechanism used.
332 Specify the requested authorization ID for SASL bind.
334 must be one of the following formats:
336 .I <distinguished name>
342 Specify the SASL mechanism to be used for authentication. If it's not
343 specified, the program will choose the best mechanism the server knows.
346 Issue StartTLS (Transport Layer Security) extended operation. If you use
348 , the command will require the operation to be successful.
350 If one or more entries are found, each entry is written to standard
351 output in LDAP Data Interchange Format or
357 # bjensen, example, net
358 dn: uid=bjensen,dc=example,dc=net
360 objectClass: dcObject
367 If the -t option is used, the URI of a temporary file
368 is used in place of the actual value. If the -A option
369 is given, only the "attributename" part is written.
371 The following command:
374 ldapsearch -LLL "(sn=smith)" cn sn telephoneNumber
377 will perform a subtree search (using the default search base and
378 other parameters defined in
380 for entries with a surname (sn) of smith. The common name (cn), surname
381 (sn) and telephoneNumber values will be retrieved and printed to
383 The output might look something like this if two entries are found:
386 dn: uid=jts,dc=example,dc=com
392 telephoneNumber: 1 555 123-4567
394 dn: uid=sss,dc=example,dc=com
400 telephoneNumber: 1 555 765-4321
406 ldapsearch -LLL -u -t "(uid=xyz)" jpegPhoto audio
409 will perform a subtree search using the default search base for entries
410 with user id of "xyz". The user friendly form of the entry's DN will be
411 output after the line that contains the DN itself, and the jpegPhoto
412 and audio values will be retrieved and written to temporary files. The
413 output might look like this if one entry with one value for each of the
414 requested attributes is found:
417 dn: uid=xyz,dc=example,dc=com
418 ufn: xyz, example, com
419 audio:< file:///tmp/ldapsearch-audio-a19924
420 jpegPhoto:< file:///tmp/ldapsearch-jpegPhoto-a19924
426 ldapsearch -LLL -s one -b "c=US" "(o=University*)" o description
429 will perform a one-level search at the c=US level for all entries
430 whose organization name (o) begins begins with \fBUniversity\fP.
431 The organization name and description attribute values will be retrieved
432 and printed to standard output, resulting in output similar to this:
435 dn: o=University of Alaska Fairbanks,c=US
436 o: University of Alaska Fairbanks
437 description: Preparing Alaska for a brave new yesterday
438 description: leaf node only
440 dn: o=University of Colorado at Boulder,c=US
441 o: University of Colorado at Boulder
442 description: No personnel information
443 description: Institution of education and research
445 dn: o=University of Colorado at Denver,c=US
446 o: University of Colorado at Denver
450 description: Institute for Higher Learning and Research
452 dn: o=University of Florida,c=US
453 o: University of Florida
455 description: Warper of young minds
460 Exit status is zero if no errors occur.
461 Errors result in a non-zero exit status and
462 a diagnostic message being written to standard error.
471 .BR ldap_search_ext (3),
474 The OpenLDAP Project <http://www.openldap.org/>