Fix an infinite loop in getting LDAP error messages. Fixes bug #11296

This commit is contained in:
Colin Kuskie 2009-12-07 18:43:09 -08:00
parent c845849da0
commit 7261ecd29d
4 changed files with 15 additions and 13 deletions

View file

@ -107,9 +107,10 @@ sub connectToLDAP {
$self->{_uri} = $uri;
my $ldap = Net::LDAP->new($uri->host,
port => $uri->port, #Port will default to 389 or 636
scheme => $uri->scheme
scheme => $uri->scheme,
timeout => 15,
);
unless($ldap) {
$self->{_error} = 103;
return undef;
@ -167,7 +168,7 @@ A valid ldap error code.
sub getErrorMessage {
my $self = shift;
my $errorCode = shift || $self->getErrorMessage;
my $errorCode = shift || $self->getErrorCode;
return "" unless $errorCode;
my $i18nCode = "LDAPLink_".$errorCode;
my $i18n = WebGUI::International->new($self->session,"AuthLDAP");
@ -231,9 +232,7 @@ Disconnect cleanly from the current databaseLink.
=cut
sub unbind {
my ($self, $value);
$self = shift;
$value = shift;
my $self = shift;
if (defined $self->{_connection}) {
$self->{_connection}->unbind;
}

View file

@ -380,13 +380,14 @@ sub www_listLDAPLinks {
my $ldapLink = WebGUI::LDAPLink->new($session,$data->{ldapLinkId});
my $status = $i18n->get("LDAPLink_1078");
if ($ldapLink->bind && $ldapLink->getErrorCode == 0) {
$status = $i18n->get("LDAPLink_1079");
} else {
$session->errorHandler->warn($ldapLink->getErrorMessage());
if ($ldapLink->bind && $ldapLink->getErrorCode == 0) {
$status = $i18n->get("LDAPLink_1079");
$ldapLink->unbind;
}
else {
$session->errorHandler->warn($ldapLink->getErrorMessage());
$status .= ": ".$ldapLink->getErrorMessage();
}
$ldapLink->unbind;
}
$row[$i] .= '<td valign="top" class="tableData">'.$status.'</td>';
$row[$i] .= '</tr>';
$i++;