For Programmers: Free Programming Magazines  


Home > Archive > LDAP > January 2006 > Net::LDAP hangs and then throws a "do_ypcall: clnt_call: RPC: Timed out" er









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 Net::LDAP hangs and then throws a "do_ypcall: clnt_call: RPC: Timed out" er
Jean-Francois.Larocque@nokia.com

2006-01-10, 4:21 am


I'm trying to read a list of values from a file (single entry per line) =
and use the value in a ldap-search query. When I try the script below it =
just hangs at the search line (used the perl -d option), but if I set =
the $domain variable inside the script by uncommenting the appropriate =
line it works fine. It's driving me mental, can anyone tell me where I'm =
going wrong?

I see it bind ok, then there's nothing else on the ldap server until I =
terminate the script.

When passed a value resulting from a previous process, LDAP search =
hangs.
No error no exception, it just hangs.=20
After a long time, I get a=20
"do_ypcall: clnt_call: RPC: Timed out"
error.

If I hardcode the value, it works fine.=20
I printed the value of the variable to look for non-printable =
characters, nothing.
I also made sure it was not a tainting problem.

Any idea anybody ?=20


(perl 5.8, and perl-ldap 0.31)

use Net::LDAP;

$ldap_server =3D 'ldapserver';
$ldap_binddn =3D 'cn=3DManager,dc=3Dmyldap,dc=3Dnet';
$ldap_bindpw =3D 'secret';
$ldap_port =3D 389;
$ldap_version =3D 3;


# Create LDAP connection
$ldap =3D Net::LDAP->new ($ldap_server, port =3D> $ldap_port, version =
=3D> $ldap_version);
$result =3D $ldap->bind($ldap_binddn, password =3D> $ldap_bindpw);
die $result->error() if $result->code();


open IMPORT, "import.csv" || die "Can't open import file\n";
while (<IMPORT> )
{
chomp $_;
$domain =3D $_;
#$domain =3D "testdomain.com";
# check $domain object exists in ou=3Ddomains
$msg =3D $ldap->search( base=3D>"ou=3Ddomains,dc=3Dmyldap,dc=3Dnet", =
filter=3D>"(associatedDomain=3D$domain)", );
$msg->code && die $msg->error;
print $msg->count() . "\n";
} # while IMPORT

$ldap->unbind();=20

> ________________________________________
____
> NOKIA
> Jean-Fran=E7ois Larocque
> SCM Administrator
> NOKIA, INC.
> 12278 Scripps Summit Drive phone: 858 831 1053
> San Diego, CA 92131 USA mobile: 619 884 4723
> Fax : 858 831 4165
> jean-francois.larocque@nokia.com
> ________________________________________
____
>=20

Peter Marschall

2006-01-20, 8:00 am

Hi,

sorry it took a little longer ;-)

On Tuesday, 10. January 2006 03:30, Jean-Francois.Larocque@nokia.com wrote:
> I'm trying to read a list of values from a file (single entry per line) and
> use the value in a ldap-search query. When I try the script below it just
> hangs at the search line (used the perl -d option), but if I set the
> $domain variable inside the script by uncommenting the appropriate line it
> works fine. It's driving me mental, can anyone tell me where I'm going
> wrong?
>
> I see it bind ok, then there's nothing else on the ldap server until I
> terminate the script.
>
> When passed a value resulting from a previous process, LDAP search hangs.
> No error no exception, it just hangs.
> After a long time, I get a
> "do_ypcall: clnt_call: RPC: Timed out"
> error.


This is not a problem aof perl-ldap but a problem in your NIS configuration:
do_ypcall is a function call in NIS.


> If I hardcode the value, it works fine.
> I printed the value of the variable to look for non-printable characters,
> nothing. I also made sure it was not a tainting problem.
>
> Any idea anybody ?


Just a wild guess:
Are the line ends in import.csv UNIX-like (i.e. LF) or DOS/Windows-like (i.e.
CR+LF) or even Mac-like?
What does chomp exactly cut off ?

> (perl 5.8, and perl-ldap 0.31)
>
> use Net::LDAP;
>
> $ldap_server = 'ldapserver';
> $ldap_binddn = 'cn=Manager,dc=myldap,dc=net';
> $ldap_bindpw = 'secret';
> $ldap_port = 389;
> $ldap_version = 3;
>
>
> # Create LDAP connection
> $ldap = Net::LDAP->new ($ldap_server, port => $ldap_port, version =>
> $ldap_version); $result = $ldap->bind($ldap_binddn, password =>
> $ldap_bindpw);
> die $result->error() if $result->code();
>
>
> open IMPORT, "import.csv" || die "Can't open import file\n";
> while (<IMPORT> )
> {
> chomp $_;
> $domain = $_;
> #$domain = "testdomain.com";
> # check $domain object exists in ou=domains
> $msg = $ldap->search( base=>"ou=domains,dc=myldap,dc=net",
> filter=>"(associatedDomain=$domain)", ); $msg->code && die $msg->error;
> print $msg->count() . "\n";
> } # while IMPORT
>
> $ldap->unbind();



--
Peter Marschall
eMail: peter@adpm.de
Sponsored Links







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

Copyright 2008 codecomments.com