ldap_first_attribute

Returns the name of the first attribute in an entry.

LDAP Version:v2 or higher
Library:*ldapsdk.*
NDS Version:7.xx or higher
Platform:NLM, Windows (NT, 95, 98, 2000, XP, Vista 32-bit and 64-bit ), Linux (32-bit and 64-bit), Solaris, AIX, and HP-UX

Syntax

  #include <ldap.h>
  
  char *ldap_first_attribute (
     LDAP          *ld,
     LDAPMessage   *entry,
     BerElement   **ptr);
  
  

Parameters

ld

(IN) Points to the handle for the LDAP session.

entry

(IN) Points to the entry whose attributes are being read.

ptr

(OUT) Returns a pointer to a BerElement allocated by the library. It is used internally to track the current position in the entry. This returned value is passed in subsequent calls to the ldap_next_attribute function. It should be freed by the application with a call to the ber_free (ptr, 0) function.

Return Values

NULL

No more attributes or failure

>0

Pointer to the name of the first attribute in an entry

Remarks

The ldap_first_attribute function returns a pointer to the first attribute of an entry returned by either the ldap_first_entry or the ldap_next_entry function.

If NULL is returned and the ptr parameter is not NULL, check the LDAP_OPT_RESULT_CODE option in the LDAP handle for the error code.

If NULL is returned and the ptr parameter is not NULL, all attributes have been retrieved.

The pointer to the name of the first attribute should be passed to the ldap_get_values function (or others of its type) to retrieve the attribute's values. When you are done with the name pointer, you must free it by calling the ldap_memfree function.

The ptr parameter should be used in subsequent calls to the ldap_next_attribute function to retrieve other attributes of the entry. When you are done with the BerElement structure and its value is non-NULL, you must free it by calling the ber_free function with the second parameter set to 0. If the ptr parameter is set to NULL, then the ldap_first_attribute function frees the memory.

See Also

ldap_next_attribute, ldap_get_values