fix(ldap): Refresh user ldap attributes on login

Otherwise when authentificating via SAML an user in the LDAP database,
this is not done.

Signed-off-by: Carl Schwan <carl.schwan@nextclound.com>
This commit is contained in:
Carl Schwan 2025-08-18 15:05:25 +02:00
parent 64c52006dd
commit 6672cf8a9a
2 changed files with 7 additions and 2 deletions

View file

@ -10,6 +10,7 @@ namespace OCA\User_LDAP;
use OCA\User_LDAP\Db\GroupMembership;
use OCA\User_LDAP\Db\GroupMembershipMapper;
use OCP\Authentication\IApacheBackend;
use OCP\DB\Exception;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
@ -49,6 +50,10 @@ class LoginListener implements IEventListener {
]
);
$this->updateGroups($user);
$backend = $user->getBackend();
if ($backend instanceof IApacheBackend) {
$backend->loginName2UserName($user->getUID(), true);
}
}
private function updateGroups(IUser $userObject): void {

View file

@ -221,9 +221,9 @@ class User_Proxy extends Proxy implements IUserBackend, UserInterface, IUserLDAP
* @param string $loginName
* @return string|false
*/
public function loginName2UserName($loginName) {
public function loginName2UserName($loginName, bool $forceLdapRefetch = false) {
$id = 'LOGINNAME,' . $loginName;
return $this->handleRequest($id, 'loginName2UserName', [$loginName]);
return $this->handleRequest($id, 'loginName2UserName', [$loginName, $forceLdapRefetch]);
}
/**