diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2021-10-12 12:38:00 +0200 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2021-10-19 09:24:54 +0000 |
commit | 2f5dd75b5551a7be656e5b45e3e1658d7eccd7c1 (patch) | |
tree | 577455f96b8f0a4315aa7bce58749722952d58da /apps | |
parent | 903afc13111794ec2748a5290b22038825bbdc1f (diff) | |
download | nextcloud-server-2f5dd75b5551a7be656e5b45e3e1658d7eccd7c1.tar.gz nextcloud-server-2f5dd75b5551a7be656e5b45e3e1658d7eccd7c1.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')
-rw-r--r-- | apps/user_ldap/lib/Access.php | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php index 862089e9d30..370a4440501 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -552,7 +552,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; } @@ -563,6 +563,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; |