MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


LDAP Library Functions                           ldapsort(3LDAP)



NAME
     ldapsort,       ldapsortentries,        ldapsortvalues,
     ldapsortstrcasecmp - LDAP entry sorting functions

SYNOPSIS
     cc[ flag... ] file... -lldap[ library... ]
     #include 
     #include 

     ldapsortentries(LDAP *ld, LDAPMessage **chain, char *attr,
          int (*cmp)());


     ldapsortvalues(LDAP *ld, char **vals, int (*cmp)());


     ldapsortstrcasecmp(char *a, char *b);


DESCRIPTION
     These functions are used to sort lists of entries and values
     retrieved  from  an LDAP server. ldapsortentries() 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 ldapsearchs(3LDAP) or ldapresult(3LDAP). attr
     is the attribute to use as a key in the sort or NUL to sort
     by DN, and  cmp is the comparison function to use when  com-
     paring  values  (or  individual  DN components if sorting by
     DN). In this case,  cmp should be a function taking two sin-
     gle  values  of  the  attr to sort by, and returning a value
     less than zero, equal to zero, or greater than zero, depend-
     ing on whether the first argument is less than, equal to, or
     greater than the second argument. The convention is the same
     as used by qsort(3C), which is called to do the actual sort-
     ing.


     ldapsortvalues() is used to sort an array of  values  from
     an  entry,  as  returned by ldapgetvalues(3LDAP). 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  argu-
     ments  (that  is, you cannot pass  strcasecmp or its friends
     for    cmp).   You   can,   however,   pass   the   function
     ldapsortstrcasecmp() for this purpose.






SunOS 5.11          Last change: 27 Jan 2002                    1






LDAP Library Functions                           ldapsort(3LDAP)



     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" );


ATRIBUTES
     See attributes(5) for a description of the following  attri-
     butes:



     
           ATRIBUTE TYPE               ATRIBUTE VALUE       
     Availability                 SUNWcsl (32-bit)            
                                  SUNWcslx (64-bit)           
     Interface Stability          Evolving                    
    


SEE ALSO
     ldap(3LDAP),     ldapsearch(3LDAP),     ldapresult(3LDAP),
     qsort(3C), attributes(5)

NOTES
     The  ldapsortentries()  function  applies  the  comparison
     function  to  each  value  of  the attribute in the array as
     returned  by  a  call  to  ldapgetvalues(3LDAP),  until  a
     mismatch  is found. This works fine for single-valued attri-
     butes, 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 functions  may  allocate  memory
     which must be freed by the calling application.















SunOS 5.11          Last change: 27 Jan 2002                    2



OpenSolaris man pages main menu

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