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