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