shawshankred has asked for the wisdom of the Perl Monks concerning the following question:

I've written a code to perform a LDAP search from the DB and it works fine if the value is available in the DB. However if the value is not available then the ldap query hangs for ever. If the value is not found it should not hang but come back with not found.

Please check the code and let me know if I am doing anything wrong.

sub hss_search{ my ($hss_ip,$pw,$subscriber) = @_; $ldap = Net::LDAP->new($hss_ip, port=>$LDAP_PORT) or die "$@"; my $ldapMsg = $ldap->bind(dn => "administratorName=jambala,nodeNam +e=lenxks_rstnva_hss01", password =>$pw ); die $ldapMsg->error if $ldapMsg->is_error; #print "$ldapMsg->is_error \n"; $mesg = $ldap->search(filter => "HSS-PrivateUserID=sip:$subscriber +\@sprint.com", base => $LDAP_BASE, scope => "sub" ); @result = $mesg->entries; foreach $entry (@result) { #print "dn: " . $entry->dn() . "\n"; @attrs = $entry->attributes(); foreach $attr (@attrs) { if ($attr =~ /HSS-PrivateUserID/ ){ printf("\t%s: %s\n", $attr, $entry->get_value($attr)); } } } $mesg = $ldap->search(filter => "HSS-PublicIdValue=sip:$subscriber +\@sprint.com", base => $LDAP_BASE, scope => "sub" ); @result = $mesg->entries; foreach $entry (@result) { #print "dn: " . $entry->dn() . "\n"; @attrs = $entry->attributes(); foreach $attr (@attrs) { if ($attr eq 'HSS-PublicIdValue' ){ printf("\t%s: %s\n", $attr, $entry->get_value($attr)); } } } print "\n"; }

Replies are listed 'Best First'.
Re: Ldap search is hanging
by Anonymous Monk on Oct 14, 2008 at 21:52 UTC
    Try adding to search timelimit argument
    timelimit => N
    A timelimit that restricts the maximum time (in seconds) allowed for a search. A value of 0 (the default), means that no timelimit will be requested.
      I added timelimit argument in the search method but it still is taking 13 minutes to comeback with no entries. I thought that the argument name may be different so tried timeout => 10 and seconds => 10. All these did not work.