Java Netscape LDAP 删除一个属性

标签 java ldap attributes netscape

我有 LDAP 架构,用户在哪里。我需要删除一个名为“notify”的属性,其值是:电话号码或邮件,或者删除用户的属性。我找到了方法

LDAPConnection myCon = new LDAPConnection("localhost",389);
myCon.delete("uid=test1, ou=People, o=domain.com, o=isp");

但这会删除整个用户,我只需要删除该用户的一个属性“notifyTo”。我需要删除整个属性,而不仅仅是其值。

谢谢回复

最佳答案

您需要调用modify method on LDAPConnection class :-)

来自 javadoc:

public void modify(java.lang.String DN, LDAPModification mod) throws LDAPException Makes a single change to an existing entry in the directory (for example, changes the value of an attribute, adds a new attribute value, or removes an existing attribute value). Use the LDAPModification object to specify the change to make and the LDAPAttribute object to specify the attribute value to change. The LDAPModification object allows you add an attribute value, change an attibute value, or remove an attribute value.

For example, the following section of code changes Barbara Jensen's email address in the directory to babs@aceindustry.com.

来自 javadocs 的示例代码:

String myEntryDN = "cn=Barbara Jensen,ou=Product Development,o=Ace Industry,c=US";
LDAPAttribute attrEmail = new LDAPAttribute( "mail", "babs@aceindustry.com" );
LDAPModification singleChange = new LDAPModification( LDAPModification.REPLACE, attrEmail );

myConn.modify( myEntryDN, singleChange );

此示例用于删除条目属性之一的一个值。您需要删除所有值:-)

关于Java Netscape LDAP 删除一个属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2585639/

相关文章:

Python Selenium 'WebDriver' object has no attribute 错误

ldap - 什么是 LDAP 以及何时考虑在 Web 应用程序中使用它?

c# - 如何使用 ResourceExposureAttribute 和 ResourceConsumptionAttribute?

java - MongoDb - 如果集合不存在,则自动更新集合

java - 处理 Kafka Broker 宕机时的故障

java - 如何检查下拉框selenium java上设置的值

java - 将 Lucene 库导入 NetBeans

php - 无法启用 PHP LDAP,即使我已经编辑了 php.ini 并且 php_ldap.dll 位于正确的位置?

spring - Grails Spring安全性和LDAP身份验证失败

Magento - 创建新的客户属性