1 .TH LDAP_SEARCH 3 "25 July 1999" "OpenLDAP LDVERSION"
3 .\" Copyright 1998-1999 The OpenLDAP Foundation All Rights Reserved.
4 .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
6 ldap_search, ldap_search_s, ldap_search_st \- Perform an LDAP search operation
10 #include <sys/time.h> /* for struct timeval definition */
14 int ldap_search(ld, base, scope, filter, attrs, attrsonly)
19 char *filter, *attrs[];
23 int ldap_search_s(ld, base, scope, filter, attrs, attrsonly, res)
28 char *filter, *attrs[]
33 int ldap_search_st(ld, base, scope, filter, attrs, attrsonly, timeout, res)
38 char *filter, *attrs[]
40 struct timeval *timeout;
43 These routines are used to perform LDAP search operations.
45 does the search synchronously (i.e., not
46 returning until the operation completes).
49 the same, but allows a \fItimeout\fP to be specified.
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.
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
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> ::= '=' | '~=' | '<=' | '>='
76 The '~=' construct is used to specify approximate matching. The
77 representation for <attributetype> and <attributevalue> are as
78 described in RFC 1778. 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.
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 1588 for a more complete description of allowable
88 .BR ldap_getfilter (3)
89 for routines to help in constructing search filters automatically.
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.
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.
108 will return the LDAP error code resulting from the search operation.
113 returns -1 in case of trouble.
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).
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
127 .BR ldap_getfilter (3),
131 is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
133 is derived from University of Michigan LDAP 3.3 Release.