]> 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-2017 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 general options.
336
337 General options:
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 .TP
343 .BI \-O \ security-properties
344 Specify SASL security properties.
345 .TP
346 .B \-I
347 Enable SASL Interactive mode.  Always prompt.  Default is to prompt
348 only as needed.
349 .TP
350 .B \-Q
351 Enable SASL Quiet mode.  Never prompt.
352 .TP
353 .B \-N
354 Do not use reverse DNS to canonicalize SASL host name.
355 .TP
356 .BI \-U \ authcid
357 Specify the authentication ID for SASL bind. The form of the ID
358 depends on the actual SASL mechanism used.
359 .TP
360 .BI \-R \ realm
361 Specify the realm of authentication ID for SASL bind. The form of the realm
362 depends on the actual SASL mechanism used.
363 .TP
364 .BI \-X \ authzid
365 Specify the requested authorization ID for SASL bind.
366 .I authzid
367 must be one of the following formats:
368 .BI dn: "<distinguished name>"
369 or
370 .BI u: <username>
371 .TP
372 .BI \-Y \ mech
373 Specify the SASL mechanism to be used for authentication. If it's not
374 specified, the program will choose the best mechanism the server knows.
375 .TP
376 .BR \-Z [ Z ]
377 Issue StartTLS (Transport Layer Security) extended operation. If you use
378 \fB\-ZZ\fP, the command will require the operation to be successful.
379 .SH OUTPUT FORMAT
380 If one or more entries are found, each entry is written to standard
381 output in LDAP Data Interchange Format or
382 .BR ldif (5):
383 .LP
384 .nf
385     version: 1
386
387     # bjensen, example, net
388     dn: uid=bjensen,dc=example,dc=net
389     objectClass: person
390     objectClass: dcObject
391     uid: bjensen
392     cn: Barbara Jensen
393     sn: Jensen
394     ...
395 .fi
396 .LP
397 If the \fB\-t\fP option is used, the URI of a temporary file
398 is used in place of the actual value.  If the \fB\-A\fP option
399 is given, only the "attributename" part is written.
400 .SH EXAMPLE
401 The following command:
402 .LP
403 .nf
404     ldapsearch \-LLL "(sn=smith)" cn sn telephoneNumber
405 .fi
406 .LP
407 will perform a subtree search (using the default search base and
408 other parameters defined in
409 .BR ldap.conf (5))
410 for entries with a surname (sn) of smith.  The common name (cn), surname
411 (sn) and telephoneNumber values will be retrieved and printed to
412 standard output.
413 The output might look something like this if two entries are found:
414 .LP
415 .nf
416     dn: uid=jts,dc=example,dc=com
417     cn: John Smith
418     cn: John T. Smith
419     sn: Smith
420     sn;lang\-en: Smith
421     sn;lang\-de: Schmidt
422     telephoneNumber: 1 555 123\-4567
423
424     dn: uid=sss,dc=example,dc=com
425     cn: Steve Smith
426     cn: Steve S. Smith
427     sn: Smith
428     sn;lang\-en: Smith
429     sn;lang\-de: Schmidt
430     telephoneNumber: 1 555 765\-4321
431 .fi
432 .LP
433 The command:
434 .LP
435 .nf
436     ldapsearch \-LLL \-u \-t "(uid=xyz)" jpegPhoto audio
437 .fi
438 .LP
439 will perform a subtree search using the default search base for entries
440 with user id of "xyz".  The user friendly form of the entry's DN will be
441 output after the line that contains the DN itself, and the jpegPhoto
442 and audio values will be retrieved and written to temporary files.  The
443 output might look like this if one entry with one value for each of the
444 requested attributes is found:
445 .LP
446 .nf
447     dn: uid=xyz,dc=example,dc=com
448     ufn: xyz, example, com
449     audio:< file:///tmp/ldapsearch\-audio\-a19924
450     jpegPhoto:< file:///tmp/ldapsearch\-jpegPhoto\-a19924
451 .fi
452 .LP
453 This command:
454 .LP
455 .nf
456     ldapsearch \-LLL \-s one \-b "c=US" "(o=University*)" o description
457 .fi
458 .LP
459 will perform a one-level search at the c=US level for all entries
460 whose organization name (o) begins with \fBUniversity\fP.
461 The organization name and description attribute values will be retrieved
462 and printed to standard output, resulting in output similar to this:
463 .LP
464 .nf
465     dn: o=University of Alaska Fairbanks,c=US
466     o: University of Alaska Fairbanks
467     description: Preparing Alaska for a brave new yesterday
468     description: leaf node only
469
470     dn: o=University of Colorado at Boulder,c=US
471     o: University of Colorado at Boulder
472     description: No personnel information
473     description: Institution of education and research
474
475     dn: o=University of Colorado at Denver,c=US
476     o: University of Colorado at Denver
477     o: UCD
478     o: CU/Denver
479     o: CU\-Denver
480     description: Institute for Higher Learning and Research
481
482     dn: o=University of Florida,c=US
483     o: University of Florida
484     o: UFl
485     description: Warper of young minds
486
487     ...
488 .fi
489 .SH DIAGNOSTICS
490 Exit status is zero if no errors occur.
491 Errors result in a non-zero exit status and
492 a diagnostic message being written to standard error.
493 .SH "SEE ALSO"
494 .BR ldapadd (1),
495 .BR ldapdelete (1),
496 .BR ldapmodify (1),
497 .BR ldapmodrdn (1),
498 .BR ldap.conf (5),
499 .BR ldif (5),
500 .BR ldap (3),
501 .BR ldap_search_ext (3),
502 .BR ldap_sort (3)
503 .SH AUTHOR
504 The OpenLDAP Project <http://www.openldap.org/>
505 .SH ACKNOWLEDGEMENTS
506 .so ../Project