Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

LDAP sorting

2 views
Skip to first unread message

ahappydeath

unread,
Jun 4, 2008, 11:18:40 AM6/4/08
to
Anyone have any idea how to make the '$result->sorted' method of
Net::LDAP become case insensitve?

Leon Timmermans

unread,
Jun 24, 2008, 10:25:45 AM6/24/08
to
On Wed, 04 Jun 2008 08:18:40 -0700, ahappydeath wrote:

> Anyone have any idea how to make the '$result->sorted' method of
> Net::LDAP become case insensitve?

Aside from using some really evil magic, I see no way to do that, but I
don't think you need to do that. You can just sort it yourself (it's
sorted on the client side anyway). I haven't tested this, but based on
the Net::LDAP code I'd say it should work something like this.


my $attribute = "some attribute you want to use to sort";
my $msg = $ldap->search(...);

my @sorted_entries =
map { $_->[0] }
sort { $a->[1] cmp $b->[1] }
map { [ $_, lc join("\000", @{ $_->get_value($attribute, asref => 1)
|| [] } ) ]}
$msg->entries();


It's not the prettiest Schwartzian transform ever, but it should work.

Cheers,

Leon

.

0 new messages