2002-06-13 11:59:10 +08:00
|
|
|
.TH LDAP_SEARCH 3 "RELEASEDATE" "OpenLDAP LDVERSION"
|
1999-09-12 12:41:47 +08:00
|
|
|
.\" $OpenLDAP$
|
2005-01-02 04:49:32 +08:00
|
|
|
.\" Copyright 1998-2005 The OpenLDAP Foundation All Rights Reserved.
|
1999-09-12 12:41:47 +08:00
|
|
|
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
|
1998-08-09 08:43:13 +08:00
|
|
|
.SH NAME
|
|
|
|
ldap_search, ldap_search_s, ldap_search_st \- Perform an LDAP search operation
|
2002-06-21 15:32:54 +08:00
|
|
|
.SH LIBRARY
|
2002-06-22 05:25:38 +08:00
|
|
|
OpenLDAP LDAP (libldap, -lldap)
|
1998-08-09 08:43:13 +08:00
|
|
|
.SH SYNOPSIS
|
|
|
|
.nf
|
|
|
|
.ft B
|
|
|
|
#include <sys/time.h> /* for struct timeval definition */
|
|
|
|
#include <ldap.h>
|
|
|
|
.LP
|
|
|
|
.ft B
|
|
|
|
int ldap_search(ld, base, scope, filter, attrs, attrsonly)
|
|
|
|
.ft
|
|
|
|
LDAP *ld;
|
|
|
|
char *base;
|
|
|
|
int scope;
|
|
|
|
char *filter, *attrs[];
|
|
|
|
int attrsonly;
|
|
|
|
.LP
|
|
|
|
.ft B
|
|
|
|
int ldap_search_s(ld, base, scope, filter, attrs, attrsonly, res)
|
|
|
|
.ft
|
|
|
|
LDAP *ld;
|
|
|
|
char *base;
|
|
|
|
int scope;
|
|
|
|
char *filter, *attrs[]
|
|
|
|
int attrsonly;
|
|
|
|
LDAPMessage **res;
|
|
|
|
.LP
|
|
|
|
.ft B
|
|
|
|
int ldap_search_st(ld, base, scope, filter, attrs, attrsonly, timeout, res)
|
|
|
|
.ft
|
|
|
|
LDAP *ld;
|
|
|
|
char *base;
|
|
|
|
int scope;
|
|
|
|
char *filter, *attrs[]
|
|
|
|
int attrsonly;
|
|
|
|
struct timeval *timeout;
|
|
|
|
LDAPMessage **res;
|
|
|
|
.SH DESCRIPTION
|
|
|
|
These routines are used to perform LDAP search operations.
|
|
|
|
.B ldap_search_s()
|
|
|
|
does the search synchronously (i.e., not
|
|
|
|
returning until the operation completes).
|
|
|
|
.B ldap_search_st()
|
|
|
|
does
|
|
|
|
the same, but allows a \fItimeout\fP to be specified.
|
|
|
|
.B ldap_search()
|
|
|
|
is the asynchronous version, initiating the search and returning
|
|
|
|
the message id of the operation it initiated.
|
|
|
|
\fIBase\fP is the DN of the entry at which to start the search.
|
|
|
|
\fIScope\fP is the scope of the search and should be one of LDAP_SCOPE_BASE,
|
|
|
|
to search the object itself,
|
|
|
|
LDAP_SCOPE_ONELEVEL, to search the object's immediate children,
|
2005-07-04 14:57:10 +08:00
|
|
|
or LDAP_SCOPE_SUBTREE, to search the object and all its descendants.
|
1998-08-09 08:43:13 +08:00
|
|
|
.LP
|
|
|
|
\fIFilter\fP is a string
|
|
|
|
representation of the filter to apply in the search. Simple filters
|
2003-10-08 06:41:45 +08:00
|
|
|
can be specified as \fI(attributetype=attributevalue)\fP. More complex
|
1998-08-09 08:43:13 +08:00
|
|
|
filters are specified using a prefix notation according to the following
|
|
|
|
BNF:
|
|
|
|
.LP
|
|
|
|
.nf
|
|
|
|
<filter> ::= '(' <filtercomp> ')'
|
|
|
|
<filtercomp> ::= <and> | <or> | <not> | <simple>
|
|
|
|
<and> ::= '&' <filterlist>
|
|
|
|
<or> ::= '|' <filterlist>
|
|
|
|
<not> ::= '!' <filter>
|
|
|
|
<filterlist> ::= <filter> | <filter> <filterlist>
|
|
|
|
<simple> ::= <attributetype> <filtertype> <attributevalue>
|
|
|
|
<filtertype> ::= '=' | '~=' | '<=' | '>='
|
|
|
|
.fi
|
|
|
|
.LP
|
|
|
|
The '~=' construct is used to specify approximate matching. The
|
|
|
|
representation for <attributetype> and <attributevalue> are as
|
2000-09-02 06:10:19 +08:00
|
|
|
described in RFC 2254. In addition, <attributevalue> can be a single *
|
1998-08-09 08:43:13 +08:00
|
|
|
to achieve an attribute existence test, or can contain text and *'s
|
|
|
|
interspersed to achieve substring matching.
|
|
|
|
.LP
|
2003-10-08 06:41:45 +08:00
|
|
|
For example, the filter "(mail=*)" will find any entries that have a mail
|
|
|
|
attribute. The filter "(mail=*@terminator.rs.itd.umich.edu)" will find
|
1998-08-09 08:43:13 +08:00
|
|
|
any entries that have a mail attribute ending in the specified string.
|
|
|
|
To put parentheses in a filter, escape them with a backslash '\\'
|
2000-09-02 06:10:19 +08:00
|
|
|
character. See RFC 2254 for a more complete description of allowable
|
2002-08-08 11:03:48 +08:00
|
|
|
filters.
|
1998-08-09 08:43:13 +08:00
|
|
|
.LP
|
|
|
|
\fIAttrs\fP is a null-terminated array of attribute types to return
|
1999-07-26 04:52:42 +08:00
|
|
|
from entries that match \fIfilter\fP.
|
2003-10-08 06:41:45 +08:00
|
|
|
If NULL is specified, the return of all user attributes is requested.
|
1999-07-26 04:52:42 +08:00
|
|
|
The type "*" (LDAP_ALL_USER_ATTRIBUTES) may be used to request
|
|
|
|
all user attributes to be returned.
|
|
|
|
The type "+"(LDAP_ALL_OPERATIONAL_ATTRIBUTES) may be used to request
|
|
|
|
all operational attributes to be returned.
|
|
|
|
To request no attributes, the type "1.1" (LDAP_NO_ATTRS)
|
|
|
|
should be listed by itself.
|
|
|
|
.LP
|
|
|
|
\fIAttrsonly\fP should be set to 1 if
|
1998-08-09 08:43:13 +08:00
|
|
|
only attribute types are wanted. It should be set to 0 if both
|
|
|
|
attributes types and attribute values are wanted.
|
|
|
|
.SH ERRORS
|
|
|
|
.B ldap_search_s()
|
|
|
|
and
|
|
|
|
.B ldap_search_st()
|
|
|
|
will return the LDAP error code resulting from the search operation.
|
|
|
|
See
|
|
|
|
.BR ldap_error (3)
|
|
|
|
for details.
|
|
|
|
.B ldap_search()
|
|
|
|
returns -1 in case of trouble.
|
|
|
|
.SH NOTES
|
|
|
|
Note that both read
|
|
|
|
and list functionality are subsumed by these routines,
|
2003-10-08 06:41:45 +08:00
|
|
|
by using a filter like "(objectclass=*)" and a scope of LDAP_SCOPE_BASE (to
|
1998-08-09 08:43:13 +08:00
|
|
|
emulate read) or LDAP_SCOPE_ONELEVEL (to emulate list).
|
|
|
|
.LP
|
1998-12-23 03:08:27 +08:00
|
|
|
These routines may dynamically allocate memory. The caller is
|
|
|
|
responsible for freeing such memory using supplied deallocation
|
2003-10-08 06:41:45 +08:00
|
|
|
routines. Return values are contained in <ldap.h>.
|
1998-08-09 08:43:13 +08:00
|
|
|
.SH SEE ALSO
|
|
|
|
.BR ldap (3),
|
|
|
|
.BR ldap_result (3),
|
|
|
|
.BR ldap_error (3)
|
1998-10-25 09:41:42 +08:00
|
|
|
.SH ACKNOWLEDGEMENTS
|
2003-06-29 23:34:32 +08:00
|
|
|
.B OpenLDAP
|
1998-10-25 09:41:42 +08:00
|
|
|
is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
|
2003-06-29 23:34:32 +08:00
|
|
|
.B OpenLDAP
|
1998-10-25 09:41:42 +08:00
|
|
|
is derived from University of Michigan LDAP 3.3 Release.
|