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