Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Avoid PHP errors when the LDAP attribute is not found
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc authored and blizzz committed Oct 29, 2021
commit 355bf525082c80343dde27d6630c20ec45a8d1d9
6 changes: 5 additions & 1 deletion apps/user_ldap/lib/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ public function dn2ocname($fdn, $ldapName = null, $isUser = true, &$newlyMapped

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;
}
Expand All @@ -566,6 +566,10 @@ public function dn2ocname($fdn, $ldapName = null, $isUser = true, &$newlyMapped
$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;
Expand Down