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