]> git.sur5r.net Git - openldap/blob - doc/man/man3/ldap_search.3
syncrepl consistency patch: utilize BDB txn rollback
[openldap] / doc / man / man3 / ldap_search.3
1 .TH LDAP_SEARCH 3 "RELEASEDATE" "OpenLDAP LDVERSION"
2 .\" $OpenLDAP$
3 .\" Copyright 1998-2004 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 LIBRARY
8 OpenLDAP LDAP (libldap, -lldap)
9 .SH SYNOPSIS
10 .nf
11 .ft B
12 #include <sys/time.h> /* for struct timeval definition */
13 #include <ldap.h>
14 .LP
15 .ft B
16 int ldap_search(ld, base, scope, filter, attrs, attrsonly)
17 .ft
18 LDAP *ld;
19 char *base;
20 int scope;
21 char *filter, *attrs[];
22 int attrsonly;
23 .LP
24 .ft B
25 int ldap_search_s(ld, base, scope, filter, attrs, attrsonly, res)
26 .ft
27 LDAP *ld;
28 char *base;
29 int scope;
30 char *filter, *attrs[]
31 int attrsonly;
32 LDAPMessage **res;
33 .LP
34 .ft B
35 int ldap_search_st(ld, base, scope, filter, attrs, attrsonly, timeout, res)
36 .ft
37 LDAP *ld;
38 char *base;
39 int scope;
40 char *filter, *attrs[]
41 int attrsonly;
42 struct timeval *timeout;
43 LDAPMessage **res;
44 .SH DESCRIPTION
45 These routines are used to perform LDAP search operations.
46 .B ldap_search_s()
47 does the search synchronously (i.e., not
48 returning until the operation completes).
49 .B ldap_search_st()
50 does
51 the same, but allows a \fItimeout\fP to be specified.
52 .B ldap_search()
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.
60 .LP
61 \fIFilter\fP is a string
62 representation of the filter to apply in the search.  Simple filters
63 can be specified as \fI(attributetype=attributevalue)\fP.  More complex
64 filters are specified using a prefix notation according to the following
65 BNF:
66 .LP
67 .nf
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> ::= '=' | '~=' | '<=' | '>='
76 .fi
77 .LP
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.
83 .LP
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
89 filters. 
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, the return of all user attributes is requested.
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 in <ldap.h>.
123 .SH SEE ALSO
124 .BR ldap (3),
125 .BR ldap_result (3),
126 .BR ldap_getfilter (3),
127 .BR ldap_error (3)
128 .SH ACKNOWLEDGEMENTS
129 .B OpenLDAP
130 is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
131 .B OpenLDAP
132 is derived from University of Michigan LDAP 3.3 Release.