1 .TH LDAPSEARCH 1 "RELEASEDATE" "OpenLDAP LDVERSION"
3 .\" Copyright 1998-2004 The OpenLDAP Foundation All Rights Reserved.
4 .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
6 ldapsearch \- LDAP search tool
28 .BI \-d \ debuglevel\fR]
38 .BI \-y \ passwdfile\fR]
42 .BI \-h \ ldaphost\fR]
44 .BI \-p \ ldapport\fR]
46 .BI \-P \ 2\fR\||\|\fI3\fR]
48 .BI \-b \ searchbase\fR]
50 .BI \-s \ base\fR\||\|\fIone\fR\||\|\fIsub\fR]
52 .BI \-a \ never\fR\||\|\fIalways\fR\||\|\fIsearch\fR\||\|\fIfind\fR]
54 .BI \-l \ timelimit\fR]
56 .BI \-z \ sizelimit\fR]
58 .BR \-O \ security-properties ]
80 is a shell-accessible interface to the
85 opens a connection to an LDAP server, binds, and performs a search
86 using specified parameters. The \fIfilter\fP should conform to
87 the string representation for search filters as defined in RFC 2254.
88 If not provided, the default filter, (objectClass=*), is used.
91 .B ldapsearch finds one or more entries, the attributes specified by
92 \fIattrs\fP are returned. If * is listed, all user attributes are
93 returned. If + is listed, all operational attributes are returned.
94 If no \fIattrs\fP are listed, all user attributes are returned. If only
95 1.1 is listed, no attributes will be returned.
99 Show what would be done, but don't actually perform the search. Useful for
100 debugging in conjunction with -v.
103 Include the User Friendly Name form of the Distinguished Name (DN)
107 Run in verbose mode, with many diagnostics written to standard output.
110 Use Kerberos IV authentication instead of simple authentication. It is
111 assumed that you already have a valid ticket granting ticket.
113 must be compiled with Kerberos support for this option to have any effect.
116 Same as \-k, but only does step 1 of the Kerberos IV bind. This is useful
117 when connecting to a slapd and there is no x500dsa.hostname principal
118 registered with your Kerberos Domain Controller(s).
121 Write retrieved non-printable values to a set of temporary files. This
122 is useful for dealing with values containing non-character data such as
126 Retrieve attributes only (no values). This is useful when you just want to
127 see if an attribute is present in an entry and are not interested in the
131 Search results are display in LDAP Data Interchange Format detailed in
133 A single -L restricts the output to LDIFv1.
134 A second -L disables comments.
135 A third -L disables printing of the LDIF version.
136 The default is to use an extended version of LDIF.
139 Enable manage DSA IT control.
141 makes control critical.
144 Sort the entries returned based on \fIattribute\fP. The default is not
145 to sort entries returned. If \fIattribute\fP is a zero-length string (""),
146 the entries are sorted by the components of their Distingished Name. See
148 for more details. Note that
150 normally prints out entries as it receives them. The use of the
152 option defeats this behavior, causing all entries to be retrieved,
153 then sorted, then printed.
156 Set the LDAP debugging level to \fIdebuglevel\fP.
158 must be compiled with LDAP_DEBUG defined for this option to have any effect.
161 Read a series of lines from \fIfile\fP, performing one LDAP search for
162 each line. In this case, the \fIfilter\fP given on the command line
163 is treated as a pattern where the first occurrence of \fB%s\fP is
164 replaced with a line from \fIfile\fP. If \fIfile\fP is a single \fI-\fP
165 character, then the lines are read from standard input.
168 Use simple authentication instead of SASL.
171 Use the Distinguished Name \fIbinddn\fP to bind to the LDAP directory.
174 Prompt for simple authentication.
175 This is used instead of specifying the password on the command line.
178 Use \fIpasswd\fP as the password for simple authentication.
181 Use complete contents of \fIpasswdfile\fP as the password for
182 simple authentication.
185 Specify URI(s) referring to the ldap server(s).
188 Specify an alternate host on which the ldap server is running.
189 Deprecated in favor of -H.
192 Specify an alternate TCP port where the ldap server is listening.
193 Deprecated in favor of -H.
196 Use \fIsearchbase\fP as the starting point for the search instead of
199 .BI \-s \ base\fR\||\|\fIone\fR\||\|\fIsub
200 Specify the scope of the search to be one of
205 to specify a base object, one-level, or subtree search. The default
209 .BI \-a \ never\fR\||\|\fIalways\fR\||\|\fIsearch\fR\||\|\fIfind
210 Specify how aliases dereferencing is done. Should be one of
216 to specify that aliases are never dereferenced, always dereferenced,
217 dereferenced when searching, or dereferenced only when locating the
218 base object for the search. The default is to never dereference aliases.
220 .BI \-P \ 2\fR\||\|\fI3
221 Specify the LDAP protocol version to use.
224 wait at most \fItimelimit\fP seconds for a search to complete.
232 means the maximum integer allowable by the protocol.
233 A server may impose a maximal timelimit which only
234 the root user may override.
237 retrieve at most \fIsizelimit\fP entries for a search.
245 means the maximum integer allowable by the protocol.
246 A server may impose a maximal sizelimit which only
247 the root user may override.
249 .BI \-O \ security-properties
250 Specify SASL security properties.
253 Enable SASL Interactive mode. Always prompt. Default is to prompt
257 Enable SASL Quiet mode. Never prompt.
260 Specify the authentication ID for SASL bind. The form of the ID
261 depends on the actual SASL mechanism used.
264 Specify the realm of authentication ID for SASL bind. The form of the realm
265 depends on the actual SASL mechanism used.
268 Specify the requested authorization ID for SASL bind.
270 must be one of the following formats:
272 .I <distinguished name>
278 Specify the SASL mechanism to be used for authentication. If it's not
279 specified, the program will choose the best mechanism the server knows.
282 Issue StartTLS (Transport Layer Security) extended operation. If you use
284 , the command will require the operation to be successful.
286 If one or more entries are found, each entry is written to standard
287 output in LDAP Data Interchange Format or
293 # bjensen, example, net
294 dn: uid=bjensen,dc=example,dc=net
296 objectClass: dcObject
303 If the -t option is used, the URI of a temporary file
304 is used in place of the actual value. If the -A option
305 is given, only the "attributename" part is written.
307 The following command:
310 ldapsearch -LLL "(sn=smith)" cn sn telephoneNumber
313 will perform a subtree search (using the default search base and
314 other parameters defined in
316 for entries with a surname (sn) of smith. The common name (cn), surname
317 (sn) and telephoneNumber values will be retrieved and printed to
319 The output might look something like this if two entries are found:
322 dn: uid=jts,dc=example,dc=com
328 telephoneNumber: 1 555 123-4567
330 dn: uid=sss,dc=example,dc=com
336 telephoneNumber: 1 555 765-4321
342 ldapsearch -LLL -u -t "(uid=xyz)" jpegPhoto audio
345 will perform a subtree search using the default search base for entries
346 with user id of "xyz". The user friendly form of the entry's DN will be
347 output after the line that contains the DN itself, and the jpegPhoto
348 and audio values will be retrieved and written to temporary files. The
349 output might look like this if one entry with one value for each of the
350 requested attributes is found:
353 dn: uid=xyz,dc=example,dc=com
354 ufn: xyz, example, com
355 audio:< file:///tmp/ldapsearch-audio-a19924
356 jpegPhoto:< file:///tmp/ldapsearch-jpegPhoto-a19924
362 ldapsearch -LLL -s one -b "c=US" "(o=University*)" o description
365 will perform a one-level search at the c=US level for all entries
366 whose organization name (o) begins begins with \fBUniversity\fP.
367 The organization name and description attribute values will be retrieved
368 and printed to standard output, resulting in output similar to this:
371 dn: o=University of Alaska Fairbanks,c=US
372 o: University of Alaska Fairbanks
373 description: Preparing Alaska for a brave new yesterday
374 description: leaf node only
376 dn: o=University of Colorado at Boulder,c=US
377 o: University of Colorado at Boulder
378 description: No personnel information
379 description: Institution of education and research
381 dn: o=University of Colorado at Denver,c=US
382 o: University of Colorado at Denver
386 description: Institute for Higher Learning and Research
388 dn: o=University of Florida,c=US
389 o: University of Florida
391 description: Warper of young minds
396 Exit status is zero if no errors occur.
397 Errors result in a non-zero exit status and
398 a diagnostic message being written to standard error.
409 The OpenLDAP Project <http://www.openldap.org/>
412 is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
414 is derived from University of Michigan LDAP 3.3 Release.