Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync LDAP user with non-auto provisioning #535

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ private function provisionUser(string $userId, int $providerId, object $idTokenP
// in case user is provisioned by user_ldap, userManager->search() triggers an ldap search which syncs the results
// so new users will be directly available even if they were not synced before this login attempt
$this->userManager->search($userId);
$this->ldapService->syncUser($userId);
// when auto provision is disabled, we assume the user has been created by another user backend (or manually)
$user = $this->userManager->get($userId);
if ($this->ldapService->isLdapDeletedUser($user)) {
Expand Down
16 changes: 16 additions & 0 deletions lib/Service/LdapService.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,20 @@ public function isLdapDeletedUser(IUser $user): bool {
// did we find the user in the LDAP deleted user list?
return $searchDisabledUser !== false;
}

/**
* This triggers User_LDAP::getLDAPUserByLoginName which does a LDAP query with the login filter
* so the user ID we got from the OIDC IdP should work as a login in LDAP (the login filter should use a matching attribute)
* @param string $userId
* @return void
*/
public function syncUser(string $userId): void {
try {
/** @var \OCA\User_LDAP\User_Proxy */
$ldapUserProxy = \OC::$server->get(\OCA\User_LDAP\User_Proxy::class);
$ldapUserProxy->loginName2UserName($userId);
} catch (QueryException $e) {
$this->logger->debug('\OCA\User_LDAP\User_Proxy class not found');
}
}
}