Table of Contents | Previous | Next | Index

Netscape Directory SDK 3.0 for C Programmer’s Guide
     Chapter 18 Functions

ldap_multisort_entries()

The 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.

Syntax

#include <ldap.h>
int ldap_multisort_entries( LDAP *ld, LDAPMessage **chain,
   char **attr, LDAP_CMP_CALLBACK *cmp );

Parameters

This function has the following parameters:

ld

Connection handle, which is a pointer to an LDAP structure containing information about the connection to the LDAP server.

chain

Chain of entries returned by the ldap_result() or ldap_search_s() function.

attr

Array of attributes to use when sorting the results. If NULL, results are sorted by distinguished name (DN).

cmp

Comparison function used when sorting the values.

Returns

One of the following values:

Example

The following section of code sorts entries first by the 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 );
}
... 

See Also

ldap_result(), ldap_search_s(), ldap_sort_entries().


Table of Contents | Previous | Next | Index

Last Updated: 10/01/98 17:06:23