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