Merge commit 'b31320a79e2054c6739b5229259dbf98f3afc547' into merges
[unleashed.git] / share / man / man1 / ldapsearch.1
blobb7856ceb3b414a44d2649ec1b3c43e30bf22b741
1 '\" te
2 .\" Copyright (C) 1990, Regents of the University of Michigan.  All Rights Reserved.
3 .\" Portions Copyright (C) 2006, Sun Microsystems, Inc. All Rights Reserved.
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH LDAPSEARCH 1 "Jan 6, 2006"
8 .SH NAME
9 ldapsearch \- ldap search tool
10 .SH SYNOPSIS
11 .LP
12 .nf
13 \fBldapsearch\fR [\fB-n\fR] [\fB-u\fR] [\fB-v\fR] [\fB-t\fR] [\fB-A\fR] [\fB-B\fR] [\fB-L\fR] [\fB-R\fR] [\fB-H\fR]
14      [\fB-?\fR] [\fB-t\fR] [\fB-T\fR] [\fB-B\fR] [\fB-E\fR] [\fB-J\fR] [\fB-e\fR] [\fB-l\fR] [\fB-Z\fR] [\fB-r\fR]
15      [\fB-M\fR] [\fB-d\fR \fIdebuglevel\fR] [\fB-F\fR \fIsep\fR] [\fB-f\fR \fIfile\fR] [\fB-D\fR \fIbindDN\fR]
16      [\fB-j\fR \fIfilename\fR] [\fB-V\fR \fIversion\fR] [\fB-Y\fR \fIproxyDN\fR] [\fB-O\fR \fIhopLimit\fR]
17      [\fB-i\fR \fIlocale\fR] [\fB-k\fR \fIpath\fR] [\fB-S\fR [\fB-\fR] \fIattribute\fR] [\fB-C\fR \fIpattern\fR]
18      [\fB-c\fR \fIauthzid\fR] [\fB-P\fR \fIpath\fR] [\fB-N\fR \fIcertificate\fR] [\fB-w\fR \fIpasswd\fR]
19      [\fB-h\fR \fIldaphost\fR] [\fB-p\fR \fIldapport\fR] [\fB-o\fR \fIattributename\fR=\fIvalue\fR]
20      [\fB-b\fR \fIsearchbase\fR] [\fB-s\fR \fIscope\fR] [\fB-a\fR \fIderef\fR] [\fB-l\fR \fItimelimit\fR]
21      [\fB-z\fR \fIsizelimit\fR] \fIfilter\fR [\fIattrs\fR]...
22 .fi
24 .SH DESCRIPTION
25 .sp
26 .LP
27 The \fBldapsearch\fR utility opens a connection to an LDAP server, binds, and
28 performs a search using the filter \fIfilter\fR.
29 .sp
30 .LP
31 If \fBldapsearch\fR finds one or more entries, the attributes specified by
32 \fIattrs\fR are retrieved and the entries and values are printed to standard
33 output. If no \fIattrs\fR are listed, all attributes are returned.
34 .SS "Output Format"
35 .sp
36 .LP
37 If one or more entries are found, each entry is written to standard output in
38 the form:
39 .sp
40 .in +2
41 .nf
42 dn: Distinguished Name (DN)
43         attributename: value
44         attributename: value
45         attributename: value
46 \&...
47 .fi
48 .in -2
49 .sp
51 .sp
52 .LP
53 Multiple entries are separated with a single blank line. If the \fB-F\fR option
54 is used to specify a different separator character, this character is used
55 instead of the \fB:\fR character. If the \fB-t\fR option is used, the name of a
56 temporary file is returned in place of the actual value. If the \fB-A\fR option
57 is given, only the "attributename" is returned and not the attribute value.
58 .SH OPTIONS
59 .sp
60 .LP
61 The following options are supported:
62 .sp
63 .ne 2
64 .na
65 \fB\fB-A\fR\fR
66 .ad
67 .sp .6
68 .RS 4n
69 Retrieve attributes only (no values). This is useful when you just want to see
70 whether an attribute is present in an entry and are not interested in the
71 specific value.
72 .RE
74 .sp
75 .ne 2
76 .na
77 \fB\fB-a\fR \fIderef\fR\fR
78 .ad
79 .sp .6
80 .RS 4n
81 Specify how aliases dereferencing is done. The possible values for \fIderef\fR
82 are \fBnever\fR, \fBalways\fR, \fBsearch\fR, or \fBfind\fR to specify
83 respectively that aliases are never dereferenced, always dereferenced,
84 dereferenced when searching, or dereferenced only when finding the base object
85 for the search. The default is to never dereference aliases.
86 .RE
88 .sp
89 .ne 2
90 .na
91 \fB\fB-B\fR\fR
92 .ad
93 .sp .6
94 .RS 4n
95 Display non-ASCII values and use the old non-LDIF format. This option disables
96 the default \fB-L\fR option.
97 .RE
99 .sp
100 .ne 2
102 \fB\fB-b\fR \fIsearchbase\fR\fR
104 .sp .6
105 .RS 4n
106 Use \fIsearchbase\fR as the starting point for the search instead of the
107 default.
111 .ne 2
113 \fB\fB-C\fR \fIpattern\fR\fR
115 .sp .6
116 .RS 4n
117 Persistent search. Perform a search that keeps the connection open and displays
118 results whenever entries matching the scope and filter of the search are added,
119 modified, or removed. With this option, the \fBldapsearch\fR tool runs
120 indefinitely; you must type Control-c to stop it. The pattern has the following
121 format:
123 .in +2
125 ps:changeType[:changesOnly[:entryChangeControls]]
127 .in -2
133 .ne 2
135 \fB\fB-c\fR \fIauthzid\fR\fR
137 .sp .6
138 .RS 4n
139 Specifies the \fBgetEffectiveRights\fR control \fIauthzid\fR. For example:
141 .in +2
143 dn:uid=bjensen,dc=example,dc=com
145 .in -2
151 .ne 2
153 \fB\fB-D\fR \fIbindDN\fR\fR
155 .sp .6
156 .RS 4n
157 Use the distinguished name \fIbindDN\fR to bind to the directory.
161 .ne 2
163 \fB\fB-d\fR \fIdebuglevel\fR\fR
165 .sp .6
166 .RS 4n
167 Set the \fBLDAP\fR debugging level. Useful levels of debugging for
168 \fBldapsearch\fR are:
170 .ne 2
172 \fB\fB1\fR\fR
174 .RS 7n
175 Trace
179 .ne 2
181 \fB\fB2\fR\fR
183 .RS 7n
184 Packets
188 .ne 2
190 \fB\fB4\fR\fR
192 .RS 7n
193 Arguments
197 .ne 2
199 \fB\fB32\fR\fR
201 .RS 7n
202 Filters
206 .ne 2
208 \fB\fB128\fR\fR
210 .RS 7n
211 Access control
214 To request more than one category of debugging information, add the masks. For
215 example, to request trace and filter information, specify a debuglevel of 33.
219 .ne 2
221 \fB\fB-E\fR\fR
223 .sp .6
224 .RS 4n
225 Ask server to expose (report) bind identity by means of authentication response
226 control.
230 .ne 2
232 \fB\fB-e\fR\fR
234 .sp .6
235 .RS 4n
236 Minimize base-64 encoding of values.
240 .ne 2
242 \fB\fB-F\fR \fIsep\fR\fR
244 .sp .6
245 .RS 4n
246 Use \fIsep\fR as the field separator between attribute names and values. If
247 this option has been specified, the \fB-L\fR option is ignored.
251 .ne 2
253 \fB\fB-f\fR \fIfile\fR\fR
255 .sp .6
256 .RS 4n
257 Read a series of lines from \fIfile\fR, performing one \fBLDAP\fR search for
258 each line. In this case, the \fIfilter\fR given on the command line is treated
259 as a pattern where the first occurrence of \fB%s\fR is replaced with a line
260 from \fIfile\fR. If \fIfile\fR is a single \fI-\fR character, then the lines
261 are read from standard input.
265 .ne 2
267 \fB\fB-G\fR \fIpattern\fR\fR
269 .sp .6
270 .RS 4n
271 Virtual list view. Retrieve only a portion of all results, as determined by the
272 index or value of the search target and the number of entries to be returned
273 before and after the target. This option always requires the \fB-S\fR and
274 \fB-x\fR options to specify the sorting order on the server.
278 .ne 2
280 \fB\fB-?\fR\fR
282 .sp .6
283 .RS 4n
284 Display the usage help text that briefly describes all options.
288 .ne 2
290 \fB\fB-H\fR\fR
292 .sp .6
293 .RS 4n
294 Display the usage help text that briefly describes all options.
298 .ne 2
300 \fB\fB-h\fR \fIldaphost\fR\fR
302 .sp .6
303 .RS 4n
304 Specify an alternate host on which the secure LDAP server is running.
308 .ne 2
310 \fB\fB-i\fR \fIlocale\fR\fR
312 .sp .6
313 .RS 4n
314 Specify the character set to use for command-line input. The default is the
315 character set specified in the \fBLANG\fR environment variable. You might want
316 to use this option to perform the conversion from the specified character set
317 to UTF8, thus overriding the \fBLANG\fR setting. Using this argument, you can
318 input the bind DN, base DN, and the search filter pattern in the specified
319 character set. The \fBldapsearch\fR tool converts the input from these
320 arguments before it processes the search request. For example, \fB-i\fR
321 \fBno\fR indicates that the bind DN, base DN, and search filter are provided in
322 Norwegian. This argument only affects the command-line input. If you specify a
323 file containing a search filter (with the \fB-f\fR option), \fBldapsearch\fR
324 does not convert the data in the file.
328 .ne 2
330 \fB\fB-j\fR \fIfilename\fR\fR
332 .sp .6
333 .RS 4n
334 Specify a file containing the password for the bind DN or the password for the
335 SSL client's key database. To protect the password, use this option in scripts
336 and place the password in a secure file. This option is mutually exclusive of
337 the \fB-w\fR and \fB-W\fR options.
341 .ne 2
343 \fB\fB-J\fR [:\fIcriticality\fR[:\fIvalue\fR|::\fIb64value\fR|\fIb64value\fR|:\
344 fIfileurl\fR]]\fR
346 .sp .6
347 .RS 4n
348 Criticality is a boolean value (default is \fBfalse\fR).
352 .ne 2
354 \fB\fB-k\fR \fIpath\fR\fR
356 .sp .6
357 .RS 4n
358 Specify the path to a directory containing conversion routines. These routines
359 are used if you want to specify a locale that is not supported by default by
360 your directory server. This is for NLS support.
364 .ne 2
366 \fB\fB-L\fR\fR
368 .sp .6
369 .RS 4n
370  Display search results in LDIF format. This option also turns on the \fB-B\fR
371 option. This behavior is the default.
375 .ne 2
377 \fB\fB-l\fR \fItimelimit\fR\fR
379 .sp .6
380 .RS 4n
381 Wait at most \fItimelimit\fR seconds for a search to complete.
385 .ne 2
387 \fB\fB-M\fR\fR
389 .sp .6
390 .RS 4n
391 Manage smart referrals. When they are the target of the operation, search the
392 entry containing the referral instead of the entry obtained by following the
393 referral.
397 .ne 2
399 \fB\fB-N\fR \fIcertificate\fR\fR
401 .sp .6
402 .RS 4n
403 Specify the certificate name to use for certificate-based client
404 authentication. For example: \fB-N\fR \fB"Directory-Cert"\fR\&.
408 .ne 2
410 \fB\fB-n\fR\fR
412 .sp .6
413 .RS 4n
414 Show what would be done, but do not actually perform the search. Useful in
415 conjunction with \fB-v\fR and \fB-d\fR for debugging.
419 .ne 2
421 \fB\fB-O\fR \fIhopLimit\fR\fR
423 .sp .6
424 .RS 4n
425 Specify the maximum number of referral hops to follow while finding an entry to
426 modify. By default, there is no limit.
430 .ne 2
432 \fB\fB-o\fR \fIattributename\fR=\fIvalue\fR\fR
434 .sp .6
435 .RS 4n
436 For SASL mechanisms and other options such as security properties, mode of
437 operation, authorization ID, authentication ID, and so forth.
439 The different attribute names and their values are as follows:
441 .ne 2
443 \fB\fBsecProp\fR=\fI"number"\fR\fR
445 .RS 20n
446 For defining SASL security properties.
450 .ne 2
452 \fB\fBrealm\fR=\fI"value"\fR\fR
454 .RS 20n
455 Specifies SASL realm (default is \fBrealm=none\fR).
459 .ne 2
461 \fB\fBauthzid\fR=\fI"value"\fR\fR
463 .RS 20n
464 Specify the authorization ID name for SASL bind.
468 .ne 2
470 \fB\fBauthid\fR=\fI"value"\fR\fR
472 .RS 20n
473 Specify the authentication ID for SASL bind.
477 .ne 2
479 \fB\fBmech\fR=\fI"value"\fR\fR
481 .RS 20n
482 Specifies the various SASL mechanisms.
488 .ne 2
490 \fB\fB-P\fR \fIpath\fR\fR
492 .sp .6
493 .RS 4n
494 Specify the path and filename of the client's certificate database. For
495 example:
497 .in +2
499 -P /home/uid/.netscape/cert7.db
501 .in -2
504 When using the command on the same host as the directory server, you can use
505 the server's own certificate database. For example:
507 .in +2
509 -P \fIinstallDir\fR/lapd-serverID/alias/cert7.db
511 .in -2
514 Use the \fB-P\fR option alone to specify server authentication only.
518 .ne 2
520 \fB\fB-p\fR \fIldapport\fR\fR
522 .sp .6
523 .RS 4n
524 Specify an alternate TCP port where the secure LAPD server is listening.
528 .ne 2
530 \fB\fB-R\fR\fR
532 .sp .6
533 .RS 4n
534 Do not automatically follow referrals returned while searching.
538 .ne 2
540 \fB\fB-r\fR\fR
542 .sp .6
543 .RS 4n
544 Display the output of the \fBldapsearch\fR command in the old format.
548 .ne 2
550 \fB\fB-S\fR [-]\fIattribute\fR\fR
552 .sp .6
553 .RS 4n
554 Specify an attribute for sorting the entries returned by the search. The sort
555 criteria is alphabetical on the attribute's value or reverse alphabetical with
556 the form \fB-attribute\fR. You can give multiple \fB-S\fR options to refine the
557 sorting, For example:
559 .in +2
561 -S sn -S \fIgivenname\fR
563 .in -2
566 By default, the entries are not sorted. Use the \fB-x\fR option to perform
567 server-side sorting.
571 .ne 2
573 \fB\fB-s\fR \fIscope\fR\fR
575 .sp .6
576 .RS 4n
577 Specify the scope of the search. The possible values of \fIscope\fR are
578 \fBbase\fR, \fBone\fR, or \fBsub\fR to specify respectively a base object,
579 one-level, or subtree search. The default is \fBsub\fR.
583 .ne 2
585 \fB\fB-T\fR\fR
587 .sp .6
588 .RS 4n
589 Format the output of search results so that no line breaks are used within
590 individual attribute values.
594 .ne 2
596 \fB\fB-t\fR\fR
598 .sp .6
599 .RS 4n
600 Write retrieved values to a set of temporary files. This is useful for dealing
601 with non-ASCII values such as jpegPhoto or audio.
605 .ne 2
607 \fB\fB-U\fR\fR
609 .sp .6
610 .RS 4n
611 URL format (valid only with the \fB-t\fR option). When using temporary file
612 output, the standard output of the tool includes the URL of the file instead of
613 the attributes value. For example:
615 .in +2
617 jpegPhoto:< file:/tmp/ldapsearch-jpegPhoto-YzaOMh
619 .in -2
625 .ne 2
627 \fB\fB-u\fR\fR
629 .sp .6
630 .RS 4n
631 Include the user-friendly form of the Distinguished Name (DN) in the output.
635 .ne 2
637 \fB\fB-V\fR \fIversion\fR\fR
639 .sp .6
640 .RS 4n
641 Specify the LDAP protocol version number to be used for the delete operation,
642 either 2 or 3. LDAP v3 is the default. Specify LDAP v2 when connecting to
643 servers that do not support v3.
647 .ne 2
649 \fB\fB-v\fR\fR
651 .sp .6
652 .RS 4n
653 Run in verbose mode, with diagnostics written to standard output.
657 .ne 2
659 \fB\fB-W\fR \fIpassword\fR\fR
661 .sp .6
662 .RS 4n
663 Specify the password for the client's key database given in the \fB-P\fR
664 option. This option is required for certificate-based client authentication.
665 Specifying \fIpassword\fR on the command line has security issues because the
666 password can be seen by others on the system by means of the \fBps\fR command.
667 Use the \fB-j\fR instead to specify the password from the file. This option is
668 mutually exclusive of \fB-j\fR.
672 .ne 2
674 \fB\fB-w\fR \fIpasswd\fR\fR
676 .sp .6
677 .RS 4n
678 Use \fIpasswd\fR as the password for authentication to the directory. When you
679 use \fB-w\fR \fIpasswd\fR to specify the password to be used for
680 authentication, the password is visible to other users of the system by means
681 of the \fBps\fR command, in script files or in shell history. If you use the
682 \fBldapsearch\fR command without this option, the command prompts for the
683 password and read it from standard in. When used without the \fB-w\fR option,
684 the password is not visible to other users.
688 .ne 2
690 \fB\fB-x\fR\fR
692 .sp .6
693 .RS 4n
694 Use with the \fB-S\fR option to specify that search results be sorted on the
695 server rather than by the \fBldapsearch\fR command running on the client. This
696 is useful if you want to sort according to a matching rule, as with an
697 international search. It is usually faster to sort on the server, if that is
698 supported, rather than on the client.
702 .ne 2
704 \fB\fB-Y\fR \fIproxyDN\fR\fR
706 .sp .6
707 .RS 4n
708 Specify the proxy DN (proxied authorization id) to use for the modify
709 operation, usually in double quotes (" ") for the shell.
713 .ne 2
715 \fB\fB-Z\fR\fR
717 .sp .6
718 .RS 4n
719 Specify that SSL be used to provide certificate-based client authentication.
720 This option requires the \fB-N\fR and SSL password and any other of the SSL
721 options needed to identify the certificate and the key database.
725 .ne 2
727 \fB\fB-z\fR \fIsizelimit\fR\fR
729 .sp .6
730 .RS 4n
731 Retrieve at most \fIsizelimit\fR entries for a search to complete.
734 .SH EXAMPLES
736 \fBExample 1 \fRPerforming a Subtree Search
739 The following command performs a subtree search (using the default search base)
740 for entries with a commonName of "mark smith". The commonName and
741 telephoneNumber values is retrieved and printed to standard output. Use the
742 \fB-r\fR option to display this output in the old format.
745 .in +2
747 example% ldapsearch "cn=mark smith" cn telephoneNumber
749 .in -2
754 The output looks something like this:
757 .in +2
759 dn: Mark D Smith, ou=Sales, ou=Atlanta, ou=People, o=XYZ, c=US
760 cn: Mark Smith
761 cn: Mark David Smith
762 cn: Mark D Smith 1
763 cn: Mark D Smith
764 telephoneNumber: +1 123 456-7890
766 dn: Mark C Smith, ou=Distribution, ou=Atlanta, ou=People, o=XYZ, c=US
767 cn: Mark Smith
768 cn: Mark C Smith 1
769 cn: Mark C Smith
770 telephoneNumber: +1 123 456-9999
772 .in -2
776 \fBExample 2 \fRPerforming a Subtree Search Using the Default Search Base
779 The following command performs a subtree search using the \fB-r\fR option to
780 display in old style format with a default search base for entries with user id
781 of \fBmcs\fR. The user-friendly form of the entry's DN is output after the line
782 that contains the DN itself, and the \fBjpegPhoto\fR and \fBaudio\fR values are
783 retrieved and written to temporary files.
786 .in +2
788 ldapsearch -r -u -t "uid=mcs" -r jpegPhoto audio
790 .in -2
795 The output might look like this if one entry with one value for each of the
796 requested attributes is found:
799 .in +2
801 cn=Mark C Smith, ou=Distribution, ou=Atlanta, ou=People, o=XYZ, c=US
802 Mark C Smith, Distribution, Atlanta, People, XYZ, US
803 audio=/tmp/ldapsearch-audio-a19924
804 jpegPhoto=/tmp/ldapsearch-jpegPhoto-a19924
806 .in -2
810 \fBExample 3 \fRPerforming a One-Level Search
813 The following command performs a one-level search at the c=US level for all
814 organizations whose organizationName begins with XY.
817 .in +2
819 example% ldapsearch -s one -b "c=US" "o=XY*" o description
821 .in -2
826 The \fBorganizationName\fR and \fBdescription\fR attribute values are retrieved
827 and printed to standard output, resulting in output similar to this:
830 .in +2
832 dn: o=XYZ    c=US
833      o: XYZ
834      description: XYZ Corporation
836      dn: o="XY Trading Company", c=US
837      o: XY Trading Company
838      description: Import and export specialists
840      dn: o=XYInternational, c=US
841      o: XYInternational
842      o: XYI
843      o: XY International
845 .in -2
849 \fBExample 4 \fRPerforming a Subtree Search on an IPv6 Server
852 The following command performs a subtree search using the default search base
853 for entries with a user id of \fBmcs\fR on an IPv6 (that is, \fB-h\fR) server:
856 .in +2
858 example% ldapsearch -u -h '['fec0::111:a00:20ff:fea3:edcf']' \e
859               -t "uid=mcs" jpegPhoto audio
861 .in -2
864 .SH EXIT STATUS
867 The following exit values are returned:
869 .ne 2
871 \fB\fB0\fR\fR
873 .RS 6n
874 Successful completion.
878 .ne 2
880 \fB>\fB0\fR\fR
882 .RS 6n
883 An error occurred. A diagnostic message is written to standard error.
886 .SH ATTRIBUTES
889 See \fBattributes\fR(5) for a description of the following attributes:
894 box;
895 c | c
896 l | l .
897 ATTRIBUTE TYPE  ATTRIBUTE VALUE
898 Stability Level Evolving
901 .SH SEE ALSO
904 \fBldapadd\fR(1), \fBldapdelete\fR(1), \fBldapmodify\fR(1),
905 \fBldapmodrdn\fR(1), \fBattributes\fR(5)