LDAP Library Functions ldapgetfilter(3LDAP)
NAME
ldapgetfilter, ldapinitgetfilter,
ldapinitgetfilterbuf, ldapgetfilterfree,
ldapgetfirstfilter, ldapgetnextfilter,
ldapsetfilteraffixes, ldapbuildfilter - LDAP filter gen-
erating functions
SYNOPSIS
cc[ flag... ] file... -lldap[ library... ]
#include
#include
#define LDAPFILTMAXSIZ 1024
LDAPFiltDesc *ldapinitgetfilter(char *file);
LDAPFiltDesc *ldapinitgetfilterbuf(char *buf, long buflen);
ldapgetfilterfree(LDAPFiltDesc *lfdp);
LDAPFiltInfo *ldapgetfirstfilter(LDAPFiltDesc *lfdp, char *tagpat,
char *value);
LDAPFiltInfo *ldapgetnextfilter(LDAPFiltDesc *lfdp);
void ldapsetfilteraffixes(LDAPFiltDesc *lfdp, char *prefix,
char *suffix);
void ldapbuildfilter(char *buf, unsigned long buflen, char *pattern,
char *prefix, char *suffix, char *attr, char *value,
char **valwords);
DESCRIPTION
These functions are used to generate filters to be used in
ldapsearch(3LDAP) or ldapsearchs(3LDAP). Either
ldapinitgetfilter or ldapinitgetfilterbuf must be
called prior to calling any of the other functions except
ldapbuildfilter.
ldapinitgetfilter() takes a file name as its only argu-
ment. The contents of the file must be a valid LDAP filter
configuration file (see ldapfilter.conf(4)). If the file is
successfully read, a pointer to an LDAPFiltDesc is
returned. This is an opaque object that is passed in subse-
quent get filter calls.
SunOS 5.11 Last change: 28 Jan 2002 1
LDAP Library Functions ldapgetfilter(3LDAP)
ldapinitgetfilterbuf() reads from buf, whose length is
buflen, the LDAP filter configuration information. buf must
point to the contents of a valid LDAP filter configuration
file. See ldapfilter.conf(4). If the filter configuration
information is successfully read, a pointer to an LDAP-
FiltDesc is returned. This is an opaque object that is
passed in subsequent get filter calls.
ldapgetfilterfree() deallocates the memory consumed by
ldapinitgetfilter. Once it is called, the LDAPFiltDesc is
no longer valid and cannot be used again.
ldapgetfirstfilter() retrieves the first filter that is
appropriate for value. Only filter sets that have tags that
match the regular expession tagpat are considered.
ldapgetfirstfilter returns a pointer to an LDAPFiltInfo
structure, which contains a filter with value inserted as
appropriate in lfifilter, a text match description in
lfidesc, lfiscope set to indicate the search scope, and
lfiisexact set to indicate the type of filter. NUL is
returned if no matching filters are found. lfiscope will
be one of LDAPSCOPEBASE, LDAPSCOPEONELEVEL, or
LDAPSCOPESUBTRE. lfiisexact will be zero if the filter
has any '~' or '*' characters in it and non-zero otherwise.
ldapgetnextfilter() retrieves the next appropriate filter
in the filter set that was determined when
ldapgetfirstfilter was called. It returns NUL when the
list has been exhausted.
ldapsetfilteraffixes() sets a prefix to be prepended and a
suffix to be appended to all filters returned in the future.
ldapbuildfilter() constructs an LDAP search filter in buf.
buflen is the size, in bytes, of the largest filter buf can
hold. A pattern for the desired filter is passed in pat-
tern. Where the string %a appears in the pattern it is
replaced with attr. prefix is pre-pended to the resulting
filter, and suffix is appended. Either can be NUL , in
which case they are not used. value and valwords are used
when the string %v appears in pattern. See
ldapfilter.conf(4) for a description of how %v is handled.
ERORS
NUL is returned by ldapinitgetfilter if there is an
error reading file. NUL is returned by ldapgetfirstfilter
and ldapgetnextfilter when there are no more appropriate
SunOS 5.11 Last change: 28 Jan 2002 2
LDAP Library Functions ldapgetfilter(3LDAP)
filters to return.
FILES
ETCDIR/ldapfilter.conf LDAP filtering routine configura-
tion file.
ATRIBUTES
See attributes(5) for a description of the following attri-
butes:
ATRIBUTE TYPE ATRIBUTE VALUE
Availability SUNWcsl (32-bit)
SUNWcslx (64-bit)
Interface Stability Evolving
SEE ALSO
ldap(3LDAP), ldapfilter.conf(4), attributes(5)
NOTES
The return values for all of these functions are declared in
the header file. Some functions may allocate
memory which must be freed by the calling application.
SunOS 5.11 Last change: 28 Jan 2002 3
|