diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2021-10-12 13:38:00 +0300 |
---|---|---|
committer | blizzz (Rebase PR Action) <blizzz@users.noreply.github.com> | 2021-10-29 12:03:12 +0300 |
commit | 355bf525082c80343dde27d6630c20ec45a8d1d9 (patch) | |
tree | 9f7e7d46e392b6ce4f6a68d55da3ef45fc2ca113 /apps | |
parent | e48efef3516355c5d8e76c185ad4c8b0a6f3c0eb (diff) |
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 222443cfa8e..93f1281f065 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -555,7 +555,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; } @@ -566,6 +566,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; |