1 .TH LDAPSEARCH 1 "RELEASEDATE" "OpenLDAP LDVERSION"
3 .\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
4 .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
6 ldapsearch \- LDAP search tool
24 .BI \-d \ debuglevel\fR]
34 .BI \-y \ passwdfile\fR]
38 .BI \-h \ ldaphost\fR]
40 .BI \-p \ ldapport\fR]
42 .BI \-P \ 2\fR\||\|\fI3\fR]
44 .BI \-b \ searchbase\fR]
46 .BI \-s \ base\fR\||\|\fIone\fR\||\|\fIsub\fR]
48 .BI \-a \ never\fR\||\|\fIalways\fR\||\|\fIsearch\fR\||\|\fIfind\fR]
50 .BI \-l \ timelimit\fR]
52 .BI \-z \ sizelimit\fR]
54 .BR \-O \ security-properties ]
76 is a shell-accessible interface to the
81 opens a connection to an LDAP server, binds, and performs a search
82 using specified parameters. The \fIfilter\fP should conform to
83 the string representation for search filters as defined in RFC 2254.
84 If not provided, the default filter, (objectClass=*), is used.
87 .B ldapsearch finds one or more entries, the attributes specified by
88 \fIattrs\fP are returned. If * is listed, all user attributes are
89 returned. If + is listed, all operational attributes are returned.
90 If no \fIattrs\fP are listed, all user attributes are returned. If only
91 1.1 is listed, no attributes will be returned.
95 Show what would be done, but don't actually perform the search. Useful for
96 debugging in conjunction with -v.
99 Include the User Friendly Name form of the Distinguished Name (DN)
103 Run in verbose mode, with many diagnostics written to standard output.
106 Write retrieved non-printable values to a set of temporary files. This
107 is useful for dealing with values containing non-character data such as
111 Retrieve attributes only (no values). This is useful when you just want to
112 see if an attribute is present in an entry and are not interested in the
116 Search results are display in LDAP Data Interchange Format detailed in
118 A single -L restricts the output to LDIFv1.
119 A second -L disables comments.
120 A third -L disables printing of the LDIF version.
121 The default is to use an extended version of LDIF.
124 Enable manage DSA IT control.
126 makes control critical.
129 Sort the entries returned based on \fIattribute\fP. The default is not
130 to sort entries returned. If \fIattribute\fP is a zero-length string (""),
131 the entries are sorted by the components of their Distingished Name. See
133 for more details. Note that
135 normally prints out entries as it receives them. The use of the
137 option defeats this behavior, causing all entries to be retrieved,
138 then sorted, then printed.
141 Set the LDAP debugging level to \fIdebuglevel\fP.
143 must be compiled with LDAP_DEBUG defined for this option to have any effect.
146 Read a series of lines from \fIfile\fP, performing one LDAP search for
147 each line. In this case, the \fIfilter\fP given on the command line
148 is treated as a pattern where the first occurrence of \fB%s\fP is
149 replaced with a line from \fIfile\fP. If \fIfile\fP is a single \fI-\fP
150 character, then the lines are read from standard input.
153 Use simple authentication instead of SASL.
156 Use the Distinguished Name \fIbinddn\fP to bind to the LDAP directory.
159 Prompt for simple authentication.
160 This is used instead of specifying the password on the command line.
163 Use \fIpasswd\fP as the password for simple authentication.
166 Use complete contents of \fIpasswdfile\fP as the password for
167 simple authentication.
170 Specify URI(s) referring to the ldap server(s); only the protocol/host/port
171 fields are allowed; a list of URI, separated by whitespace or commas
175 Specify an alternate host on which the ldap server is running.
176 Deprecated in favor of -H.
179 Specify an alternate TCP port where the ldap server is listening.
180 Deprecated in favor of -H.
183 Use \fIsearchbase\fP as the starting point for the search instead of
186 .BI \-s \ base\fR\||\|\fIone\fR\||\|\fIsub
187 Specify the scope of the search to be one of
192 to specify a base object, one-level, or subtree search. The default
196 .BI \-a \ never\fR\||\|\fIalways\fR\||\|\fIsearch\fR\||\|\fIfind
197 Specify how aliases dereferencing is done. Should be one of
203 to specify that aliases are never dereferenced, always dereferenced,
204 dereferenced when searching, or dereferenced only when locating the
205 base object for the search. The default is to never dereference aliases.
207 .BI \-P \ 2\fR\||\|\fI3
208 Specify the LDAP protocol version to use.
211 wait at most \fItimelimit\fP seconds for a search to complete.
219 means the maximum integer allowable by the protocol.
220 A server may impose a maximal timelimit which only
221 the root user may override.
224 retrieve at most \fIsizelimit\fP entries for a search.
232 means the maximum integer allowable by the protocol.
233 A server may impose a maximal sizelimit which only
234 the root user may override.
236 .BI \-O \ security-properties
237 Specify SASL security properties.
240 Enable SASL Interactive mode. Always prompt. Default is to prompt
244 Enable SASL Quiet mode. Never prompt.
247 Specify the authentication ID for SASL bind. The form of the ID
248 depends on the actual SASL mechanism used.
251 Specify the realm of authentication ID for SASL bind. The form of the realm
252 depends on the actual SASL mechanism used.
255 Specify the requested authorization ID for SASL bind.
257 must be one of the following formats:
259 .I <distinguished name>
265 Specify the SASL mechanism to be used for authentication. If it's not
266 specified, the program will choose the best mechanism the server knows.
269 Issue StartTLS (Transport Layer Security) extended operation. If you use
271 , the command will require the operation to be successful.
273 If one or more entries are found, each entry is written to standard
274 output in LDAP Data Interchange Format or
280 # bjensen, example, net
281 dn: uid=bjensen,dc=example,dc=net
283 objectClass: dcObject
290 If the -t option is used, the URI of a temporary file
291 is used in place of the actual value. If the -A option
292 is given, only the "attributename" part is written.
294 The following command:
297 ldapsearch -LLL "(sn=smith)" cn sn telephoneNumber
300 will perform a subtree search (using the default search base and
301 other parameters defined in
303 for entries with a surname (sn) of smith. The common name (cn), surname
304 (sn) and telephoneNumber values will be retrieved and printed to
306 The output might look something like this if two entries are found:
309 dn: uid=jts,dc=example,dc=com
315 telephoneNumber: 1 555 123-4567
317 dn: uid=sss,dc=example,dc=com
323 telephoneNumber: 1 555 765-4321
329 ldapsearch -LLL -u -t "(uid=xyz)" jpegPhoto audio
332 will perform a subtree search using the default search base for entries
333 with user id of "xyz". The user friendly form of the entry's DN will be
334 output after the line that contains the DN itself, and the jpegPhoto
335 and audio values will be retrieved and written to temporary files. The
336 output might look like this if one entry with one value for each of the
337 requested attributes is found:
340 dn: uid=xyz,dc=example,dc=com
341 ufn: xyz, example, com
342 audio:< file:///tmp/ldapsearch-audio-a19924
343 jpegPhoto:< file:///tmp/ldapsearch-jpegPhoto-a19924
349 ldapsearch -LLL -s one -b "c=US" "(o=University*)" o description
352 will perform a one-level search at the c=US level for all entries
353 whose organization name (o) begins begins with \fBUniversity\fP.
354 The organization name and description attribute values will be retrieved
355 and printed to standard output, resulting in output similar to this:
358 dn: o=University of Alaska Fairbanks,c=US
359 o: University of Alaska Fairbanks
360 description: Preparing Alaska for a brave new yesterday
361 description: leaf node only
363 dn: o=University of Colorado at Boulder,c=US
364 o: University of Colorado at Boulder
365 description: No personnel information
366 description: Institution of education and research
368 dn: o=University of Colorado at Denver,c=US
369 o: University of Colorado at Denver
373 description: Institute for Higher Learning and Research
375 dn: o=University of Florida,c=US
376 o: University of Florida
378 description: Warper of young minds
383 Exit status is zero if no errors occur.
384 Errors result in a non-zero exit status and
385 a diagnostic message being written to standard error.
396 The OpenLDAP Project <http://www.openldap.org/>
399 is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
401 is derived from University of Michigan LDAP 3.3 Release.