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