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