You are not logged in.
Pages: 1
Hi
I have accidentally imported my AD into root folder so i have alot of OUs that are empty, but cant remove them as i get a message saying "root cannot be deleted"
I cant find them with the terminal that will not list them.
What can i do to clean up this mess.
Offline
Hi Dennis,
you will need to use a bit of scripting for this. Do you have the IDs of the "root" folders that you want to delete? If so, you should be able to do so with the following script:
import net.datenwerke.security.service.usermanager.entities.OrganisationalUnit;
import net.datenwerke.security.service.usermanager.UserManagerService;
def ouID = 236082L; // note the L to ensure it is treated as Long
def userService = GLOBALS.getInstance(UserManagerService.class);
def ou = GLOBALS.findEntity(OrganisationalUnit.class, ouID);
userService.forceRemove(ou);
"deleted " + ouID
This should bypass the check whether or not the node to be deleted is a "root" node.
Regards,
Arno
Offline
Hi Arno
Just tried with 1 of the IDs and get an error in line 10, that will be "userServer.forceRemove(ou);
Script execution failed.
error message: No signature of method: net.datenwerke.security.service.usermanager.UserManagerServiceImpl$$EnhancerByGuice$$980d92f3.ForceRemove() is applicable for argument types: (net.datenwerke.security.service.usermanager.entities.OrganisationalUnit) values: [net.datenwerke.security.service.usermanager.entities.OrganisationalUnit@7132]
Possible solutions: forceRemove(net.datenwerke.treedb.service.treedb.AbstractNode), forceRemove(net.datenwerke.treedb.service.treedb.AbstractNode), forceRemove(net.datenwerke.security.service.treedb.entities.SecuredAbstractNode), forceRemove(net.datenwerke.security.service.usermanager.entities.AbstractUserManagerNode), forceRemove(net.datenwerke.security.service.usermanager.entities.AbstractUserManagerNode) (groovy.lang.MissingMethodException)
script arguments:
file: DeleteOU.groovy (id: 51427, line 10)
line number: 10
line: userService.ForceRemove(ou);
Offline
I think you accidentally replaced forceRemove by ForceRemove.
Offline
I did also try with small "f" and got same error.
Offline
Could you post the error message. I am pretty sure that there must be a typo somewhere in your script.
Offline
I get the following error:
reportserver$ exec DeleteOU.groovy
Script execution failed.
error message: javax.script.ScriptException: java.lang.IllegalArgumentException: Object is write protected (java.lang.IllegalArgumentException)
script arguments:
file: DeleteOU.groovy (id: 51427, line 10)
line number: 10
line: userService.forceRemove(ou);
reportserver$
Looks like write protected
Offline
Good point. The LDAP sample script write protects any imported objects, such that they are not accidentally deleted/changed. In order to delete them, you would need to remove the write protection. Following is the adapted script, that does exactly this.
import net.datenwerke.security.service.usermanager.entities.OrganisationalUnit;
import net.datenwerke.security.service.usermanager.UserManagerService;
def ouID = 236082L; // note the L to ensure it is treated as Long
def userService = GLOBALS.getInstance(UserManagerService.class);
def ou = GLOBALS.findEntity(OrganisationalUnit.class, ouID);
/* remove write protection */
def remWP;
remWP = { node ->
node.setWriteProtection(false);
node.getChildren().each{ remWP(it) }
}
remWP(ou);
/* now that write protection is removed, nodes can be deleted */
userService.forceRemove(ou);
"deleted " + ouID
Cheers,
Arno
Offline
Now the scritp is going good and reports "deleted 28978" but to OU is still there, even after relog.
Seems like i have to reinstall the whole thing to get rid of them.
Offline
Just tried to remove the writeprotection and then manually delete it, but same result.
Offline
did you run it with the -c flag for "commit"? that is
exec -c THE_SCRIPT
Offline
Oh i missed that one.
Thanks alot now i can start deleting 200 OUs.
Offline
If you want to fiddle a bit with the script, you can also try:
userService.getRoots()
This gives you all the root nodes. But careful, this also gives you the root node that you should not delete!
Offline
Pages: 1