简体   繁体   中英

Java JNDI Delete entire LDAP subtree

I need 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?

如果服务器支持,则需要使用javax.naming.ldap.TreeDelete控件,否则只能选择深度优先手动进行操作。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM