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