我正在尝试使用 Novell JLDAP 库执行更新插入,不幸的是,我找不到这样的示例。目前,我必须:
public EObject put(EObject eObject){
Subject s = (Subject) eObject;
//Query and grab attributes from subject
LDAPAttributes attr = resultsToAttributes(getLDAPConnection().get(s));
//No modification needed - return
if(s.getAttributes().equals(attr)){
return eObject;
} else {
//Keys:
//REPLACE,ADD,DELETE, depending on which attributes are present in the maps, I choose the operation which will be used
Map<String,LDAPAttribute> operationalMap = figureOutWhichAttributesArePresent(c.getAttributes(),attr);
//Add the Modifcations to a modification array
ArrayList<LDAPModification> modList = new ArrayList<LDAPModification>();
for(Entry entry: operationalMap.getEntrySet()){
//Specify whether it is an update, delete, or insert here. (entry.getKey());
modList.add(new LDAPModification(entry.getKey(),entry.getValue());
}
//commit
connection.modify("directorypathhere",modList.toArray(new LDAPModification[modList.size()]));
}
我不想先查询客户,这也会导致循环访问主题的属性。有人知道 JNDI 或其他库是否能够在不针对 LDAP 运行多个语句的情况下执行更新/插入吗?
最佳答案
Petesh 是正确的 - 抽象是在 Novell 库(以及 UnboundId 库)中实现的。我能够使用 Modify.REPLACE 参数为每个传入的属性“更新插入”值,并为空值传入 null。这可以有效地创建、更新和删除属性,而无需先解析它们。
关于java - Java 中 LDAP 目录的更新插入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15096558/