Java LDAP替换一个属性的列表值

Java LDAP替换一个属性的列表值,java,ldap,jndi,Java,Ldap,Jndi,我有一个属性,比如telephonenumber,它在一个人身上出现多次。现在,我想用一个新数字列表替换所有数字: <person> <telephonnumber>12345</telephonnumber> <telephonnumber>23456</telephonnumber> </person> 最终所有值都将替换为最后一个ModificationItem。我可以通过删除所有数字,并从列表中添加

我有一个属性,比如
telephonenumber
,它在一个人身上出现多次。现在,我想用一个新数字列表替换所有数字:

<person>  
<telephonnumber>12345</telephonnumber>  
<telephonnumber>23456</telephonnumber>  
</person>  

最终所有值都将替换为最后一个ModificationItem。我可以通过删除所有数字,并从列表中添加所有新值来解决这个问题。但是我认为JavaLDAP直接支持它。

您希望创建一个替换为多值电话属性。看


提示:在开始编码之前,首先通过文件尝试LDAP操作。

您想用多值电话属性创建一个单个替换。看

提示:在开始编码之前,首先通过文件尝试LDAP操作

<person>  
<telephonnumber>56789</telephonnumber>  
<telephonnumber>78901</telephonnumber>  
</person>  
mods.add(new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("telephonnumber", "56789")));  
mods.add(new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("telephonnumber", "78901")));  
// Create a multivalued attribute that has four String values
BasicAttribute oc = new BasicAttribute("objectClass", "top");
oc.add("person");
oc.add("organizationalPerson");
oc.add("inetOrgPerson");