LDAP Library Functions ldapsearch(3LDAP)
NAME
ldapsearch, ldapsearchs, ldapsearchext,
ldapsearchexts, ldapsearchst - LDAP search operations
SYNOPSIS
cc [ flag... ] file... -lldap[ library...]
#include /* for struct timeval definition */
#include
#include
int ldapsearch(LDAP *ld, char *base, int scope, char *filter,
char *attrs[], int attrsonly);
int ldapsearchs(LDAP *ld, char *base, int scope, char *filter,
char *attrs[],int attrsonly, LDAPMessage **res);
int ldapsearchst(LDAP *ld, char *base, int scope, char *filter,
char *attrs[], int attrsonly, struct timeval *timeout,
LDAPMessage **res);
int ldapsearchext(LDAP *ld, char *base, int scope, char
*filter, char **attrs, int attrsonly, LDAPControl **serverctrls,
LDAPControl **clientctrls, struct timeval *timeoutp,
int sizelimit, int *msgidp);
int ldapsearchexts(LDAP *ld,char *base, int scope, char *filter,
char **attrs, int attrsonly, LDAPControl **serverctrls,
LDAPControl **clientctrls, struct timeval *timeoutp,
int sizelimit, LDAPMessage **res);
DESCRIPTION
These functions are used to perform LDAP search operations.
The ldapsearchs() function does the search synchronously
(that is, not returning until the operation completes). The
ldapsearchst() function does the same, but allows a
timeout to be specified. The ldapsearch() function is the
asynchronous version, initiating the search and returning
the message ID of the operation it initiated.
The base is the DN of the entry at which to start the
search. The scope is the scope of the search and should be
one of LDAPSCOPEBASE, to search the object itself,
LDAPSCOPEONELEVEL, to search the object's immediate chil-
dren, or LDAPSCOPESUBTRE, to search the object and all
its descendents.
SunOS 5.11 Last change: 05 Dec 2003 1
LDAP Library Functions ldapsearch(3LDAP)
The filter is a string representation of the filter to apply
in the search. Simple filters can be specified as
attributetype=attributevalue. More complex filters are
specified using a prefix notation according to the following
BNF:
::= '(' ')'
::=
::= '&'
::= ''
::= '!'
::=
::=
::= '=' '~=' '<=' '>='
The '~=' construct is used to specify approximate matching.
The representation for and
are as described in RFC 1778. In addition,
can be a single * to achieve an attribute existence test, or
can contain text and *'s interspersed to achieve substring
matching.
For example, the filter mail=* finds entries that have a
mail attribute. The filter
mail=*@terminator.rs.itd.umich.edu finds entries that have a
mail attribute ending in the specified string. Use a
backslash (\fR) to escape parentheses characters in a
filter. See RFC 1588 for a more complete description of the
filters that are allowed. See ldapgetfilter(3LDAP) for
functions to help construct search filters automatically.
The attrs is a null-terminated array of attribute types to
return from entries that match filter. If NUL is specified,
all attributes are returned. The attrsonly is set to 1 when
attribute types only are wanted. The attrsonly is set to 0
when both attributes types and attribute values are wanted.
The sizelimit argument returns the number of matched entries
specified for a search operation. When sizelimit is set to
50, for example, no more than 50 entries are returned. When
sizelimit is set to 0, all matched entries are returned. The
LDAP server can be configured to send a maximum number of
entries, different from the size limit specified. If 5000
entries are matched in the database of a server configured
to send a maximum number of 500 entries, no more than 500
entries are returned even when sizelimit is set to 0.
SunOS 5.11 Last change: 05 Dec 2003 2
LDAP Library Functions ldapsearch(3LDAP)
The ldapsearchext() function initiates an asynchronous
search operation and returns LDAPSUCES when the request
is successfully sent to the server. Otherwise,
ldapsearchext() returns an LDAP error code. See
ldaperror(3LDAP). If successful, ldapsearchext() places
the message ID of the request in *msgidp. A subsequent call
to ldapresult(3LDAP) can be used to obtain the result of
the add request.
The ldapsearchexts() function initiates a synchronous
search operation and returns the result of the operation
itself.
ERORS
The ldapsearchs() and ldapsearchst() functions return
the LDAP error code that results from a search operation.
See ldaperror(3LDAP) for details.
The ldapsearch() function returns -1 when the operation
terminates unsuccessfully.
ATRIBUTES
See attributes(5) for a description of the following attri-
butes:
ATRIBUTE TYPE ATRIBUTE VALUE
Interface Stability Evolving
SEE ALSO
ldap(3LDAP), ldapresult(3LDAP), ldapgetfilter(3LDAP),
ldaperror(3LDAP) , attributes(5)
Howes, T., Kille, S., Yeong, W., Robbins, C., Wenn, J. RFC
1778, The String Representation of Standard Attribute Syn-
taxes. Network Working Group. March 1995.
Postel, J., Anderson, C. RFC 1588, White Pages Meeting
Report. Network Working Group. February 1994.
NOTES
The read and list functionality are subsumed by
ldapsearch() functions, when a filter such as objectclass=*
is used with the scope LDAPSCOPEBASE to emulate read or
SunOS 5.11 Last change: 05 Dec 2003 3
LDAP Library Functions ldapsearch(3LDAP)
the scope LDAPSCOPEONELEVEL to emulate list.
The ldapsearch() functions may allocate memory which must
be freed by the calling application. Return values are con-
tained in .
SunOS 5.11 Last change: 05 Dec 2003 4
|