java - Java 中 LDAP 目录的更新插入

标签 java ldap upsert

我正在尝试使用 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/

相关文章:

java - 有没有办法将xml文件数据插入cassandra?

linux - 如何将OTRS 5与Microsoft LDAP服务器连接以进行用户身份验证?

security - Grails LDAP身份验证失败

python - 使用 python 在 Elasticsearch 中批量部分更新插入

没有添加 native 代码的 Java fatal error SIGSEGV

java - Android Joda Time,从 ISOPeriodFormat 排序字符串时遇到问题

sql - Oracle APEX - 来自 LDAP 的 LOV

mysql - 我如何更新表中的一行或如果它不存在则插入它?

node.js - 使用 MongoDB 更新插入

Java多线程: why is execution not stopping at join()?