如果使用JNDI:
Attributes attrs= new BasicAttributes(true);
attrs.put( "seeAlso", "....");
ctx.modifyAttribute( dn, DirContext.REMOVE_ATTRIBUTE, attrs);
...
Attributes attrs= new BasicAttributes(true);
attrs.put( "seeAlso", "....");
ctx.modifyAttribute( dn, DirContext.REMOVE_ATTRIBUTE, attrs);
...
Attribute ae = attrs.get("seeAlso");
Object object = null;
if(ae!=null){
NamingEnumeration ne = ae.getAll();
while(ne.hasMore()){
object = ne.next();
.....//定位你要删除的值,如果找到
break;
}
}
if(object!=null)
ae.remove(object);
我的方法可以对指定的属性值进行删除操作,你可以试一下。
如果需要修改,可以先删除该值,然后再添加新值。如果属性数目不多的话,可以取出Attribute,然后替换需要修改的Attribute Value,再一次将这些属性更新到LDAP中。不过这样对不同的LDAP来说可能会有些问题……