简体   繁体   English

Java JNDI删除整个LDAP子树

[英]Java JNDI Delete entire LDAP subtree

I need to delete entire LDAP subtree, by Java code, like the -r parameter of ldapdelete command. 我需要通过Java代码删除整个LDAP子树,例如ldapdelete命令的-r参数。 How can I do that? 我怎样才能做到这一点? Is there a simple way to delete entire LDAP subtree with JNDI? 有没有一种简单的方法可以使用JNDI删除整个LDAP子树?

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

Usually deleting entire subtrees in LDAP is something you do only in tests... 通常,仅在测试中才能删除LDAP中的整个子树。

Anyway,there's a utility class in spring-Ldap test utils called LdaptestUtils that does just what you want. 无论如何,spring-Ldap测试实用程序中有一个实用程序类,称为LdaptestUtils,可以满足您的需求。 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 看看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). 相关的方法名称为clearSubContexts()(请注意重载)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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