Merge pull request #49404 from Thatoo/Thatoo-patch-1

fix(user_ldap): retrieve from LDAP first "email shaped" value instead…
This commit is contained in:
Arthur Schiwon 2024-12-05 14:23:19 +01:00 committed by GitHub
commit c9073f7ab7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -154,7 +154,14 @@ class User {
//change event that will trigger fetching the display name again
$attr = strtolower($this->connection->ldapEmailAttribute);
if (isset($ldapEntry[$attr])) {
$this->updateEmail($ldapEntry[$attr][0]);
$mailValue = 0;
for ($x = 0; $x < count($ldapEntry[$attr]); $x++) {
if (filter_var($ldapEntry[$attr][$x], FILTER_VALIDATE_EMAIL)) {
$mailValue = $x;
break;
}
}
$this->updateEmail($ldapEntry[$attr][$mailValue]);
}
unset($attr);