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