From 6672cf8a9a2b61caa73be5a318932515c2c5536a Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Mon, 18 Aug 2025 15:05:25 +0200 Subject: [PATCH] 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 --- apps/user_ldap/lib/LoginListener.php | 5 +++++ apps/user_ldap/lib/User_Proxy.php | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/user_ldap/lib/LoginListener.php b/apps/user_ldap/lib/LoginListener.php index f397f4694d2..cef4219c5fd 100644 --- a/apps/user_ldap/lib/LoginListener.php +++ b/apps/user_ldap/lib/LoginListener.php @@ -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 { diff --git a/apps/user_ldap/lib/User_Proxy.php b/apps/user_ldap/lib/User_Proxy.php index 0d41f495ce9..4164a3e3581 100644 --- a/apps/user_ldap/lib/User_Proxy.php +++ b/apps/user_ldap/lib/User_Proxy.php @@ -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]); } /**