2013-02-26 2 views
1

Novell JLDAP 라이브러리를 사용하여 Upsert를 실행하려고하는데, 불행히도이 예제를 찾는 데 어려움이 있습니다.Java의 LDAP 디렉토리 Upsert

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에 대해 여러 명령문을 실행하지 않고 업데이트/삽입을 실행할 수 있는지 알고있는 사람 있습니까?

+0

이 스레드를 발견하셨습니까? http://stackoverflow.com/questions/389746/ldap-java-library – n1ckolas

+0

LDAP 프로토콜 자체에 결합 된 업데이트/삽입 개념이 있다고 생각하지 않으므로 라이브러리에서 수행하는 모든 작업은 돼지의 립스틱입니다. – Petesh

답변

1

Petesh는 정확했습니다. 추상화는 Novell 라이브러리 (UnboundId 라이브러리는 물론)에서 구현되었습니다. 들어온 모든 속성에 대해 Modify.REPLACE 매개 변수를 사용하여 값을 "업"할 수 있었으며 빈 값으로 null을 전달할 수있었습니다. 이렇게하면 속성을 먼저 구문 분석 할 필요없이 속성을 효과적으로 생성, 업데이트 및 삭제할 수 있습니다.

0

LDIF 파일을 통해 LDAP에서는 두 단계로 구성된 단일 이벤트가됩니다. 값 제거 및 추가. 이것은 한 행에 하나의 대시 (dash)로 표시됩니다.

나는이 라이브러리에서 어떻게 할 것인지 잘 모르겠습니다. 나는 modList.remove와 modList.add를 하나씩 시도해 보았다.