]> git.sur5r.net Git - openldap/blob - doc/man/man1/ldapsearch.1
Cast ber_read() arg to char*
[openldap] / doc / man / man1 / ldapsearch.1
1 .TH LDAPSEARCH 1 "25 July 1999" "OpenLDAP LDVERSION"
2 .SH NAME
3 ldapsearch \- ldap search tool
4 .SH SYNOPSIS
5 .B ldapsearch
6 [\c
7 .BR \-n ]
8 [\c
9 .BR \-u ]
10 [\c
11 .BR \-v ]
12 [\c
13 .BR \-k ]
14 [\c
15 .BR \-K ]
16 [\c
17 .BR \-t ]
18 [\c
19 .BR \-A ]
20 [\c
21 .BR \-B ]
22 [\c
23 .BR \-L ]
24 [\c
25 .BR \-M[M] ]
26 [\c
27 .BR \-R ]
28 [\c
29 .BI \-d \ debuglevel\fR]
30 [\c
31 .BI \-F \ sep\fR]
32 [\c
33 .BI \-f \ file\fR]
34 [\c
35 .BI \-D \ binddn\fR]
36 [\c
37 .BR \-W ]
38 [\c
39 .BI \-w \ bindpasswd\fR]
40 [\c
41 .BI \-h \ ldaphost\fR]
42 [\c
43 .BI \-p \ ldapport\fR]
44 [\c
45 .BI \-P \ 2\fR\||\|\fI3\fR]
46 [\c
47 .BI \-b \ searchbase\fR]
48 [\c
49 .BI \-s \ base\fR\||\|\fIone\fR\||\|\fIsub\fR]
50 [\c
51 .BI \-a \ never\fR\||\|\fIalways\fR\||\|\fIsearch\fR\||\|\fIfind\fR]
52 [\c
53 .BI \-l \ timelimit\fR]
54 [\c
55 .BI \-z \ sizelimit\fR]
56 .I filter
57 [\c
58 .IR attrs... ]
59 .SH DESCRIPTION
60 .I ldapsearch
61 is a shell-accessible interface to the
62 .BR ldap_search (3)
63 library call.
64 .LP
65 .B ldapsearch
66 opens a connection to an LDAP server, binds, and performs a search
67 using the filter \fIfilter\fP.  The \fIfilter\fP should conform to
68 the string representation for LDAP filters as defined in RFC 1558.
69 .LP
70 If
71 .B ldapsearch
72 finds one or more entries, the attributes specified by
73 \fIattrs\fP are retrieved and the entries and values are printed to
74 standard output.  If no \fIattrs\fP are listed, all attributes are
75 returned.  If * is listed, all user attributes are returned.
76 If + is listed, all operational attributes are returned.
77 If only 1.1 is listed, no attributes are listed.
78 .SH OPTIONS
79 .TP
80 .B \-n
81 Show what would be done, but don't actually perform the search.  Useful for
82 debugging in conjunction with -v.
83 .TP
84 .B \-u
85 Include the User Friendly form of the Distinguished Name (DN) in the output
86 .TP
87 .B \-v
88 Run in verbose mode, with many diagnostics written to standard output
89 .TP
90 .B \-k
91 Use Kerberos authentication instead of simple authentication.  It is
92 assumed that you already have a valid ticket granting ticket.
93 .B ldapsearch
94 must be compiled with KERBEROS defined for this option to have any effect.
95 .TP
96 .B \-K
97 Same as \-k, but only does step 1 of the kerberos bind.  This is useful
98 when connecting to a slapd and there is no x500dsa.hostname principal
99 registered with your kerberos servers.
100 .TP
101 .B \-t
102 Write retrieved values to a set of temporary files.  This is useful for
103 dealing with non-ASCII values such as jpegPhoto or audio.
104 .TP
105 .B \-A
106 Retrieve attributes only (no values).  This is useful when you just want to
107 see if an attribute is present in an entry and are not interested in the
108 specific values.
109 .TP
110 .B \-B
111 Do not suppress display of non-ascii values.  This is useful when
112 dealing with values that appear in alternate characters sets such as
113 ISO-8859.1.  This option is implied by -L (see below).
114 .TP
115 .B \-L
116 Display search results in
117 .BR ldif (5)
118 format.  This option also turns on the -B option, and causes the -F option
119 to be ignored.
120 .TP
121 .B \-M[M]
122 Enable manage DSA IT control.
123 .B \-MM
124 makes control critical.
125 .TP
126 .B \-R
127 Do not automatically follow referrals returned while searching.
128 .B ldapsearch
129 must be compiled with LDAP_REFERRALS defined for referrals to be
130 automatically followed by default, and for this option to have any effect.
131 .TP
132 .BI \-F \ sep
133 Use \fIsep\fP as the field separator between attribute names and values.
134 The default separator is `=', unless the -L flag has been specified, in
135 which case this option is ignored.
136 .TP
137 .BI \-S \ attribute
138 Sort the entries returned based on \fIattribute\fP. The default is not
139 to sort entries returned.  If \fIattribute\fP is a zero-length string (""),
140 the entries are sorted by the components of their Distingished Name.  See
141 .BR ldap_sort (3)
142 for more details. Note that
143 .B ldapsearch
144 normally prints out entries as it receives them. The use of the
145 .B \-S
146 option defeats this behavior, causing all entries to be retrieved,
147 then sorted, then printed.
148 .TP
149 .BI \-d \ debuglevel
150 Set the LDAP debugging level to \fIdebuglevel\fP.
151 .B ldapsearch
152 must be compiled with LDAP_DEBUG defined for this option to have any effect.
153 .TP
154 .BI \-f \ file
155 Read a series of lines from \fIfile\fP, performing one LDAP search for
156 each line.  In this case, the \fIfilter\fP given on the command line
157 is treated as a pattern where the first occurrence of \fB%s\fP is
158 replaced with a line from \fIfile\fP.  If \fIfile\fP is a single \fI-\fP
159 character, then the lines are read from standard input.
160 .TP
161 .BI \-D \ binddn
162 Use \fIbinddn\fP to bind to the LDAP directory. \fIbinddn\fP should be
163 a string-represented DN as defined in RFC 1779.
164 .TP
165 .B \-W
166 Prompt for simple authentication.
167 This is used instead of specifying the password on the command line.
168 .TP
169 .BI \-w \ bindpasswd
170 Use \fIbindpasswd\fP as the password for simple authentication.
171 .TP
172 .BI \-h \ ldaphost
173 Specify an alternate host on which the ldap server is running.
174 .TP
175 .BI \-p \ ldapport
176 Specify an alternate TCP port where the ldap server is listening.
177 .TP
178 .BI \-b \ searchbase
179 Use \fIsearchbase\fP as the starting point for the search instead of
180 the default.
181 .TP
182 .BI \-s \ base\fR\||\|\fIone\fR\||\|\fIsub
183 Specify the scope of the search to be one of
184 .IR base ,
185 .IR one ,
186 or
187 .I sub
188 to specify a base object, one-level, or subtree search.  The default
189 is
190 .IR sub .
191 .TP
192 .BI \-a \ never\fR\||\|\fIalways\fR\||\|\fIsearch\fR\||\|\fIfind
193 Specify how aliases dereferencing is done.  Should be one of
194 .IR never ,
195 .IR always ,
196 .IR search ,
197 or
198 .I find
199 to specify that aliases are never dereferenced, always dereferenced,
200 dereferenced when searching, or dereferenced only when locating the
201 base object for the search.  The default is to never dereference aliases.
202 .TP
203 .BI \-P \ 2\fR\||\|\fI3
204 Specify the LDAP protocol version to use.
205 .TP
206 .BI \-l \ timelimit
207 wait at most \fItimelimit\fP seconds for a search to complete.  A
208 timelimit of
209 .I 0
210 (zero) removes the
211 .B ldap.conf
212 limit.
213 A server may impose a maximal timelimit which only
214 the root user may override.
215 .TP
216 .BI \-z \ sizelimit
217 retrieve at most \fIsizelimit\fP entries for a search.  A sizelimit
218 of 
219 .I 0
220 (zero) removes the 
221 .B ldap.conf
222 limit.
223 A server may impose a maximal sizelimit which only
224 the root user may override.
225 .SH OUTPUT FORMAT
226 If one or more entries are found, each entry is written to standard output
227 in the form:
228 .LP
229 .nf
230     Distinguished Name (DN)
231     User Friendly Name (this line present only if the -u option is used)
232     attributename=value
233     attributename=value
234     attributename=value
235     ...
236 .fi
237 .LP
238 Multiple entries are separated with a single blank line.  If the -F option
239 is used to specify a separator character, it will be used instead of the
240 `=' character.  If the -t option is used, the name of a temporary file
241 is used in place of the actual value.  If the -A option
242 is given, only the "attributename" part is written.
243 .SH EXAMPLE
244 The following command:
245 .LP
246 .nf
247     ldapsearch "cn=mark smith" cn telephoneNumber
248 .fi
249 .LP
250 will perform a subtree search (using the default search base) for entries
251 with a commonName of "mark smith".  The commonName and telephoneNumber
252 values will be retrieved and printed to standard output.
253 The output might look something like this if two entries are found:
254 .LP
255 .nf
256 cn=Mark D Smith, ou="College of Literature, Science, and the Arts", ou=Students, ou=People, o=University of Michigan, c=US
257 cn=Mark Smith
258 cn=Mark David Smith
259 cn=Mark D Smith 1
260 cn=Mark D Smith
261 telephoneNumber=+1 313 930-9489
262
263 cn=Mark C Smith, ou=Information Technology Division, ou=Faculty and Staff, ou=People, o=University of Michigan, c=US
264 cn=Mark Smith
265 cn=Mark C Smith 1
266 cn=Mark C Smith
267 telephoneNumber=+1 313 764-2277
268 .fi
269 .LP
270 The command:
271 .LP
272 .nf
273     ldapsearch -u -t "uid=mcs" jpegPhoto audio
274 .fi
275 .LP
276 will perform a subtree search using the default search base for entries
277 with user id of "mcs".  The user friendly form of the entry's DN will be
278 output after the line that contains the DN itself, and the jpegPhoto
279 and audio values will be retrieved and written to temporary files.  The
280 output might look like this if one entry with one value for each of the
281 requested attributes is found:
282 .LP
283 .nf
284 cn=Mark C Smith, ou=Information Technology Division, ou=Faculty and Staff, ou=People, o=University of Michigan, c=US
285 Mark C Smith, Information Technology Division, Faculty and Staff, People, University of Michigan, US
286 audio=/tmp/ldapsearch-audio-a19924
287 jpegPhoto=/tmp/ldapsearch-jpegPhoto-a19924
288 .fi
289 .LP
290 This command:
291 .LP
292 .nf
293     ldapsearch -L -s one -b "c=US" "o=university*" o description
294 .fi
295 .LP
296 will perform a one-level search at the c=US level for all organizations
297 whose organizationName begins with \fBuniversity\fP.  Search results
298 will be displayed in the LDIF format.
299 The organizationName and description attribute values will be retrieved
300 and printed to standard output, resulting in output similar to this:
301 .LP
302 .nf
303 dn: o=University of Alaska Fairbanks, c=US
304 o: University of Alaska Fairbanks
305 description: Preparing Alaska for a brave new yesterday
306 description: leaf node only
307
308 dn: o=University of Colorado at Boulder, c=US
309 o: University of Colorado at Boulder
310 description: No personnel information
311 description: Institution of education and research
312
313 dn: o=University of Colorado at Denver, c=US
314 o: University of Colorado at Denver
315 o: UCD
316 o: CU/Denver
317 o: CU-Denver
318 description: Institute for Higher Learning and Research
319
320 dn: o=University of Florida, c=US
321 o: University of Florida
322 o: UFl
323 description: Warper of young minds
324
325 etc....
326 .fi
327 .SH DIAGNOSTICS
328 Exit status is 0 if no errors occur.  Errors result in a non-zero exit
329 status and a diagnostic message being written to standard error.
330 .SH "SEE ALSO"
331 .BR ldapadd (1),
332 .BR ldapdelete (1),
333 .BR ldapmodify (1),
334 .BR ldapmodrdn (1),
335 .BR ldap.conf (5),
336 .BR ldap (3),
337 .BR ldap_search (3)
338 .LP
339 Kille, S.,
340 .IR "A String Representation of Distinguished Names",
341 .SM RFC
342 1779,
343 ISODE Consortium, March 1995.
344 .LP
345 Howes, T.,
346 .IR "A String Representation of LDAP Search Filters",
347 .SM RFC
348 1558,
349 University of Michigan, December 1993.
350 .SH ACKNOWLEDGEMENTS
351 .B      OpenLDAP
352 is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
353 .B      OpenLDAP
354 is derived from University of Michigan LDAP 3.3 Release.