1 .TH LDAP_SEARCH 3 "RELEASEDATE" "OpenLDAP LDVERSION"
3 .\" Copyright 1998-2002 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
8 OpenlDAP LDAP (libldap, -lldap)
12 #include <sys/time.h> /* for struct timeval definition */
16 int ldap_search(ld, base, scope, filter, attrs, attrsonly)
21 char *filter, *attrs[];
25 int ldap_search_s(ld, base, scope, filter, attrs, attrsonly, res)
30 char *filter, *attrs[]
35 int ldap_search_st(ld, base, scope, filter, attrs, attrsonly, timeout, res)
40 char *filter, *attrs[]
42 struct timeval *timeout;
45 These routines are used to perform LDAP search operations.
47 does the search synchronously (i.e., not
48 returning until the operation completes).
51 the same, but allows a \fItimeout\fP to be specified.
53 is the asynchronous version, initiating the search and returning
54 the message id of the operation it initiated.
55 \fIBase\fP is the DN of the entry at which to start the search.
56 \fIScope\fP is the scope of the search and should be one of LDAP_SCOPE_BASE,
57 to search the object itself,
58 LDAP_SCOPE_ONELEVEL, to search the object's immediate children,
59 or LDAP_SCOPE_SUBTREE, to search the object and all its descendents.
61 \fIFilter\fP is a string
62 representation of the filter to apply in the search. Simple filters
63 can be specified as \fIattributetype=attributevalue\fP. More complex
64 filters are specified using a prefix notation according to the following
68 <filter> ::= '(' <filtercomp> ')'
69 <filtercomp> ::= <and> | <or> | <not> | <simple>
70 <and> ::= '&' <filterlist>
71 <or> ::= '|' <filterlist>
72 <not> ::= '!' <filter>
73 <filterlist> ::= <filter> | <filter> <filterlist>
74 <simple> ::= <attributetype> <filtertype> <attributevalue>
75 <filtertype> ::= '=' | '~=' | '<=' | '>='
78 The '~=' construct is used to specify approximate matching. The
79 representation for <attributetype> and <attributevalue> are as
80 described in RFC 2254. In addition, <attributevalue> can be a single *
81 to achieve an attribute existence test, or can contain text and *'s
82 interspersed to achieve substring matching.
84 For example, the filter "mail=*" will find any entries that have a mail
85 attribute. The filter "mail=*@terminator.rs.itd.umich.edu" will find
86 any entries that have a mail attribute ending in the specified string.
87 To put parentheses in a filter, escape them with a backslash '\\'
88 character. See RFC 2254 for a more complete description of allowable
90 .BR ldap_getfilter (3)
91 for routines to help in constructing search filters automatically.
93 \fIAttrs\fP is a null-terminated array of attribute types to return
94 from entries that match \fIfilter\fP.
95 If NULL is specified, all attributes will be returned.
96 The type "*" (LDAP_ALL_USER_ATTRIBUTES) may be used to request
97 all user attributes to be returned.
98 The type "+"(LDAP_ALL_OPERATIONAL_ATTRIBUTES) may be used to request
99 all operational attributes to be returned.
100 To request no attributes, the type "1.1" (LDAP_NO_ATTRS)
101 should be listed by itself.
103 \fIAttrsonly\fP should be set to 1 if
104 only attribute types are wanted. It should be set to 0 if both
105 attributes types and attribute values are wanted.
110 will return the LDAP error code resulting from the search operation.
115 returns -1 in case of trouble.
118 and list functionality are subsumed by these routines,
119 by using a filter like "objectclass=*" and a scope of LDAP_SCOPE_BASE (to
120 emulate read) or LDAP_SCOPE_ONELEVEL (to emulate list).
122 These routines may dynamically allocate memory. The caller is
123 responsible for freeing such memory using supplied deallocation
124 routines. Return values are contained
129 .BR ldap_getfilter (3),
133 is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
135 is derived from University of Michigan LDAP 3.3 Release.