Skip to content

Commit 6672cf8

Browse files
author
Carl Schwan
committed
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 <[email protected]>
1 parent 64c5200 commit 6672cf8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

apps/user_ldap/lib/LoginListener.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use OCA\User_LDAP\Db\GroupMembership;
1212
use OCA\User_LDAP\Db\GroupMembershipMapper;
13+
use OCP\Authentication\IApacheBackend;
1314
use OCP\DB\Exception;
1415
use OCP\EventDispatcher\Event;
1516
use OCP\EventDispatcher\IEventDispatcher;
@@ -49,6 +50,10 @@ public function onPostLogin(IUser $user): void {
4950
]
5051
);
5152
$this->updateGroups($user);
53+
$backend = $user->getBackend();
54+
if ($backend instanceof IApacheBackend) {
55+
$backend->loginName2UserName($user->getUID(), true);
56+
}
5257
}
5358

5459
private function updateGroups(IUser $userObject): void {

apps/user_ldap/lib/User_Proxy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ public function checkPassword($uid, $password) {
221221
* @param string $loginName
222222
* @return string|false
223223
*/
224-
public function loginName2UserName($loginName) {
224+
public function loginName2UserName($loginName, bool $forceLdapRefetch = false) {
225225
$id = 'LOGINNAME,' . $loginName;
226-
return $this->handleRequest($id, 'loginName2UserName', [$loginName]);
226+
return $this->handleRequest($id, 'loginName2UserName', [$loginName, $forceLdapRefetch]);
227227
}
228228

229229
/**

0 commit comments

Comments
 (0)