diff --git a/inc/drivers_ldap.php b/inc/drivers_ldap.php index ba8d549b..f087ac51 100644 --- a/inc/drivers_ldap.php +++ b/inc/drivers_ldap.php @@ -140,22 +140,38 @@ class ldapDriver $ret = array(); 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<'), $this->filterUsers, join(', ', $attributes), $baseDNUsers); + return $ret; } + $row = array(); - for($i = ldap_first_entry($this->connect,$entry); - $i && $arr = ldap_get_attributes($this->connect,$i); - $i = ldap_next_entry($this->connect,$i) ) { + for ($i = ldap_first_entry($this->connect,$entry); + $i && $arr = ldap_get_attributes($this->connect,$i); + $i = ldap_next_entry($this->connect,$i) ) { $row = array(); + for ($j=0; $j < $arr['count']; $j++) { $row[$arr[$j]] = $arr[$arr[$j]][0]; } + $ret[]=$row; } }