]> git.sur5r.net Git - openldap/blob - doc/man/man3/ldap_search.3
Update copyright statements
[openldap] / doc / man / man3 / ldap_search.3
1 .TH LDAP_SEARCH 3 "25 July 1999" "OpenLDAP LDVERSION"
2 .\" $OpenLDAP$
3 .\" Copyright 1998-2002 The OpenLDAP Foundation All Rights Reserved.
4 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
5 .SH NAME
6 ldap_search, ldap_search_s, ldap_search_st \- Perform an LDAP search operation
7 .SH SYNOPSIS
8 .nf
9 .ft B
10 #include <sys/time.h> /* for struct timeval definition */
11 #include <ldap.h>
12 .LP
13 .ft B
14 int ldap_search(ld, base, scope, filter, attrs, attrsonly)
15 .ft
16 LDAP *ld;
17 char *base;
18 int scope;
19 char *filter, *attrs[];
20 int attrsonly;
21 .LP
22 .ft B
23 int ldap_search_s(ld, base, scope, filter, attrs, attrsonly, res)
24 .ft
25 LDAP *ld;
26 char *base;
27 int scope;
28 char *filter, *attrs[]
29 int attrsonly;
30 LDAPMessage **res;
31 .LP
32 .ft B
33 int ldap_search_st(ld, base, scope, filter, attrs, attrsonly, timeout, res)
34 .ft
35 LDAP *ld;
36 char *base;
37 int scope;
38 char *filter, *attrs[]
39 int attrsonly;
40 struct timeval *timeout;
41 LDAPMessage **res;
42 .SH DESCRIPTION
43 These routines are used to perform LDAP search operations.
44 .B ldap_search_s()
45 does the search synchronously (i.e., not
46 returning until the operation completes).
47 .B ldap_search_st()
48 does
49 the same, but allows a \fItimeout\fP to be specified.
50 .B ldap_search()
51 is the asynchronous version, initiating the search and returning
52 the message id of the operation it initiated.
53 \fIBase\fP is the DN of the entry at which to start the search.
54 \fIScope\fP is the scope of the search and should be one of LDAP_SCOPE_BASE,
55 to search the object itself,
56 LDAP_SCOPE_ONELEVEL, to search the object's immediate children,
57 or LDAP_SCOPE_SUBTREE, to search the object and all its descendents.
58 .LP
59 \fIFilter\fP is a string
60 representation of the filter to apply in the search.  Simple filters
61 can be specified as \fIattributetype=attributevalue\fP.  More complex
62 filters are specified using a prefix notation according to the following
63 BNF:
64 .LP
65 .nf
66         <filter> ::= '(' <filtercomp> ')'
67         <filtercomp> ::= <and> | <or> | <not> | <simple>
68         <and> ::= '&' <filterlist>
69         <or> ::= '|' <filterlist>
70         <not> ::= '!' <filter>
71         <filterlist> ::= <filter> | <filter> <filterlist>
72         <simple> ::= <attributetype> <filtertype> <attributevalue>
73         <filtertype> ::= '=' | '~=' | '<=' | '>='
74 .fi
75 .LP
76 The '~=' construct is used to specify approximate matching.  The
77 representation for <attributetype> and <attributevalue> are as
78 described in RFC 2254.  In addition, <attributevalue> can be a single *
79 to achieve an attribute existence test, or can contain text and *'s
80 interspersed to achieve substring matching.
81 .LP
82 For example, the filter "mail=*" will find any entries that have a mail
83 attribute.  The filter "mail=*@terminator.rs.itd.umich.edu" will find
84 any entries that have a mail attribute ending in the specified string.
85 To put parentheses in a filter, escape them with a backslash '\\'
86 character.  See RFC 2254 for a more complete description of allowable
87 filters.  See
88 .BR ldap_getfilter (3)
89 for routines to help in constructing search filters automatically.
90 .LP
91 \fIAttrs\fP is a null-terminated array of attribute types to return
92 from entries that match \fIfilter\fP.
93 If NULL is specified, all attributes will be returned.
94 The type "*" (LDAP_ALL_USER_ATTRIBUTES) may be used to request
95 all user attributes to be returned.
96 The type "+"(LDAP_ALL_OPERATIONAL_ATTRIBUTES) may be used to request
97 all operational attributes to be returned.
98 To request no attributes, the type "1.1" (LDAP_NO_ATTRS)
99 should be listed by itself.
100 .LP
101 \fIAttrsonly\fP should be set to 1 if
102 only attribute types are wanted.  It should be set to 0 if both
103 attributes types and attribute values are wanted.
104 .SH ERRORS
105 .B ldap_search_s()
106 and
107 .B ldap_search_st()
108 will return the LDAP error code resulting from the search operation.
109 See
110 .BR ldap_error (3)
111 for details.
112 .B ldap_search()
113 returns -1 in case of trouble.
114 .SH NOTES
115 Note that both read
116 and list functionality are subsumed by these routines,
117 by using a filter like "objectclass=*" and a scope of LDAP_SCOPE_BASE (to
118 emulate read) or LDAP_SCOPE_ONELEVEL (to emulate list).
119 .LP
120 These routines may dynamically allocate memory.  The caller is
121 responsible for freeing such memory using supplied deallocation
122 routines.  Return values are contained
123 in <ldap.h>.
124 .SH SEE ALSO
125 .BR ldap (3),
126 .BR ldap_result (3),
127 .BR ldap_getfilter (3),
128 .BR ldap_error (3)
129 .SH ACKNOWLEDGEMENTS
130 .B      OpenLDAP
131 is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
132 .B      OpenLDAP
133 is derived from University of Michigan LDAP 3.3 Release.