Better handle when we can't talk to the server, log that

This commit is contained in:
Andrew Ruthven 2024-01-22 02:15:43 +13:00
parent 15e5a89675
commit e73f2d73d4

View File

@ -140,22 +140,38 @@ class ldapDriver
$ret = array(); $ret = array();
foreach($this->baseDNUsers as $baseDNUsers) { foreach($this->baseDNUsers as $baseDNUsers) {
$entry = $query($this->connect,$baseDNUsers,$this->filterUsers,$attributes); $entry = $query($this->connect, $baseDNUsers, $this->filterUsers, $attributes);
if (!ldap_first_entry($this->connect,$entry)) { if (! $entry) {
$c->messages[] = sprintf(translate('Error NoUserFound with filter >%s<, attributes >%s< , dn >%s<'),
$this->filterUsers,
join(', ', $attributes),
$baseDNUsers);
dbg_error_log('LDAP', 'Error NoUserFound with filter >%s<, attributes >%s< , dn >%s<',
$this->filterUsers,
join(', ', $attributes),
$baseDNUsers);
return $ret;
}
if (! ldap_first_entry($this->connect, $entry)) {
$c->messages[] = sprintf(translate('Error NoUserFound with filter >%s<, attributes >%s< , dn >%s<'), $c->messages[] = sprintf(translate('Error NoUserFound with filter >%s<, attributes >%s< , dn >%s<'),
$this->filterUsers, $this->filterUsers,
join(', ', $attributes), join(', ', $attributes),
$baseDNUsers); $baseDNUsers);
return $ret;
} }
$row = array(); $row = array();
for($i = ldap_first_entry($this->connect,$entry); for ($i = ldap_first_entry($this->connect,$entry);
$i && $arr = ldap_get_attributes($this->connect,$i); $i && $arr = ldap_get_attributes($this->connect,$i);
$i = ldap_next_entry($this->connect,$i) ) { $i = ldap_next_entry($this->connect,$i) ) {
$row = array(); $row = array();
for ($j=0; $j < $arr['count']; $j++) { for ($j=0; $j < $arr['count']; $j++) {
$row[$arr[$j]] = $arr[$arr[$j]][0]; $row[$arr[$j]] = $arr[$arr[$j]][0];
} }
$ret[]=$row; $ret[]=$row;
} }
} }