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