summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2021-10-12 12:38:00 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2021-10-12 12:44:26 +0200
commit437048e9b6e56dcc8915839d8383edac3819c692 (patch)
treecbed5c15fb369e7608562a48bcb73fd5e707bdc0 /apps/user_ldap/lib
parentda1b97decda88893cc26539439a15050953419ae (diff)
downloadnextcloud-server-437048e9b6e56dcc8915839d8383edac3819c692.tar.gz
nextcloud-server-437048e9b6e56dcc8915839d8383edac3819c692.zip
Avoid PHP errors when the LDAP attribute is not found
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/Access.php6
1 files changed, 5 insertions, 1 deletions
diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php
index 14178023e12..cd13a3c49b3 100644
--- a/apps/user_ldap/lib/Access.php
+++ b/apps/user_ldap/lib/Access.php
@@ -551,7 +551,7 @@ class Access extends LDAPUtility {
if (is_null($ldapName)) {
$ldapName = $this->readAttribute($fdn, $nameAttribute, $filter);
- if (!isset($ldapName[0]) && empty($ldapName[0])) {
+ if (!isset($ldapName[0]) || empty($ldapName[0])) {
\OCP\Util::writeLog('user_ldap', 'No or empty name for ' . $fdn . ' with filter ' . $filter . '.', ILogger::DEBUG);
return false;
}
@@ -562,6 +562,10 @@ class Access extends LDAPUtility {
$usernameAttribute = (string)$this->connection->ldapExpertUsernameAttr;
if ($usernameAttribute !== '') {
$username = $this->readAttribute($fdn, $usernameAttribute);
+ if (!isset($username[0]) || empty($username[0])) {
+ \OCP\Util::writeLog('user_ldap', 'No or empty username (' . $usernameAttribute . ') for ' . $fdn . '.', ILogger::DEBUG);
+ return false;
+ }
$username = $username[0];
} else {
$username = $uuid;