You are not logged in.
Pages: 1
Hello,
In the ldapimport.groovy, when the users in the "external" OrganisationUnit are not to be, the script removes them with no parent but they still exists
In the script, we find:
if(null != current.getOrigin() && current.getOrigin().startsWith(providerUrl) && !nodesInDirectoryByGuid.containsKey(current.getGuid())){
current.getParent().removeChild(current);
removedNodes.add(current);
}
The problem is that those users still exist for ldap identification.
We can see them by clicking on + in users management, they are out of User Root.
How can we delete them and what must be the change in the script to delete them instead of remove them.
Thanks
Offline
Hi Stéphane,
this seems to be a bug in the script, we are currently working on it. Basically, the bugfix is the following:
//current.getParent().removeChild(current);
userManagerService.forceRemove(current);
Does this work for you ?
Regards,
Eduardo
Offline
Hello,
it doesn't work for the users removed with no parent
I try this to delete them:
userManagerService.getAllUsers().each{
if (it.getParent()==null) {
it.setWriteProtection(false);
tout.println(it.getUsername());
userManagerService.forceRemove(it);
}
}
no error but not deleted
certainly a userManagerService.persist but on which node ?
Offline
Hi Stéphane,
the bugfix I sent was for modifying the ldapimport script, for next users deleted to be deleted correctly.
The users already (incorrectly) deleted have to be removed manually.
You can use these scripts for this:
Show users directly under root:
import java.util.Map.Entry
import java.util.logging.Level
import java.util.logging.Logger
import net.datenwerke.security.service.usermanager.UserManagerService
import net.datenwerke.security.service.usermanager.entities.AbstractUserManagerNode
import net.datenwerke.security.service.usermanager.entities.Group
import net.datenwerke.security.service.usermanager.entities.OrganisationalUnit
import net.datenwerke.security.service.usermanager.entities.User
UserManagerService userManagerService = GLOBALS.getRsService(UserManagerService.class);
Logger logger = Logger.getLogger(getClass().getName());
List<AbstractUserManagerNode> umRoots = userManagerService.getRoots();
for (AbstractUserManagerNode rootNode: umRoots) {
logger.log(Level.SEVERE, rootNode.getName() + ": " + rootNode);
}
For actually deleting these users:
import java.util.Map.Entry
import java.util.logging.Level
import java.util.logging.Logger
import net.datenwerke.security.service.usermanager.UserManagerService
import net.datenwerke.security.service.usermanager.entities.AbstractUserManagerNode
import net.datenwerke.security.service.usermanager.entities.Group
import net.datenwerke.security.service.usermanager.entities.OrganisationalUnit
import net.datenwerke.security.service.usermanager.entities.User
UserManagerService userManagerService = GLOBALS.getRsService(UserManagerService.class);
Logger logger = Logger.getLogger(getClass().getName());
List<AbstractUserManagerNode> umRoots = userManagerService.getRoots();
for (AbstractUserManagerNode rootNode: umRoots) {
System.out.println(rootNode.getName() + ": " + rootNode);
if (rootNode.getName().equals("User Root")) {
logger.log(Level.SEVERE, "CLEANING: skipping: " + rootNode.getName());
continue;
}
logger.log(Level.SEVERE, "CLEANING: deleting: " + rootNode.getName());
rootNode.setWriteProtection(false);
userManagerService.remove(rootNode);
}
If you include the bugfix userManagerService.forceRemove(current); into your ldapimport script, this should work as expected for next users being deleted.
Can you please confirm this?
Regards,
Eduardo
Offline
Thanks Eduardo,
it was OK to delete users with no parent. (very well)
for the ldapimport.groovy, the userManagerService was not known in the class and the users were write protected so i did that and it's ok:
//current.getParent().removeChild(current);
current.setWriteProtection(false);
getUserManagerService().forceRemove(current); //userManagerService was set as private in the class and setter and getter were added
Regards
Stéphane
Last edited by Stéphane (2020-12-10 15:49:47)
Offline
Pages: 1