]> git.sur5r.net Git - openldap/blob - doc/man/man1/ldapsearch.1
fix client tool man page
[openldap] / doc / man / man1 / ldapsearch.1
1 .TH LDAPSEARCH 1 "RELEASEDATE" "OpenLDAP LDVERSION"
2 .\" $OpenLDAP$
3 .\" Copyright 1998-2010 The OpenLDAP Foundation All Rights Reserved.
4 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
5 .SH NAME
6 ldapsearch \- LDAP search tool
7 .SH SYNOPSIS
8 .B ldapsearch
9 [\c
10 .BR \-n ]
11 [\c
12 .BR \-c ]
13 [\c
14 .BR \-u ]
15 [\c
16 .BR \-v ]
17 [\c
18 .BR \-t [ t ]]
19 [\c
20 .BI \-T \ path\fR]
21 [\c
22 .BI \-F \ prefix\fR]
23 [\c
24 .BR \-A ]
25 [\c
26 .BR \-L [ L [ L ]]]
27 [\c
28 .BR \-M [ M ]]
29 [\c
30 .BI \-S \ attribute\fR]
31 [\c
32 .BI \-d \ debuglevel\fR]
33 [\c
34 .BI \-f \ file\fR]
35 [\c
36 .BR \-x ]
37 [\c
38 .BI \-D \ binddn\fR]
39 [\c
40 .BR \-W ]
41 [\c
42 .BI \-w \ passwd\fR]
43 [\c
44 .BI \-y \ passwdfile\fR]
45 [\c
46 .BI \-H \ ldapuri\fR]
47 [\c
48 .BI \-h \ ldaphost\fR]
49 [\c
50 .BI \-p \ ldapport\fR]
51 [\c
52 .BI \-b \ searchbase\fR]
53 [\c
54 .BR \-s \ { base \||\| one \||\| sub \||\| children }]
55 [\c
56 .BR \-a \ { never \||\| always \||\| search \||\| find }]
57 [\c
58 .BR \-P \ { 2 \||\| 3 }]
59 [\c
60 .BR \-e \ [ ! ] \fIext\fP [ =\fIextparam\fP ]]
61 [\c
62 .BR \-E \ [ ! ] \fIext\fP [ =\fIextparam\fP ]]
63 [\c
64 .BI \-l \ timelimit\fR]
65 [\c
66 .BI \-z \ sizelimit\fR]
67 [\c
68 .BI \-O \ security-properties\fR]
69 [\c
70 .BR \-I ]
71 [\c
72 .BR \-Q ]
73 [\c
74 .BI \-U \ authcid\fR]
75 [\c
76 .BI \-R \ realm\fR]
77 [\c
78 .BI \-X \ authzid\fR]
79 [\c
80 .BI \-Y \ mech\fR]
81 [\c
82 .BR \-Z [ Z ]]
83 .I filter
84 [\c
85 .IR attrs... ]
86 .SH DESCRIPTION
87 .I ldapsearch
88 is a shell-accessible interface to the
89 .BR ldap_search_ext (3)
90 library call.
91 .LP
92 .B ldapsearch
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, \fB(objectClass=*)\fP, is used.
97 .LP
98 If
99 .B ldapsearch
100 finds one or more entries, the attributes specified by
101 \fIattrs\fP are returned.  If \fB*\fP is listed, all user attributes are
102 returned.  If \fB+\fP 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.
105 .LP
106 The search results are displayed using an extended version of LDIF.
107 Option \fI\-L\fP controls the format of the output.
108 .SH OPTIONS
109 .TP
110 .B \-n
111 Show what would be done, but don't actually perform the search.  Useful for
112 debugging in conjunction with \fB\-v\fP.
113 .TP
114 .B \-c
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 \fB\-f\fP.
118 .TP
119 .B \-u
120 Include the User Friendly Name form of the Distinguished Name (DN)
121 in the output.
122 .TP
123 .B \-v
124 Run in verbose mode, with many diagnostics written to standard output.
125 .TP
126 .BR \-t [ t ]
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
130 files.
131 .TP
132 .BI \-T \ path
133 Write temporary files to directory specified by \fIpath\fP (default:
134 \fB/var/tmp/\fP)
135 .TP
136 .BI \-F \ prefix
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.
139 .TP
140 .B \-A
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
143 specific values.
144 .TP
145 .B \-L
146 Search results are display in LDAP Data Interchange Format detailed in
147 .BR ldif (5).
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.
152 .TP
153 .BR \-M [ M ]
154 Enable manage DSA IT control.
155 .B \-MM
156 makes control critical.
157 .TP
158 .BI \-S \ attribute
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
162 .BR ldap_sort (3)
163 for more details. Note that
164 .B ldapsearch
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.
168 .TP
169 .BI \-d \ debuglevel
170 Set the LDAP debugging level to \fIdebuglevel\fP.
171 .B ldapsearch
172 must be compiled with LDAP_DEBUG defined for this option to have any effect.
173 .TP
174 .BI \-f \ file
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.
184 .B ldapsearch
185 will exit when the first non-successful search result is returned,
186 unless \fB\-c\fP is used.
187 .TP
188 .B \-x 
189 Use simple authentication instead of SASL.
190 .TP
191 .BI \-D \ binddn
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.
194 .TP
195 .B \-W
196 Prompt for simple authentication.
197 This is used instead of specifying the password on the command line.
198 .TP
199 .BI \-w \ passwd
200 Use \fIpasswd\fP as the password for simple authentication.
201 .TP
202 .BI \-y \ passwdfile
203 Use complete contents of \fIpasswdfile\fP as the password for
204 simple authentication.
205 .TP
206 .BI \-H \ ldapuri
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.
215 .TP
216 .BI \-h \ ldaphost
217 Specify an alternate host on which the ldap server is running.
218 Deprecated in favor of \fB\-H\fP.
219 .TP
220 .BI \-p \ ldapport
221 Specify an alternate TCP port where the ldap server is listening.
222 Deprecated in favor of \fB\-H\fP.
223 .TP
224 .BI \-b \ searchbase
225 Use \fIsearchbase\fP as the starting point for the search instead of
226 the default.
227 .TP
228 .BR \-s \ { base \||\| one \||\| sub \||\| children }
229 Specify the scope of the search to be one of
230 .BR base ,
231 .BR one ,
232 .BR sub ,
233 or
234 .B children
235 to specify a base object, one-level, subtree, or children search.
236 The default is
237 .BR sub .
238 Note:
239 .I children
240 scope requires LDAPv3 subordinate feature extension.
241 .TP
242 .BR \-a \ { never \||\| always \||\| search \||\| find }
243 Specify how aliases dereferencing is done.  Should be one of
244 .BR never ,
245 .BR always ,
246 .BR search ,
247 or
248 .B find
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.
252 .TP
253 .BR \-P \ { 2 \||\| 3 }
254 Specify the LDAP protocol version to use.
255 .TP
256 .BR \-e \ [ ! ] \fIext\fP [ =\fIextparam\fP ]
257 .TP
258 .BR \-E \ [ ! ] \fIext\fP [ =\fIextparam\fP ]
259
260 Specify general extensions with \fB\-e\fP and search extensions with \fB\-E\fP.
261 \'\fB!\fP\' indicates criticality.
262
263 General extensions:
264 .nf
265   [!]assert=<filter>    (an RFC 4515 Filter)
266   !authzid=<authzid>    ("dn:<dn>" or "u:<user>")
267   [!]bauthzid           (RFC 3829 authzid control)
268   [!]chaining[=<resolve>[/<cont>]]
269   [!]manageDSAit
270   [!]noop
271   ppolicy
272   [!]postread[=<attrs>] (a comma-separated attribute list)
273   [!]preread[=<attrs>]  (a comma-separated attribute list)
274   [!]relax
275   sessiontracking
276   abandon,cancel,ignore (SIGINT sends abandon/cancel,
277   or ignores response; if critical, doesn't wait for SIGINT.
278   not really controls)
279 .fi
280
281 Search extensions:
282 .nf
283   !dontUseCopy
284   [!]domainScope                       (domain scope)
285   [!]mv=<filter>                       (matched values filter)
286   [!]pr=<size>[/prompt|noprompt]       (paged results/prompt)
287   [!]sss=[\-]<attr[:OID]>[/[\-]<attr[:OID]>...]  (server side sorting)
288   [!]subentries[=true|false]           (subentries)
289   [!]sync=ro[/<cookie>]                (LDAP Sync refreshOnly)
290           rp[/<cookie>][/<slimit>]     (LDAP Sync refreshAndPersist)
291   [!]vlv=<before>/<after>(/<offset>/<count>|:<value>)  (virtual list view)
292   [!]deref=derefAttr:attr[,attr[...]][;derefAttr:attr[,attr[...]]]
293   [!]<oid>[=<value>]
294 .fi
295 .TP
296 .BI \-l \ timelimit
297 wait at most \fItimelimit\fP seconds for a search to complete.
298 A timelimit of
299 .I 0
300 (zero) or
301 .I none
302 means no limit.
303 A timelimit of
304 .I max
305 means the maximum integer allowable by the protocol.
306 A server may impose a maximal timelimit which only
307 the root user may override.
308 .TP
309 .BI \-z \ sizelimit
310 retrieve at most \fIsizelimit\fP entries for a search.
311 A sizelimit of
312 .I 0
313 (zero) or
314 .I none
315 means no limit.
316 A sizelimit of
317 .I max
318 means the maximum integer allowable by the protocol.
319 A server may impose a maximal sizelimit which only
320 the root user may override.
321 .TP
322 .BI \-O \ security-properties
323 Specify SASL security properties.
324 .TP
325 .B \-I
326 Enable SASL Interactive mode.  Always prompt.  Default is to prompt
327 only as needed.
328 .TP
329 .B \-Q
330 Enable SASL Quiet mode.  Never prompt.
331 .TP
332 .BI \-U \ authcid
333 Specify the authentication ID for SASL bind. The form of the ID
334 depends on the actual SASL mechanism used.
335 .TP
336 .BI \-R \ realm
337 Specify the realm of authentication ID for SASL bind. The form of the realm
338 depends on the actual SASL mechanism used.
339 .TP
340 .BI \-X \ authzid
341 Specify the requested authorization ID for SASL bind.
342 .I authzid
343 must be one of the following formats:
344 .BI dn: "<distinguished name>"
345 or
346 .BI u: <username>
347 .TP
348 .BI \-Y \ mech
349 Specify the SASL mechanism to be used for authentication. If it's not
350 specified, the program will choose the best mechanism the server knows.
351 .TP
352 .BR \-Z [ Z ]
353 Issue StartTLS (Transport Layer Security) extended operation. If you use
354 \fB\-ZZ\fP, the command will require the operation to be successful.
355 .SH OUTPUT FORMAT
356 If one or more entries are found, each entry is written to standard
357 output in LDAP Data Interchange Format or
358 .BR ldif (5):
359 .LP
360 .nf
361     version: 1
362
363     # bjensen, example, net
364     dn: uid=bjensen,dc=example,dc=net
365     objectClass: person
366     objectClass: dcObject
367     uid: bjensen
368     cn: Barbara Jensen
369     sn: Jensen
370     ...
371 .fi
372 .LP
373 If the \fB\-t\fP option is used, the URI of a temporary file
374 is used in place of the actual value.  If the \fB\-A\fP option
375 is given, only the "attributename" part is written.
376 .SH EXAMPLE
377 The following command:
378 .LP
379 .nf
380     ldapsearch \-LLL "(sn=smith)" cn sn telephoneNumber
381 .fi
382 .LP
383 will perform a subtree search (using the default search base and
384 other parameters defined in
385 .BR ldap.conf (5))
386 for entries with a surname (sn) of smith.  The common name (cn), surname
387 (sn) and telephoneNumber values will be retrieved and printed to
388 standard output.
389 The output might look something like this if two entries are found:
390 .LP
391 .nf
392     dn: uid=jts,dc=example,dc=com
393     cn: John Smith
394     cn: John T. Smith
395     sn: Smith
396     sn;lang\-en: Smith
397     sn;lang\-de: Schmidt
398     telephoneNumber: 1 555 123\-4567
399
400     dn: uid=sss,dc=example,dc=com
401     cn: Steve Smith
402     cn: Steve S. Smith
403     sn: Smith
404     sn;lang\-en: Smith
405     sn;lang\-de: Schmidt
406     telephoneNumber: 1 555 765\-4321
407 .fi
408 .LP
409 The command:
410 .LP
411 .nf
412     ldapsearch \-LLL \-u \-t "(uid=xyz)" jpegPhoto audio
413 .fi
414 .LP
415 will perform a subtree search using the default search base for entries
416 with user id of "xyz".  The user friendly form of the entry's DN will be
417 output after the line that contains the DN itself, and the jpegPhoto
418 and audio values will be retrieved and written to temporary files.  The
419 output might look like this if one entry with one value for each of the
420 requested attributes is found:
421 .LP
422 .nf
423     dn: uid=xyz,dc=example,dc=com
424     ufn: xyz, example, com
425     audio:< file:///tmp/ldapsearch\-audio\-a19924
426     jpegPhoto:< file:///tmp/ldapsearch\-jpegPhoto\-a19924
427 .fi
428 .LP
429 This command:
430 .LP
431 .nf
432     ldapsearch \-LLL \-s one \-b "c=US" "(o=University*)" o description
433 .fi
434 .LP
435 will perform a one-level search at the c=US level for all entries
436 whose organization name (o) begins begins with \fBUniversity\fP.
437 The organization name and description attribute values will be retrieved
438 and printed to standard output, resulting in output similar to this:
439 .LP
440 .nf
441     dn: o=University of Alaska Fairbanks,c=US
442     o: University of Alaska Fairbanks
443     description: Preparing Alaska for a brave new yesterday
444     description: leaf node only
445
446     dn: o=University of Colorado at Boulder,c=US
447     o: University of Colorado at Boulder
448     description: No personnel information
449     description: Institution of education and research
450
451     dn: o=University of Colorado at Denver,c=US
452     o: University of Colorado at Denver
453     o: UCD
454     o: CU/Denver
455     o: CU\-Denver
456     description: Institute for Higher Learning and Research
457
458     dn: o=University of Florida,c=US
459     o: University of Florida
460     o: UFl
461     description: Warper of young minds
462
463     ...
464 .fi
465 .SH DIAGNOSTICS
466 Exit status is zero if no errors occur.
467 Errors result in a non-zero exit status and
468 a diagnostic message being written to standard error.
469 .SH "SEE ALSO"
470 .BR ldapadd (1),
471 .BR ldapdelete (1),
472 .BR ldapmodify (1),
473 .BR ldapmodrdn (1),
474 .BR ldap.conf (5),
475 .BR ldif (5),
476 .BR ldap (3),
477 .BR ldap_search_ext (3),
478 .BR ldap_sort (3)
479 .SH AUTHOR
480 The OpenLDAP Project <http://www.openldap.org/>
481 .SH ACKNOWLEDGEMENTS
482 .so ../Project