From 24fde58d66cbe2d19b9d1c9f17d92efafb744f2e Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Fri, 20 Apr 2018 11:57:34 +0200 Subject: [PATCH] OO-3447: filter the permanent user in the delete process of the LDAP administration --- .../org/olat/ldap/manager/LDAPLoginManagerImpl.java | 5 +++++ .../java/org/olat/ldap/ui/LDAPAdminController.java | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/main/java/org/olat/ldap/manager/LDAPLoginManagerImpl.java b/src/main/java/org/olat/ldap/manager/LDAPLoginManagerImpl.java index b3c750edf39..20b77febcf3 100644 --- a/src/main/java/org/olat/ldap/manager/LDAPLoginManagerImpl.java +++ b/src/main/java/org/olat/ldap/manager/LDAPLoginManagerImpl.java @@ -432,6 +432,11 @@ public class LDAPLoginManagerImpl implements LDAPLoginManager, GenericEventListe SecurityGroup secGroup = securityManager.findSecurityGroupByName(LDAPConstants.SECURITY_GROUP_LDAP); for (Identity identity: identityList) { + if(Identity.STATUS_PERMANENT.equals(identity.getStatus())) { + log.audit(identity.getKey() + " was not deleted because is status is permanent."); + continue; + } + securityManager.removeIdentityFromSecurityGroup(identity, secGroup); userDeletionManager.deleteIdentity(identity); dbInstance.intermediateCommit(); diff --git a/src/main/java/org/olat/ldap/ui/LDAPAdminController.java b/src/main/java/org/olat/ldap/ui/LDAPAdminController.java index a336a196d8f..2b11f3440b9 100644 --- a/src/main/java/org/olat/ldap/ui/LDAPAdminController.java +++ b/src/main/java/org/olat/ldap/ui/LDAPAdminController.java @@ -21,6 +21,7 @@ package org.olat.ldap.ui; import java.text.DateFormat; import java.util.Date; +import java.util.Iterator; import java.util.List; import javax.naming.NamingException; @@ -174,6 +175,15 @@ public class LDAPAdminController extends BasicController implements GenericEvent showError("delete.error.connection.close"); logError("Could not close LDAP connection on manual delete sync", e); } + + if (identitiesToDelete != null) { + for(Iterator<Identity> it=identitiesToDelete.iterator(); it.hasNext(); ) { + if(Identity.STATUS_PERMANENT.equals(it.next().getStatus())) { + it.remove(); + } + } + } + if (identitiesToDelete != null && identitiesToDelete.size() != 0) { hasIdentitiesToDelete = true; /* @@ -184,6 +194,7 @@ public class LDAPAdminController extends BasicController implements GenericEvent * wizard finish callback called after "finish" is called */ StepRunnerCallback finishCallback = new StepRunnerCallback() { + @Override public Step execute(UserRequest uureq, WindowControl control, StepsRunContext runContext) { hasIdentitiesToDeleteAfterRun = ((Boolean) runContext.get("hasIdentitiesToDelete")).booleanValue(); if (hasIdentitiesToDeleteAfterRun) { -- GitLab