LDAP Library Functions ldapentry2text(3LDAP)
NAME
ldapentry2text, ldapentry2textsearch, ldapentry2html,
ldapentry2htmlsearch, ldapvals2html, ldapvals2text -
LDAP entry display functions
SYNOPSIS
cc[ flag... ] file... -lldap[ library... ]
#include
#include
int ldapentry2text(LDAP *ld, char *buf, LDAPMessage *entry,
struct ldapdisptmpl *tmpl, char **defattrs, char ***defvals,
int (*writeproc)(), void *writeparm, char *eol, int rdncount,
unsigned long opts);
int ldapentry2textsearch(LDAP *ld, char *dn, char *base,
LDAPMessage *entry, struct ldapdisptmpl *tmpllist,
char **defattrs, char ***defvals, int (*writeproc)(),
void *writeparm, char *eol,int rdncount,
unsigned long opts);
int ldapvals2text(LDAP *ld, char *buf, char **vals, char *label,
int labelwidth, unsigned longsyntaxid, int (*writeproc)(),
void *writeparm, char *eol, int rdncount);
int ldapentry2html(LDAP *ld, char *buf, LDAPMessage *entry,
struct ldapdisptmpl *tmpl, char **defattrs, char ***defvals,
int (*writeproc)(),void *writeparm, char *eol, int rdncount,
unsigned long opts, char *urlprefix, char *base);
int ldapentry2htmlsearch(LDAP *ld, char *dn, LDAPMessage *entry,
struct ldapdisptmpl *tmpllist, char **defattrs, char ***defvals,
int (*writeproc)(), void *writeparm, char *eol, int rdncount,
unsigned long opts, char *urlprefix);
int ldapvals2html(LDAP *ld, char *buf, char **vals,
char *label, int labelwidth, unsigned long syntaxid,
int (*writeproc)(), void *writeparm, char *eol, int rdncount,
char *urlprefix);
#define LDAPDISPOPTAUTOLABELWIDTH 0x00000001
#define LDAPDISPOPTHTMLBODYONLY 0x00000002
SunOS 5.11 Last change: 27 Jan 2002 1
LDAP Library Functions ldapentry2text(3LDAP)
#define LDAPDTMPLBUFSIZ 2048
DESCRIPTION
These functions use the LDAP display template functions (see
ldapdisptmpl(3LDAP) and ldaptemplates.conf(4)) to produce
a plain text or an HyperText Markup Language (HTML) display
of an entry or a set of values. Typical plain text output
produced for an entry might look like:
"Barbara J Jensen, Information Technology Division"
Also Known As:
Babs Jensen
Barbara Jensen
Barbara J Jensen
E-Mail Address:
bjensen@terminator.rs.itd.umich.edu
Work Address:
535 W. William
Ann Arbor, MI 48103
Title:
Mythical Manager, Research Systems
...
The exact output produced will depend on the display tem-
plate configuration. HTML output is similar to the plain
text output, but more richly formatted.
ldapentry2text() produces a text representation of entry
and writes the text by calling the writeproc function. All
of the attributes values to be displayed must be present in
entry; no interaction with the LDAP server will be performed
within ldapentry2text. ld is the LDAP pointer obtained by a
previous call to ldapopen. writeproc should be declared as:
int writeproc( writeparm, p, len )
void *writeparm;
char *p;
int len;
where p is a pointer to text to be written and len is the
length of the text. p is guaranteed to be zero-terminated.
Lines of text are terminated with the string eol. buf is a
pointer to a buffer of size LDAPDTMPLBUFSIZ or larger. If
buf is NUL then a buffer is allocated and freed internally.
tmpl is a pointer to the display template to be used (usu-
ally obtained by calling ldapoc2template). If tmpl is NUL,
SunOS 5.11 Last change: 27 Jan 2002 2
LDAP Library Functions ldapentry2text(3LDAP)
no template is used and a generic display is produced.
defattrs is a NUL-terminated array of LDAP attribute names
which you wish to provide default values for (only used if
entry contains no values for the attribute). An array of
NUL-terminated arrays of default values corresponding to
the attributes should be passed in defvals. The rdncount
parameter is used to limit the number of Distinguished Name
(DN) components that are actually displayed for DN attri-
butes. If rdncount is zero, all components are shown. opts
is used to specify output options. The only values
currently allowed are zero (default output),
LDAPDISPOPTAUTOLABELWIDTH which causes the width for
labels to be determined based on the longest label in tmpl,
and LDAPDISPOPTHTMLBODYONLY. The
LDAPDISPOPTHTMLBODYONLY option instructs the library not
to include , , , and tags. In
other words, an HTML fragment is generated, and the caller
is responsible for prepending and appending the appropriate
HTML tags to construct a correct HTML document.
ldapentry2textsearch() is similar to ldapentry2text, and
all of the like-named parameters have the same meaning
except as noted below. If base is not NUL, it is the
search base to use when executing search actions. If it is
NUL, search action template items are ignored. If entry is
not NUL, it should contain the objectClass attribute values
for the entry to be displayed. If entry is NUL, dn must
not be NUL, and ldapentry2textsearch will retrieve the
objectClass values itself by calling ldapsearchs.
ldapentry2textsearch will determine the appropriate
display template to use by calling ldapoc2template, and
will call ldapsearchs to retrieve any attribute values to
be displayed. The tmpllist parameter is a pointer to the
entire list of templates available (usually obtained by cal-
ling ldapinittemplates or ldapinittemplatesbuf). If
tmpllist is NUL, ldapentry2textsearch will attempt to
read a load templates from the default template configura-
tion file ETCDIR/ldaptemplates.conf
ldapvals2text produces a text representation of a single
set of LDAP attribute values. The ld, buf, writeproc, wri-
teparm, eol, and rdncount parameters are the same as the
like-named parameters for ldapentry2text. vals is a NUL-
terminated list of values, usually obtained by a call to
ldapgetvalues. label is a string shown next to the values
(usually a friendly form of an LDAP attribute name).
labelwidth specifies the label margin, which is the number
of blank spaces displayed to the left of the values. If zero
is passed, a default label width is used. syntaxid is a
display template attribute syntax identifier (see
SunOS 5.11 Last change: 27 Jan 2002 3
LDAP Library Functions ldapentry2text(3LDAP)
ldapdisptmpl(3LDAP) for a list of the pre-defined
LDAPSYN... values).
ldapentry2html produces an HTML representation of entry. It
behaves exactly like ldapentry2text(3LDAP), except for the
formatted output and the addition of two parameters. urlpre-
fix is the starting text to use when constructing an LDAP
URL. The default is the string ldap:/ The second addi-
tional parameter, base, the search base to use when execut-
ing search actions. If it is NUL, search action template
items are ignored.
ldapentry2htmlsearch behaves exactly like
ldapentry2textsearch(3LDAP), except HTML output is pro-
duced and one additional parameter is required. urlprefix is
the starting text to use when constructing an LDAP URL. The
default is the string ldap:/
ldapvals2html behaves exactly like
ldapvals2text,exceptHTMLoutputis and one additional parame-
ter is required. urlprefix is the starting text to use when
constructing an LDAP URL. The default is the string ldap:/
ERORS
These functions all return an LDAP error code. LDAPSUCES
is returned if no error occurs. See ldaperror(3LDAP) for
details. The lderrno field of the ld parameter is also set
to indicate the error.
FILES
ETCDIR/ldaptemplates.conf
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), ldapdisptmpl(3LDAP), ldaptemplates.conf(4) ,
attributes(5)
SunOS 5.11 Last change: 27 Jan 2002 4
|