Project

General

Profile

« Previous | Next » 

Revision 4845

Added by daigle about 15 years ago

Do not try to use non-existant ldap object if ldap server is down.

View differences:

src/perl/ldapweb.cgi
674 674
    #if main ldap server is down, a html file containing warning message will be returned
675 675
    debug("connecting to LDAP in findExistingAccounts with settings $ldapurl, $timeout");
676 676
    $ldap = Net::LDAP->new($ldapurl, timeout => $timeout) or handleLDAPBindFailure($ldapurl);
677
    $ldap->start_tls( verify => 'none');
678
    $ldap->bind( version => 3, anonymous => 1);
679
    my $mesg = $ldap->search (
680
        base   => $base,
681
        filter => $filter,
682
        attrs => @$attref,
683
    );
677
    if ($ldap) {
678
    	$ldap->start_tls( verify => 'none');
679
    	$ldap->bind( version => 3, anonymous => 1);
680
		my $mesg = $ldap->search (
681
			base   => $base,
682
			filter => $filter,
683
			attrs => @$attref,
684
		);
684 685

  
685
    if ($mesg->count() > 0) {
686
        $foundAccounts = "";
687
        my $entry;
688
        foreach $entry ($mesg->all_entries) { 
689
            $foundAccounts .= "<p>\n<b><u>Account:</u> ";
690
            $foundAccounts .= $entry->dn();
691
            $foundAccounts .= "</b><br />\n";
692
            foreach my $attribute ($entry->attributes()) {
693
                $foundAccounts .= "$attribute: ";
694
                $foundAccounts .= $entry->get_value($attribute);
695
                $foundAccounts .= "<br />\n";
696
            }
697
            $foundAccounts .= "</p>\n";
686
	    if ($mesg->count() > 0) {
687
			$foundAccounts = "";
688
			my $entry;
689
			foreach $entry ($mesg->all_entries) { 
690
				$foundAccounts .= "<p>\n<b><u>Account:</u> "
691
				$foundAccounts .= $entry->dn();
692
				$foundAccounts .= "</b><br />\n";
693
				foreach my $attribute ($entry->attributes()) {
694
					$foundAccounts .= "$attribute: ";
695
					$foundAccounts .= $entry->get_value($attribute);
696
					$foundAccounts .= "<br />\n";
697
				}
698
				$foundAccounts .= "</p>\n";
699
			}
698 700
        }
701
    	$ldap->unbind;   # take down session
699 702
    }
700
    $ldap->unbind;   # take down session
701 703

  
702 704
    # Follow references
703 705
    my @references = $mesg->references();

Also available in: Unified diff