ldap_sort_values() function sorts an array of values retrieved from an ldap_get_values() call.
For additional information, see "Sorting the Search Results" on page 135.
#include <ldap.h>
int ldap_sort_values( LDAP *ld, char **vals,
LDAP_VALCMP_CALLBACK cmp );
ld |
Connection handle, which is a pointer to an |
vals | |
cmp | Comparison function used when sorting the values.
In the |
LDAP_SUCCESS if successful. #include <stdio.h>
#include <string.h>
#include <ldap.h>
...
LDAP *ld;
LDAPMessage *result, *e;
BerElement *ber;
char *a, *dn;
char **vals;
int i;
char *my_searchbase = "o=Airius.com";
char *my_filter = "(sn=Jensen)";
...
if ( ( vals = ldap_get_values( ld, e, a ) ) != NULL ) {/* Sort the values of the attribute */
if ( ldap_sort_values( ld, vals, strcasecmp ) ) != LDAP_SUCCESS ) {ldap_perror( ld, "ldap_sort_values" );
return( 1 );
}
/* Print the values of the attribute */
for ( i = 0; vals[i] != NULL; i++ ) {printf( "%s: %s\n", a, vals[i] );
}
/* Free the values from memory */
ldap_value_free( vals );
}
...
ldap_get_values(), ldap_sort_strcasecmp().
Last Updated: 10/01/98 17:06:23