开发者

Java JNDI Delete entire LDAP subtree

I nee开发者_运维技巧d to delete entire LDAP subtree, by Java code, like the -r parameter of ldapdelete command. How can I do that? Is there a simple way to delete entire LDAP subtree with JNDI?


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).


You need to use the javax.naming.ldap.TreeDelete control, if your server supports it, otherwise you have no choice but to do it by hand, depth-first.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜