ldap_first_attribute(3ldap)
ldap_first_attribute, ldap_next_attribute --
step through LDAP entry attributes
Synopsis
#include <lber.h>
#include <ldap.h>
char
ldap_first_attribute(LDAP
ld, LDAPMessage
entry,
BerElement 
berptr);
char
ldap_next_attribute(LDAP
ld, LDAPMessage
entry, BerElement
ber);
Description
The ldap_first_attribute and ldap_next_attribute
routines are used to step through the attributes in an LDAP entry.
ldap_first_attribute takes an entry as returned by
ldap_first_entry(3ldap)
or
ldap_next_entry(3ldap)
and returns a pointer to a per-connection buffer containing the first
attribute type in the entry. The return value should be treated as if it is
a pointer to a static area, that is, strdup it if you want to save
it (see the
string(3C)
manual page for details of strdup).
It also returns, in berptr, a pointer to a BerElement
it has allocated to keep track of its current position. This pointer should
be passed to subsequent calls to ldap_next_attribute and is used
used to effectively step through the entry's attributes. This pointer
is freed by ldap_next_attribute when there are no more attributes
(that is, when ldap_next_attribute returns NULL).
Otherwise, the caller is responsible for freeing the BerElement
pointed to by berptr when it is no longer needed by calling
ber_free. When calling ber_free in this instance, be sure
the second argument is 0. (See the
lber-decode(3ldap)
manual page for details).
The attribute names returned are suitable for inclusion in a call to
ldap_get_values(3ldap)
to retrieve the attribute's values.
Return values
If an error occurs, NULL is returned. See
ldap_perror(3ldap)
for a description of possible error codes.
Warnings
The ldap_first_attribute routine malloc's memory that
may need to be freed by the caller via ber_free.
See also
Intro(3ldap),
ldap_first_entry(3ldap),
ldap_get_values(3ldap),
ldap_perror(3ldap)
30 January 1998
© 1998 The Santa Cruz Operation, Inc. All rights reserved.