ldap_first_attribute() function returns the name of the first attribute in a entry returned by the ldap_first_entry() function, the ldap_next_entry() function, or the ldap_result() function.
For more information, see "Getting Attributes from an Entry" on page 129.
#include <ldap.h>
char * ldap_first_attribute( LDAP *ld, LDAPMessage *entry,
BerElement **ber );
ld |
Connection handle, which is a pointer to an |
entry |
Pointer to the
|
ber |
A pointer to a |
ldap_memfree() function. LDAP structure. To get the error code, call the ldap_get_lderrno() function. (See "Result Codes" on page 691 for a complete listing of error codes.) #include <stdio.h>
#include <ldap.h>
...
LDAP *ld;
LDAPMessage *result, *e;
BerElement *ber;
char *a;
char *my_searchbase = "o=Airius.com";
char *my_filter = "(sn=Jensen)"
...
/* Search the directory */
if ( ldap_search_s( ld, my_searchbase, LDAP_SCOPE_SUBTREE, my_filter, NULL, 0, &result ) != LDAP_SUCCESS ) {ldap_perror( ld, "ldap_search_s" );
return( 1 );
}
/* Get the first matching entry.*/
e = ldap_first_entry( ld, result );
/* Retrieve the attributes the entry */
for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL;
a = ldap_next_attribute( ld, e, ber ) ) {
...
/* Code to get and manipulate attribute values */
...
}
ldap_memfree( a );
}
/* Free the BerElement from memory when done */
if ( ber != NULL ) {ldap_ber_free( ber, 0 );
}
...
ldap_first_entry(), ldap_next_entry(), ldap_next_attribute().
Last Updated: 10/01/98 17:06:23