From 355bf525082c80343dde27d6630c20ec45a8d1d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 12 Oct 2021 12:38:00 +0200 Subject: Avoid PHP errors when the LDAP attribute is not found MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/user_ldap/lib/Access.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'apps') 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; -- cgit v1.2.3