For Programmers: Free Programming Magazines  


Home > Archive > LDAP > May 2005 > LDAP Sorting









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author LDAP Sorting
CZachary@wiley.com

2005-05-23, 8:59 pm

Hello all,

I've been trying to sort the data returned from my LDAP host, but I get
the following error when I execute my script. Can any help?
I'm a newbie.

"Can't call method "Net::LDAP::Control::Sort" on an undefined value at
../ldapsort.pl line 39, <FH> line 7."

Here is my code

use Net::LDAP qw(:all);
use Net::LDAP::Util qw(ldap_error_text);
use Net::LDAP::Control::Sort;
use Net::LDAP::Constant qw(LDAP_CONTROL_SORTRESULT);

open(FH. "< somefile");

while (<FH> )
{
($iid, $domain, $session, $minutes, $cost) = split(/ */, $line);
$sorted->Net::LDAP::Control::Sort->new(
order => "departmentnumber"
);
$sr = $ldapObject->search(
base=> 'O=Wiley',
scope=> 'sub',
filter=>
"(&(objectclass=jwsPerson)(uid=$iid))",
control => [ $sorted ]
);

($resp) = $sr->control( LDAP_CONTROL_SORTRESULT );

print "Results are sorted\n" if $resp and
!$resp->result;
}
close(FH);
Jonathan Steinert

2005-05-23, 8:59 pm

The error should have clued you in that you have an arrow on the wrong
side of that package name.

The line:
$sorted->Net::LDAP::Control::Sort->new(

should probably read:
$sorted = Net::LDAP::Control::Sort->new(

Using 'strict' would have also thrown you a clue at compile time that
$sorted was never declared. You may want to think about using strict all
the time to prevent such mistakes as these.

--Jonathan Steinert

CZachary@wiley.com wrote:

>Hello all,
>
>I've been trying to sort the data returned from my LDAP host, but I get
>the following error when I execute my script. Can any help?
>I'm a newbie.
>
>"Can't call method "Net::LDAP::Control::Sort" on an undefined value at
>./ldapsort.pl line 39, <FH> line 7."
>
>Here is my code
>
>use Net::LDAP qw(:all);
>use Net::LDAP::Util qw(ldap_error_text);
>use Net::LDAP::Control::Sort;
>use Net::LDAP::Constant qw(LDAP_CONTROL_SORTRESULT);
>
>open(FH. "< somefile");
>
>while (<FH> )
>{
>($iid, $domain, $session, $minutes, $cost) = split(/ */, $line);
> $sorted->Net::LDAP::Control::Sort->new(
> order => "departmentnumber"
> );
> $sr = $ldapObject->search(
> base=> 'O=Wiley',
> scope=> 'sub',
> filter=>
>"(&(objectclass=jwsPerson)(uid=$iid))",
> control => [ $sorted ]
> );
>
> ($resp) = $sr->control( LDAP_CONTROL_SORTRESULT );
>
> print "Results are sorted\n" if $resp and
>!$resp->result;
>}
>close(FH);
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com