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