ldap_multisort_entries() function sorts a chain of entries retrieved from an LDAP search call (ldap_search_s() or ldap_result()) by a specified set of attributes in the entries (or by DN if you don't specify a set of attributes).
For additional information, see "Sorting the Search Results" on page 135.
#include <ldap.h>
int ldap_multisort_entries( LDAP *ld, LDAPMessage **chain,
char **attr, LDAP_CMP_CALLBACK *cmp );
ld |
Connection handle, which is a pointer to an |
chain |
Chain of entries returned by the |
attr | |
cmp |
LDAP structure. To get the error code, call the ldap_get_lderrno() function.) LDAP_PARAM_ERROR if an invalid parameter was passed to the function roomNumber attribute, then by the telephoneNumber attribute.
#include <stdio.h>
#include <string.h>
#include <ldap.h>
...
LDAP *ld;
LDAPMessage *result;
char *my_searchbase = "o=Airius.com";
char *my_filter = "(sn=Jensen)";
char *attrs[3];
attrs[0] = "roomNumber";
attrs[1] = "telephoneNumber";
attrs[2] = NULL;
...
/* 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 );
}
/* Sort the results, using strcasecmp */
if ( ldap_multisort_entries( ld, &result, attrs, strcasecmp ) != LDAP_SUCCESS ) { ldap_perror( ld, "ldap_multisort_entries" );
return( 1 );
}
...
ldap_result(), ldap_search_s(), ldap_sort_entries().
Last Updated: 10/01/98 17:06:23