ldap_first_attribute()

Purpose

Return the attribute type for the first attribute in an LDAP search entry

Format

#include <ldap.h> 

char * ldap_first_attribute(
    LDAP *                ld,
    LDAPMessage *         entry,
    BerElement **         ber)

Parameters

Input

ld
Specifies the LDAP handle.
entry
Specifies an entry returned by the ldap_first_entry() or ldap_next_entry() routine.

Output

ber
Returns the address of an LDAP control block used to maintain the current attribute position. The application must not modify this control block.

Usage

The ldap_first_attribute() routine returns the attribute type for the first attribute in the search entry. The ldap_next_attribute() routine should be called to obtain successive attributes in the search entry. The ldap_get_values() or ldap_get_values_len() routine can be called to get the attribute values associated with the attribute type.

The ber parameter returns the address of a control block allocated and maintained by the LDAP client run time. This control block is released when the ldap_next_attribute() routine returns a NULL value. The application should call the ldap_memfree() routine to release this control block if the application does not want to keep calling the ldap_next_attribute() routine until all attributes have been processed.

Function return value

The function return value is the attribute type of the first attribute. The attribute type is a null-terminated character string in UTF-8 or the local EBCDIC code page, as determined by the LDAP_OPT_UTF8_IO option for the LDAP handle. The application should call the ldap_memfree() routine to release the attribute type when it is no longer needed. The return value is NULL if there are no attributes or if an error is detected. The ldap_get_errno() routine can be called to get the error code when the return value is NULL. The error code is LDAP_SUCCESS if there are no attributes.

The following are some common errors for this routine:
LDAP_NO_MEMORY
Insufficient storage available.
LDAP_PARAM_ERROR
A parameter is not valid.