LDIF 파일에서 LDAP 서버로 대량 가져 오기를 수행 할 수 있기를 원합니다. 언 바운드 ID LDAP SDK를 사용하는 작업 구현 (아래)이 있습니다. 이 문제는 LDIF의 각 항목을 반복하며 큰 파일 (수백만 개의 항목)에 대해 매우 느릴 수 있습니다. 고속 가져 오기에 사용할 수있는 도구/SDK가 있습니까? 이 프로그래밍 방식으로 달성 할 수 있어야합니다 (선호 자바). 감사!프로그래밍 방식으로 LDIF 대량 가져 오기
public static void importLdif(){
try{
LDAPConnection connection = new LDAPConnection("ldapserver.com", 389,
"uid=admin,ou=system", "secret");
LDIFReader ldifReader = new LDIFReader("C:/Users/ejamcud/Desktop/LDAP/ldifs/Sailors.ldif");
int entriesRead = 0;
int entriesAdded = 0;
int errorsEncountered = 0;
Entry entry;
LDAPResult addResult;
while (true)
{
try
{
entry = ldifReader.readEntry();
if (entry == null)
{
System.out.println("All entries have been read.");
break;
}
entriesRead++;
}
catch (LDIFException le)
{
errorsEncountered++;
if (le.mayContinueReading())
{
// A recoverable error occurred while attempting to read a change
// record, at or near line number le.getLineNumber()
// The entry will be skipped, but we'll try to keep reading from the
// LDIF file.
continue;
}
else
{
// An unrecoverable error occurred while attempting to read an entry
// at or near line number le.getLineNumber()
// No further LDIF processing will be performed.
break;
}
}
catch (IOException ioe)
{
// An I/O error occurred while attempting to read from the LDIF file.
// No further LDIF processing will be performed.
errorsEncountered++;
break;
}
try
{
addResult = connection.add(entry);
// If we got here, then the change should have been processed
// successfully.
System.out.println(entry.toLDIFString());
entriesAdded++;
}
catch (LDAPException le)
{
// If we got here, then the change attempt failed.
le.printStackTrace();
addResult = le.toLDAPResult();
errorsEncountered++;
}
}
}catch(IOException ioe){
ioe.printStackTrace();
}
catch(LDAPException lde){
lde.printStackTrace();
}finally{
//ldifReader.close();
}
}
준수하는 LDAP 서버와 함께 OpenLDAP 클라이언트 도구를 사용할 수 있습니다. – EJP