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