开发者

Java JNDI Delete entire LDAP subtree

开发者 https://www.devze.com 2023-01-18 14:43 出处:网络
I nee开发者_运维技巧d to delete entire LDAP subtree, by Java code, like the -r parameter of ldapdelete command. How can I do that?

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

精彩评论

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