On Thursday, July 31, 2003, at 10:52PM, Chris Heath <[EMAIL PROTECTED]> wrote:
I am using the Net::LDAP and Net::LDAP::Search objects to retrieve up to 10 entries from a LDAP db. Everything works fine until I try to sort the entries returned in the search object. The entries are sorted, but not by the attributes I specify. Instead they seem to be sorted by the DN. Does anyone have a clue as to what I am doing wrong? Here are some snippets of the code that I am using:
my $filter = "&(sn=$lname*)"; if ($fname) {$filter .= " (&(givenName=$fname*))"} $filter = "($filter)";
my $searchresult = $ldap->search( base => $search_base, filter => $filter, sizelimit => (11));
my @sort = ($searchresult->sorted(["sn", "givenName"]));
Thanks for any help you can give, chris h
The sorted method just takes an array of attributes, not a reference to an array!
my @sort = ($searchresult->sorted("sn", "givenName"));
In that page of the documentation the square brackets indicate the list is optional; with no list the method sorts by DN.
I can see how that might be confusing. Maybe we should add a few examples to the sorted entry
Graham. [who is supposed to be on vacation]