1 .TH LDAPSEARCH 1 "22 September 1998" "OpenLDAP LDVERSION"
3 ldapsearch \- ldap search tool
32 is a shell-accessible interface to the
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.
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
50 Show what would be done, but don't actually perform the search. Useful for
51 debugging in conjunction with -v.
54 Include the User Friendly form of the Distinguished Name (DN) in the output
57 Run in verbose mode, with many diagnostics written to standard output
60 Use Kerberos authentication instead of simple authentication. It is
61 assumed that you already have a valid ticket granting ticket.
63 must be compiled with KERBEROS defined for this option to have any effect.
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.
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.
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
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).
85 Display search results in
87 format. This option also turns on the -B option, and causes the -F option
91 Do not automatically follow referrals returned while searching.
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.
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.
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
106 for more details. Note that
108 normally prints out entries as it receives them. The use of the
110 option defeats this behavior, causing all entries to be retrieved,
111 then sorted, then printed.
114 Set the LDAP debugging level to \fIdebuglevel\fP.
116 must be compiled with LDAP_DEBUG defined for this option to have any effect.
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.
126 Use \fIbinddn\fP to bind to the X.500 directory. \fIbinddn\fP should be
127 a string-represented DN as defined in RFC 1779.
130 Use \fIbindpasswd\fP as the password for simple authentication.
133 Specify an alternate host on which the ldap server is running.
136 Specify an alternate TCP port where the ldap server is listening.
139 Use \fIsearchbase\fP as the starting point for the search instead of
143 Specify the scope of the search. \fIscope\fP should be one of
148 to specify a base object, one-level, or subtree search. The default
153 Specify how aliases dereferencing is done. \fIderef\fP should be one of
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.
164 wait at most \fItimelimit\fP seconds for a search to complete.
167 retrieve at most \fIsizelimit\fP entries for a search.
169 If one or more entries are found, each entry is written to standard output
173 Distinguished Name (DN)
174 User Friendly Name (this line present only if the -u option is used)
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.
187 The following command:
190 ldapsearch "cn=mark smith" cn telephoneNumber
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:
199 cn=Mark D Smith, ou="College of Literature, Science, and the Arts", ou=Students, ou=People, o=University of Michigan, c=US
204 telephoneNumber=+1 313 930-9489
206 cn=Mark C Smith, ou=Information Technology Division, ou=Faculty and Staff, ou=People, o=University of Michigan, c=US
210 telephoneNumber=+1 313 764-2277
216 ldapsearch -u -t "uid=mcs" jpegPhoto audio
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:
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
236 ldapsearch -L -s one -b "c=US" "o=university*" o description
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:
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
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
256 dn: o=University of Colorado at Denver, c=US
257 o: University of Colorado at Denver
261 description: Institute for Higher Learning and Research
263 dn: o=University of Florida, c=US
264 o: University of Florida
266 description: Warper of young minds
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.
282 .IR "A String Representation of Distinguished Names",
285 ISODE Consortium, March 1995.
288 .IR "A String Representation of LDAP Search Filters",
291 University of Michigan, December 1993.
294 is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
296 is derived from University of Michigan LDAP 3.3 Release.