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