Hi, sorry it took a little longer ;-)
On Tuesday, 10. January 2006 03:30, [EMAIL PROTECTED] 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: [EMAIL PROTECTED]