views:

31

answers:

1

Hi all, I need to delete entire LDAP subtree, by Java code, like the -r parameter of ldapdelete command. How can I do that? There is a simple way to delete entire LDAP subtree with JNDI?

Thanks and best regards, Roberto.

A: 

Usually deleting entire subtrees in LDAP is something you do only in tests...

Anyway,there's a utility class in spring-Ldap test utils called LdaptestUtils that does just what you want. I won't copy the code here. Take a look at http://www.jarvana.com/jarvana/view/org/springframework/ldap/spring-ldap/1.3.0.RELEASE/spring-ldap-1.3.0.RELEASE-sources.jar!/org/springframework/ldap/test/LdapTestUtils.java?format=ok

The relevant method name is clearSubContexts() (note the overloading).

Eran Harel