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