1 .TH LDAPSEARCH 1 "RELEASEDATE" "OpenLDAP LDVERSION"
3 .\" Copyright 1998-2008 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 .BI \-s \ base\fR\||\|\fIone\fR\||\|\fIsub\fR\||\|\fIchildren\fR]
56 .BI \-a \ never\fR\||\|\fIalways\fR\||\|\fIsearch\fR\||\|\fIfind\fR]
58 .BI \-P \ 2\fR\||\|\fI3\fR]
60 .BR \-e \ [!]ext[=extparam]]
62 .BR \-E \ [!]ext[=extparam]]
64 .BI \-l \ timelimit\fR]
66 .BI \-z \ sizelimit\fR]
68 .BR \-O \ security-properties ]
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.
108 Show what would be done, but don't actually perform the search. Useful for
109 debugging in conjunction with -v.
112 Continuous operation mode. Errors are reported, but ldapsearch will continue
113 with searches. The default is to exit after reporting an error. Only useful
114 in conjunction with -f.
117 Include the User Friendly Name form of the Distinguished Name (DN)
121 Run in verbose mode, with many diagnostics written to standard output.
124 A single -t writes retrieved non-printable values to a set of temporary
125 files. This is useful for dealing with values containing non-character
126 data such as jpegPhoto or audio. A second -t writes all retrieved values to
130 Write temporary files to directory specified by \fIpath\fP (default:
134 URL prefix for temporary files. Default is file://\fIpath\fP/ where
135 \fIpath\fP is /var/tmp/ or specified with -T.
138 Retrieve attributes only (no values). This is useful when you just want to
139 see if an attribute is present in an entry and are not interested in the
143 Search results are display in LDAP Data Interchange Format detailed in
145 A single -L restricts the output to LDIFv1.
146 A second -L disables comments.
147 A third -L disables printing of the LDIF version.
148 The default is to use an extended version of LDIF.
151 Enable manage DSA IT control.
153 makes control critical.
156 Sort the entries returned based on \fIattribute\fP. The default is not
157 to sort entries returned. If \fIattribute\fP is a zero-length string (""),
158 the entries are sorted by the components of their Distinguished Name. See
160 for more details. Note that
162 normally prints out entries as it receives them. The use of the
164 option defeats this behavior, causing all entries to be retrieved,
165 then sorted, then printed.
168 Set the LDAP debugging level to \fIdebuglevel\fP.
170 must be compiled with LDAP_DEBUG defined for this option to have any effect.
173 Read a series of lines from \fIfile\fP, performing one LDAP search for
174 each line. In this case, the \fIfilter\fP given on the command line
175 is treated as a pattern where the first and only occurrence of \fB%s\fP
176 is replaced with a line from \fIfile\fP. Any other occurrence of the
177 the \fB%\fP character in the pattern will be regarded as an error.
178 Where it is desired that the search filter include a \fB%\fP character,
179 the character should be encoded as \fB\\25\fP (see RFC 4515).
180 If \fIfile\fP is a single
181 \fI-\fP character, then the lines are read from standard input.
183 will exit when the first non-successful search result is returned,
187 Use simple authentication instead of SASL.
190 Use the Distinguished Name \fIbinddn\fP to bind to the LDAP directory.
191 For SASL Binds, the server is expected to ignore this value.
194 Prompt for simple authentication.
195 This is used instead of specifying the password on the command line.
198 Use \fIpasswd\fP as the password for simple authentication.
201 Use complete contents of \fIpasswdfile\fP as the password for
202 simple authentication.
205 Specify URI(s) referring to the ldap server(s);
206 a list of URI, separated by whitespace or commas is expected;
207 only the protocol/host/port fields are allowed.
208 As an exception, if no host/port is specified, but a DN is,
209 the DN is used to look up the corresponding host(s) using the
210 DNS SRV records, according to RFC 2782. The DN must be a non-empty
211 sequence of AVAs whose attribute type is "dc" (domain component),
212 and must be escaped according to RFC 2396.
215 Specify an alternate host on which the ldap server is running.
216 Deprecated in favor of -H.
219 Specify an alternate TCP port where the ldap server is listening.
220 Deprecated in favor of -H.
223 Use \fIsearchbase\fP as the starting point for the search instead of
226 .BI \-s \ base\fR\||\|\fIone\fR\||\|\fIsub\fR\||\|\fIchildren
227 Specify the scope of the search to be one of
233 to specify a base object, one-level, subtree, or children search.
238 scope requires LDAPv3 subordinate feature extension.
240 .BI \-a \ never\fR\||\|\fIalways\fR\||\|\fIsearch\fR\||\|\fIfind
241 Specify how aliases dereferencing is done. Should be one of
247 to specify that aliases are never dereferenced, always dereferenced,
248 dereferenced when searching, or dereferenced only when locating the
249 base object for the search. The default is to never dereference aliases.
251 .BI \-P \ 2\fR\||\|\fI3
252 Specify the LDAP protocol version to use.
254 .B \-e \fI[!]ext[=extparam]\fP
256 .B \-E \fI[!]ext[=extparam]\fP
258 Specify general extensions with -e and search extensions with -E.
259 \'!\' indicates criticality.
263 [!]assert=<filter> (an RFC 4515 Filter)
264 [!]authzid=<authzid> ("dn:<dn>" or "u:<user>")
268 [!]postread[=<attrs>] (a comma-separated attribute list)
269 [!]preread[=<attrs>] (a comma-separated attribute list)
270 abandon, cancel (SIGINT sends abandon/cancel; not really controls)
275 [!]domainScope (domain scope)
276 [!]mv=<filter> (matched values filter)
277 [!]pr=<size>[/prompt|noprompt] (paged results/prompt)
278 [!]sss=[-]<attr[:OID]>[/[-]<attr[:OID]>...] (server side sorting)
279 [!]subentries[=true|false] (subentries)
280 [!]sync=ro[/<cookie>] (LDAP Sync refreshOnly)
281 rp[/<cookie>][/<slimit>] (LDAP Sync refreshAndPersist)
285 wait at most \fItimelimit\fP seconds for a search to complete.
293 means the maximum integer allowable by the protocol.
294 A server may impose a maximal timelimit which only
295 the root user may override.
298 retrieve at most \fIsizelimit\fP entries for a search.
306 means the maximum integer allowable by the protocol.
307 A server may impose a maximal sizelimit which only
308 the root user may override.
310 .BI \-O \ security-properties
311 Specify SASL security properties.
314 Enable SASL Interactive mode. Always prompt. Default is to prompt
318 Enable SASL Quiet mode. Never prompt.
321 Specify the authentication ID for SASL bind. The form of the ID
322 depends on the actual SASL mechanism used.
325 Specify the realm of authentication ID for SASL bind. The form of the realm
326 depends on the actual SASL mechanism used.
329 Specify the requested authorization ID for SASL bind.
331 must be one of the following formats:
333 .I <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
345 , the command will require the operation to be successful.
347 If one or more entries are found, each entry is written to standard
348 output in LDAP Data Interchange Format or
354 # bjensen, example, net
355 dn: uid=bjensen,dc=example,dc=net
357 objectClass: dcObject
364 If the -t option is used, the URI of a temporary file
365 is used in place of the actual value. If the -A option
366 is given, only the "attributename" part is written.
368 The following command:
371 ldapsearch -LLL "(sn=smith)" cn sn telephoneNumber
374 will perform a subtree search (using the default search base and
375 other parameters defined in
377 for entries with a surname (sn) of smith. The common name (cn), surname
378 (sn) and telephoneNumber values will be retrieved and printed to
380 The output might look something like this if two entries are found:
383 dn: uid=jts,dc=example,dc=com
389 telephoneNumber: 1 555 123-4567
391 dn: uid=sss,dc=example,dc=com
397 telephoneNumber: 1 555 765-4321
403 ldapsearch -LLL -u -t "(uid=xyz)" jpegPhoto audio
406 will perform a subtree search using the default search base for entries
407 with user id of "xyz". The user friendly form of the entry's DN will be
408 output after the line that contains the DN itself, and the jpegPhoto
409 and audio values will be retrieved and written to temporary files. The
410 output might look like this if one entry with one value for each of the
411 requested attributes is found:
414 dn: uid=xyz,dc=example,dc=com
415 ufn: xyz, example, com
416 audio:< file:///tmp/ldapsearch-audio-a19924
417 jpegPhoto:< file:///tmp/ldapsearch-jpegPhoto-a19924
423 ldapsearch -LLL -s one -b "c=US" "(o=University*)" o description
426 will perform a one-level search at the c=US level for all entries
427 whose organization name (o) begins begins with \fBUniversity\fP.
428 The organization name and description attribute values will be retrieved
429 and printed to standard output, resulting in output similar to this:
432 dn: o=University of Alaska Fairbanks,c=US
433 o: University of Alaska Fairbanks
434 description: Preparing Alaska for a brave new yesterday
435 description: leaf node only
437 dn: o=University of Colorado at Boulder,c=US
438 o: University of Colorado at Boulder
439 description: No personnel information
440 description: Institution of education and research
442 dn: o=University of Colorado at Denver,c=US
443 o: University of Colorado at Denver
447 description: Institute for Higher Learning and Research
449 dn: o=University of Florida,c=US
450 o: University of Florida
452 description: Warper of young minds
457 Exit status is zero if no errors occur.
458 Errors result in a non-zero exit status and
459 a diagnostic message being written to standard error.
468 .BR ldap_search_ext (3),
471 The OpenLDAP Project <http://www.openldap.org/>