Skip to content
Snippets Groups Projects
Commit 565b6c6f authored by Philippe Larose's avatar Philippe Larose
Browse files

ad-connector: fix user revocation

fixing a bug where users that should not be revoked are getting revoked
automatically with Active Directory
Ticket: https://redmine.savoirfairelinux.com/issues/7520

Change-Id: Icb7a0292eb195cdab6dec1af642211ca1ee69f09
parent a2ababcf
Branches
Tags
No related merge requests found
......@@ -133,20 +133,6 @@ public class UserProfileService {
results.stream()
.map(UserProfileService::profileFromResponse)
.collect(Collectors.toList());
// There is a use case where a user is not in the LDAP directory but is in the database.
// When this happens, we need to revoke the user from the database.
List<UserProfile> profilesFromDatabase =
dataStore.getUserProfileDao().getAllUserProfile();
for (UserProfile p : profilesFromDatabase) {
if (profilesFromResponse.stream()
.noneMatch(r -> r.getUsername().equals(p.getUsername()))) {
RevokeUserFlow.revokeUser(p.getUsername());
// We also remove the user from the local_directory table to avoid duplicate
// revocations
dataStore.getUserProfileDao().deleteUserProfile(p.getUsername());
}
}
// Inserts the newly added profiles into the database.
for (UserProfile p : profilesFromResponse) {
dataStore.getUserProfileDao().insertIfNotExists(p);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment