Cheers,
Chris
------ Forwarded Message
From: [EMAIL PROTECTED]
Date: Wed, 17 Dec 2003 08:11:14 +0200
To: [EMAIL PROTECTED]
Subject: RE: NET::LDAP:search
Hello Chris,
thanks for your suggestions & corrections.
My script is running with perl 5.6.0 on HP-UX 11.11
Regards,
Tapio
-----Original Message-----
From: Chris Ridd [mailto:[EMAIL PROTECTED]
Sent: 16. joulukuuta 2003 21:07
To: Niva Tapio; [EMAIL PROTECTED]
Subject: Re: NET::LDAP:search
On 16/12/03 7:06 am, [EMAIL PROTECTED]
<[EMAIL PROTECTED]>
wrote:
> Hello,
> following perl script, using Net::LDAP 0.30 , sometimes causes
> following problem :
> ---------------------------------------
> $ldap = Net::LDAP->new('<ldap-server>) or &DEBUG("Failed to open LDAP
> connection : $@"); $ldap->bind or &DEBUG("Failed to bind to LDAP :
> $@");
That doesn't test the bind worked, BTW. The bind method returns a
Net::LDAP::Message object which you need to query, similar to the search
method (except that returns a subclass of Message.)
> &DEBUG("LDAP connection opened ") ;
>
> undef $mesg ;
> $mesg = $ldap->search( base => "o=tietoenator corp", scope => "sub",
> filter => "(&(cn=$fullname)(ba=Processing & Network))" );
The '&' in 'Processing & Network' should be escaped, as it is a special
character in the string representation of LDAP filters. You ought to be
careful that $fullname is properly escaped too.
> if ( defined $mesg )
> {
> if ( $mesg->code == LDAP_SUCCESS ) # no errors
> { $cnt = $mesg->count; }
> else { $cnt = 0; }
> }
> ---------------------------------------
> The above script is continuously , about once each minute, doing the
> above search, and most of the times everything works ok.
>
> However, script sometimes exits with error message
> 'Can't call method "code" without a package or object reference at
> /home/niv/net_updater.pl line 205, <GEN4> line 52.'
>
> It seems to me that the "defined" test is not enough to make sure that
> $mesg is usable as an object.
Well, it is meant to be! What perl version are you using on what
platform?
Cheers,
Chris
------ End of Forwarded Message