fix(user_ldap): retrieve from LDAP first "email shaped" value instead of first value

Signed-off-by: Thatoo <Thatoo@users.noreply.github.com>
This commit is contained in:
Thatoo 2024-11-20 16:55:44 +01:00 committed by GitHub
parent 3822db5174
commit 486f0eda71
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);