Manual Pages for UNIX Darwin command on man ldap_sort_values
MyWebUniversity

Manual Pages for UNIX Darwin command on man ldap_sort_values

LDAPSORT(3) LDAPSORT(3)

NAME

ldapsortentries, ldapsortvalues, ldapsortstrcasecmp - LDAP sort-

ing routines LLIIBBRRAARRYY

OpenLDAP LDAP (libldap, -lldap)

SYNOPSIS

##iinncclluuddee <>

llddaappssoorrtteennttrriieess((lldd,, cchhaaiinn,, aattttrr,, ccmmpp)) LDAP *ld; LDAPMessage **chain; char *attr; int (*cmp)(); llddaappssoorrttvvaalluueess((lldd,, vvaallss,, ccmmpp)) LDAP *ld; char **vals; int (*cmp)(); llddaappssoorrttssttrrccaasseeccmmpp((aa,, bb)) char *a; char *b;

DESCRIPTION

These routines are used to sort lists of entries and values retrieved from an LDAP server. llddaappssoorrtteennttrriieess(()) is used to sort a chain of entries retrieved from an LDAP search call either by DN or by some arbitrary attribute in the entries. It takes ld, the LDAP structure, which is only used for error reporting, chain, the list of entries as returned by llddaappsseeaarrcchhss(3) or llddaapprreessuulltt(3). attr is the attribute

to use as a key in the sort or NULL to sort by DN, and cmp is the com-

parison function to use when comparing values (or individual DN compo-

nents if sorting by DN). In this case, cmp should be a function taking two single values of the attr to sort by, and returning a value less than zero, equal to zero, or greater than zero, depending on whether the first argument is less than, equal to, or greater than the second argument. The convention is the same as used by qqssoorrtt(3), which is called to do the actual sorting. llddaappssoorrttvvaalluueess(()) is used to sort an array of values from an entry, as returned by llddaappggeettvvaalluueess(3). It takes the LDAP connection structure ld, the array of values to sort vals, and cmp, the comparison function to use during the sort. Note that cmp will be passed a pointer to each element in the vals array, so if you pass the normal char ** for this parameter, cmp should take two char **'s as arguments (i.e., you cannot pass strcasecmp or its friends for cmp). You can, however, pass the function llddaappssoorrttssttrrccaasseeccmmpp(()) for this purpose. For example: LDAP *ld; LDAPMessage *res; /* * ... call to ldapsearchs(), fill in res, * retrieve sn attr ... */ /* now sort the entries on surname attribute */ if ( ldapsortentries( ld, &res, "sn", ldapsortstrcasecmp ) != 0 ) ldapperror( ld, "ldapsortentries" ); NNOOTTEESS The llddaappssoorrtteennttrriieess(()) routine applies the comparison function to each value of the attribute in the array as returned by a call to llddaappggeettvvaalluueess(3), until a mismatch is found. This works fine for

single-valued attributes, but may produce unexpected results for multi-

valued attributes. When sorting by DN, the comparison function is applied to an exploded version of the DN, without types. The return values for all of these functions are declared in the header file. Some routines may dynamically allocate memory. Callers are responsible for freeing such memory using the supplied deallocation routines.

SEE ALSO

llddaapp(3), llddaappsseeaarrcchh(3), llddaapprreessuulltt(3), qqssoorrtt(3) AACCKKNNOOWWLLEEDDGGEEMMEENNTTSS OOppeennLLDDAAPP is developed and maintained by The OpenLDAP Project (http://www.openldap.org/). OOppeennLLDDAAPP is derived from University of Michigan LDAP 3.3 Release. OpenLDAP 2.2.19 2004/11/26 LDAPSORT(3)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™