Move everything from /var/adm to /var/log
[unleashed.git] / share / man / man1 / ldapsearch.1
blob91571c81bdfe19c956bc1d86c415122482e110aa
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|:\fIfileurl\fR]]\fR
345 .sp .6
346 .RS 4n
347 Criticality is a boolean value (default is \fBfalse\fR).
351 .ne 2
353 \fB\fB-k\fR \fIpath\fR\fR
355 .sp .6
356 .RS 4n
357 Specify the path to a directory containing conversion routines. These routines
358 are used if you want to specify a locale that is not supported by default by
359 your directory server. This is for NLS support.
363 .ne 2
365 \fB\fB-L\fR\fR
367 .sp .6
368 .RS 4n
369  Display search results in LDIF format. This option also turns on the \fB-B\fR
370 option. This behavior is the default.
374 .ne 2
376 \fB\fB-l\fR \fItimelimit\fR\fR
378 .sp .6
379 .RS 4n
380 Wait at most \fItimelimit\fR seconds for a search to complete.
384 .ne 2
386 \fB\fB-M\fR\fR
388 .sp .6
389 .RS 4n
390 Manage smart referrals. When they are the target of the operation, search the
391 entry containing the referral instead of the entry obtained by following the
392 referral.
396 .ne 2
398 \fB\fB-N\fR \fIcertificate\fR\fR
400 .sp .6
401 .RS 4n
402 Specify the certificate name to use for certificate-based client
403 authentication. For example: \fB-N\fR \fB"Directory-Cert"\fR\&.
407 .ne 2
409 \fB\fB-n\fR\fR
411 .sp .6
412 .RS 4n
413 Show what would be done, but do not actually perform the search. Useful in
414 conjunction with \fB-v\fR and \fB-d\fR for debugging.
418 .ne 2
420 \fB\fB-O\fR \fIhopLimit\fR\fR
422 .sp .6
423 .RS 4n
424 Specify the maximum number of referral hops to follow while finding an entry to
425 modify. By default, there is no limit.
429 .ne 2
431 \fB\fB-o\fR \fIattributename\fR=\fIvalue\fR\fR
433 .sp .6
434 .RS 4n
435 For SASL mechanisms and other options such as security properties, mode of
436 operation, authorization ID, authentication ID, and so forth.
438 The different attribute names and their values are as follows:
440 .ne 2
442 \fB\fBsecProp\fR=\fI"number"\fR\fR
444 .RS 20n
445 For defining SASL security properties.
449 .ne 2
451 \fB\fBrealm\fR=\fI"value"\fR\fR
453 .RS 20n
454 Specifies SASL realm (default is \fBrealm=none\fR).
458 .ne 2
460 \fB\fBauthzid\fR=\fI"value"\fR\fR
462 .RS 20n
463 Specify the authorization ID name for SASL bind.
467 .ne 2
469 \fB\fBauthid\fR=\fI"value"\fR\fR
471 .RS 20n
472 Specify the authentication ID for SASL bind.
476 .ne 2
478 \fB\fBmech\fR=\fI"value"\fR\fR
480 .RS 20n
481 Specifies the various SASL mechanisms.
487 .ne 2
489 \fB\fB-P\fR \fIpath\fR\fR
491 .sp .6
492 .RS 4n
493 Specify the path and filename of the client's certificate database. For
494 example:
496 .in +2
498 -P /home/uid/.netscape/cert7.db
500 .in -2
503 When using the command on the same host as the directory server, you can use
504 the server's own certificate database. For example:
506 .in +2
508 -P \fIinstallDir\fR/lapd-serverID/alias/cert7.db
510 .in -2
513 Use the \fB-P\fR option alone to specify server authentication only.
517 .ne 2
519 \fB\fB-p\fR \fIldapport\fR\fR
521 .sp .6
522 .RS 4n
523 Specify an alternate TCP port where the secure LAPD server is listening.
527 .ne 2
529 \fB\fB-R\fR\fR
531 .sp .6
532 .RS 4n
533 Do not automatically follow referrals returned while searching.
537 .ne 2
539 \fB\fB-r\fR\fR
541 .sp .6
542 .RS 4n
543 Display the output of the \fBldapsearch\fR command in the old format.
547 .ne 2
549 \fB\fB-S\fR [-]\fIattribute\fR\fR
551 .sp .6
552 .RS 4n
553 Specify an attribute for sorting the entries returned by the search. The sort
554 criteria is alphabetical on the attribute's value or reverse alphabetical with
555 the form \fB-attribute\fR. You can give multiple \fB-S\fR options to refine the
556 sorting, For example:
558 .in +2
560 -S sn -S \fIgivenname\fR
562 .in -2
565 By default, the entries are not sorted. Use the \fB-x\fR option to perform
566 server-side sorting.
570 .ne 2
572 \fB\fB-s\fR \fIscope\fR\fR
574 .sp .6
575 .RS 4n
576 Specify the scope of the search. The possible values of \fIscope\fR are
577 \fBbase\fR, \fBone\fR, or \fBsub\fR to specify respectively a base object,
578 one-level, or subtree search. The default is \fBsub\fR.
582 .ne 2
584 \fB\fB-T\fR\fR
586 .sp .6
587 .RS 4n
588 Format the output of search results so that no line breaks are used within
589 individual attribute values.
593 .ne 2
595 \fB\fB-t\fR\fR
597 .sp .6
598 .RS 4n
599 Write retrieved values to a set of temporary files. This is useful for dealing
600 with non-ASCII values such as jpegPhoto or audio.
604 .ne 2
606 \fB\fB-U\fR\fR
608 .sp .6
609 .RS 4n
610 URL format (valid only with the \fB-t\fR option). When using temporary file
611 output, the standard output of the tool includes the URL of the file instead of
612 the attributes value. For example:
614 .in +2
616 jpegPhoto:< file:/tmp/ldapsearch-jpegPhoto-YzaOMh
618 .in -2
624 .ne 2
626 \fB\fB-u\fR\fR
628 .sp .6
629 .RS 4n
630 Include the user-friendly form of the Distinguished Name (DN) in the output.
634 .ne 2
636 \fB\fB-V\fR \fIversion\fR\fR
638 .sp .6
639 .RS 4n
640 Specify the LDAP protocol version number to be used for the delete operation,
641 either 2 or 3. LDAP v3 is the default. Specify LDAP v2 when connecting to
642 servers that do not support v3.
646 .ne 2
648 \fB\fB-v\fR\fR
650 .sp .6
651 .RS 4n
652 Run in verbose mode, with diagnostics written to standard output.
656 .ne 2
658 \fB\fB-W\fR \fIpassword\fR\fR
660 .sp .6
661 .RS 4n
662 Specify the password for the client's key database given in the \fB-P\fR
663 option. This option is required for certificate-based client authentication.
664 Specifying \fIpassword\fR on the command line has security issues because the
665 password can be seen by others on the system by means of the \fBps\fR command.
666 Use the \fB-j\fR instead to specify the password from the file. This option is
667 mutually exclusive of \fB-j\fR.
671 .ne 2
673 \fB\fB-w\fR \fIpasswd\fR\fR
675 .sp .6
676 .RS 4n
677 Use \fIpasswd\fR as the password for authentication to the directory. When you
678 use \fB-w\fR \fIpasswd\fR to specify the password to be used for
679 authentication, the password is visible to other users of the system by means
680 of the \fBps\fR command, in script files or in shell history. If you use the
681 \fBldapsearch\fR command without this option, the command prompts for the
682 password and read it from standard in. When used without the \fB-w\fR option,
683 the password is not visible to other users.
687 .ne 2
689 \fB\fB-x\fR\fR
691 .sp .6
692 .RS 4n
693 Use with the \fB-S\fR option to specify that search results be sorted on the
694 server rather than by the \fBldapsearch\fR command running on the client. This
695 is useful if you want to sort according to a matching rule, as with an
696 international search. It is usually faster to sort on the server, if that is
697 supported, rather than on the client.
701 .ne 2
703 \fB\fB-Y\fR \fIproxyDN\fR\fR
705 .sp .6
706 .RS 4n
707 Specify the proxy DN (proxied authorization id) to use for the modify
708 operation, usually in double quotes (" ") for the shell.
712 .ne 2
714 \fB\fB-Z\fR\fR
716 .sp .6
717 .RS 4n
718 Specify that SSL be used to provide certificate-based client authentication.
719 This option requires the \fB-N\fR and SSL password and any other of the SSL
720 options needed to identify the certificate and the key database.
724 .ne 2
726 \fB\fB-z\fR \fIsizelimit\fR\fR
728 .sp .6
729 .RS 4n
730 Retrieve at most \fIsizelimit\fR entries for a search to complete.
733 .SH EXAMPLES
735 \fBExample 1 \fRPerforming a Subtree Search
738 The following command performs a subtree search (using the default search base)
739 for entries with a commonName of "mark smith". The commonName and
740 telephoneNumber values is retrieved and printed to standard output. Use the
741 \fB-r\fR option to display this output in the old format.
744 .in +2
746 example% ldapsearch "cn=mark smith" cn telephoneNumber
748 .in -2
753 The output looks something like this:
756 .in +2
758 dn: Mark D Smith, ou=Sales, ou=Atlanta, ou=People, o=XYZ, c=US
759 cn: Mark Smith
760 cn: Mark David Smith
761 cn: Mark D Smith 1
762 cn: Mark D Smith
763 telephoneNumber: +1 123 456-7890
765 dn: Mark C Smith, ou=Distribution, ou=Atlanta, ou=People, o=XYZ, c=US
766 cn: Mark Smith
767 cn: Mark C Smith 1
768 cn: Mark C Smith
769 telephoneNumber: +1 123 456-9999
771 .in -2
775 \fBExample 2 \fRPerforming a Subtree Search Using the Default Search Base
778 The following command performs a subtree search using the \fB-r\fR option to
779 display in old style format with a default search base for entries with user id
780 of \fBmcs\fR. The user-friendly form of the entry's DN is output after the line
781 that contains the DN itself, and the \fBjpegPhoto\fR and \fBaudio\fR values are
782 retrieved and written to temporary files.
785 .in +2
787 ldapsearch -r -u -t "uid=mcs" -r jpegPhoto audio
789 .in -2
794 The output might look like this if one entry with one value for each of the
795 requested attributes is found:
798 .in +2
800 cn=Mark C Smith, ou=Distribution, ou=Atlanta, ou=People, o=XYZ, c=US
801 Mark C Smith, Distribution, Atlanta, People, XYZ, US
802 audio=/tmp/ldapsearch-audio-a19924
803 jpegPhoto=/tmp/ldapsearch-jpegPhoto-a19924
805 .in -2
809 \fBExample 3 \fRPerforming a One-Level Search
812 The following command performs a one-level search at the c=US level for all
813 organizations whose organizationName begins with XY.
816 .in +2
818 example% ldapsearch -s one -b "c=US" "o=XY*" o description
820 .in -2
825 The \fBorganizationName\fR and \fBdescription\fR attribute values are retrieved
826 and printed to standard output, resulting in output similar to this:
829 .in +2
831 dn: o=XYZ    c=US
832      o: XYZ
833      description: XYZ Corporation
835      dn: o="XY Trading Company", c=US
836      o: XY Trading Company
837      description: Import and export specialists
839      dn: o=XYInternational, c=US
840      o: XYInternational
841      o: XYI
842      o: XY International
844 .in -2
848 \fBExample 4 \fRPerforming a Subtree Search on an IPv6 Server
851 The following command performs a subtree search using the default search base
852 for entries with a user id of \fBmcs\fR on an IPv6 (that is, \fB-h\fR) server:
855 .in +2
857 example% ldapsearch -u -h '['fec0::111:a00:20ff:fea3:edcf']' \e
858               -t "uid=mcs" jpegPhoto audio
860 .in -2
863 .SH EXIT STATUS
866 The following exit values are returned:
868 .ne 2
870 \fB\fB0\fR\fR
872 .RS 6n
873 Successful completion.
877 .ne 2
879 \fB>\fB0\fR\fR
881 .RS 6n
882 An error occurred. A diagnostic message is written to standard error.
885 .SH ATTRIBUTES
888 See \fBattributes\fR(5) for a description of the following attributes:
893 box;
894 c | c
895 l | l .
896 ATTRIBUTE TYPE  ATTRIBUTE VALUE
897 Stability Level Evolving
900 .SH SEE ALSO
903 \fBldapadd\fR(1), \fBldapdelete\fR(1), \fBldapmodify\fR(1),
904 \fBldapmodrdn\fR(1), \fBattributes\fR(5)