1LDAP_FIRST_ATTRIBUTE(3) Library Functions Manual LDAP_FIRST_ATTRIBUTE(3)
2
3
4
6 ldap_first_attribute, ldap_next_attribute - step through LDAP entry at‐
7 tributes
8
10 OpenLDAP LDAP (libldap, -lldap)
11
13 #include <ldap.h>
14
15 char *ldap_first_attribute(
16 LDAP *ld, LDAPMessage *entry, BerElement **berptr )
17
18 char *ldap_next_attribute(
19 LDAP *ld, LDAPMessage *entry, BerElement *ber )
20
21 int ldap_get_attribute_ber(
22 LDAP *ld, LDAPMessage *entry, BerElement *ber,
23 BerValue *attr, BerVarray *vals )
24
26 The ldap_first_attribute(), ldap_next_attribute() and ldap_get_attri‐
27 bute_ber() routines are used to step through the attributes in an LDAP
28 entry. ldap_first_attribute() takes an entry as returned by
29 ldap_first_entry(3) or ldap_next_entry(3) and returns a pointer to
30 character string containing the first attribute description in the en‐
31 try. ldap_next_attribute() returns the next attribute description in
32 the entry.
33
34 It also returns, in berptr, a pointer to a BerElement it has allocated
35 to keep track of its current position. This pointer should be passed
36 to subsequent calls to ldap_next_attribute() and is used to effectively
37 step through the entry's attributes. The caller is solely responsible
38 for freeing the BerElement pointed to by berptr when it is no longer
39 needed by calling ber_free(3). When calling ber_free(3) in this in‐
40 stance, be sure the second argument is 0.
41
42 The attribute names returned are suitable for inclusion in a call to
43 ldap_get_values(3) to retrieve the attribute's values.
44
45 The ldap_get_attribute_ber() routine allows one to iterate over all at‐
46 tributes in-place, without allocating memory to hold text for the at‐
47 tribute name or its values, if requested. The use case is similar to
48 ldap_next_attribute() except that the attribute name is returned into
49 attr and, if vals is non-NULL, the list of values is stored there. Both
50 point into the LDAP message and remain valid only while the entry is
51 valid. The caller is still responsible for freeing vals with ldap_mem‐
52 free(3), if used.
53
55 If an error occurs, NULL is returned and the ld_errno field in the ld
56 parameter is set to indicate the error. See ldap_error(3) for a de‐
57 scription of possible error codes.
58
60 The ldap_first_attribute() and ldap_next_attribute() return dynamically
61 allocated memory that must be freed by the caller via ldap_memfree(3).
62 For ldap_get_attribute_ber(), only the actual vals pointer needs to be
63 freed with ldap_memfree(3), other data is accounted for as part of ber.
64
66 ldap(3), ldap_first_entry(3), ldap_get_values(3), ldap_error(3)
67
69 OpenLDAP Software is developed and maintained by The OpenLDAP Project
70 <http://www.openldap.org/>. OpenLDAP Software is derived from the Uni‐
71 versity of Michigan LDAP 3.3 Release.
72
73
74
75OpenLDAP 2.6.6 2023/07/31 LDAP_FIRST_ATTRIBUTE(3)