Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

LDAP Sorting
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);

Report this thread to moderator Post Follow-up to this message
Old Post
CZachary@wiley.com
05-24-05 01:59 AM


Re: LDAP Sorting
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);
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Jonathan Steinert
05-24-05 01:59 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

LDAP archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 10:25 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.