2013-07-25 63 views
3

我從LDAP服務器導出以下ldif文件,我現在試圖導入它,這樣我可以複製我出口其從目錄中:使用如何使用unboundid-ldap-sdp導入ldif文件?

dn: cn=MYCOMPANY Users,dc=mycompany,dc=com 
changetype: add 
objectClass: posixGroup 
objectClass: top 
cn: MYCOMPANY Users 
gidNumber: 1001 

dn: cn=jim smith,cn=MYCOMPANY Users,dc=mycompany,dc=com 
objectClass: inetOrgPerson 
objectClass: posixAccount 
objectClass: top 
givenName: jim 
cn: jim smith 
sn: smith 
gidNumber: 1000 
homeDirectory: /home/users/arolls 
uid: jsmith 
uidNumber: 1038 
userPassword: {MD5}X03MO1qnZdYdgyfeuILPmQ== 

dn: cn=dave jones,cn=MYCOMPANY Users,dc=mycompany,dc=com 
objectClass: inetOrgPerson 
objectClass: posixAccount 
objectClass: top 
givenName: dave 
userPassword: {MD5}FhCDh0PMkOPk/dp0goLZuA== 
loginShell: /bin/sh 
cn: dave jones 
sn: dave 
gidNumber: 1000 
homeDirectory: /home/users/dave 
uid: dave 
uidNumber: 1006 

我試圖將其導入

LDIFReader r = new LDIFReader(resourceAsStream); 
LDIFChangeRecord readEntry = null; 
while ((readEntry = r.readChangeRecord()) != null) { 
    readEntry.processChange(server); 
} 

我收到以下錯誤,有人會知道我在做什麼錯嗎?

LDAPException(resultCode=65 (object class violation), errorMessage='Unable to add entry 'cn=MYCOMPANY Users,dc=mycompany,dc=com' because it violates the provided schema: The entry contains object class posixGroup which is not defined in the schema. The entry contains attribute cn which is not allowed by its object classes and/or DIT content rule. The entry contains attribute gidNumber which is not defined in the schema. The entry's RDN contains attribute cn which is not allowed to be included in the entry.', diagnosticMessage='Unable to add entry 'cn=MYCOMPANY Users,dc=mycompany,dc=com' because it violates the provided schema: The entry contains object class posixGroup which is not defined in the schema. The entry contains attribute cn which is not allowed by its object classes and/or DIT content rule. The entry contains attribute gidNumber which is not defined in the schema. The entry's RDN contains attribute cn which is not allowed to be included in the entry.') 

at com.unboundid.ldap.listener.InMemoryDirectoryServer.add(InMemoryDirectoryServer.java:1382) 
at com.unboundid.ldif.LDIFAddChangeRecord.processChange(LDIFAddChangeRecord.java:213) 
at com.github.trevershick.test.ldap.LdapServerResource.loadLdifFiles(LdapServerResource.java:156) 
at com.github.trevershick.test.ldap.LdapServerResource.start(LdapServerResource.java:81) 
at org.rory.util.services.ldap.TestLDAPAuthUIUtilUsingInMemoryLdapServer.startup(TestLDAPAuthUIUtilUsingInMemoryLdapServer.java:42) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) 
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) 
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 
java.lang.NullPointerException 
at org.rory.util.services.ldap.TestLDAPAuthUIUtilUsingInMemoryLdapServer.shutdown(TestLDAPAuthUIUtilUsingInMemoryLdapServer.java:47) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) 
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) 
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 

非常感謝!

回答

0

在您的目錄服務器模式中找不到objectClass posixGroupposixGroupRFC 2307-bis定義。您需要將該objectClass及其關聯的屬性添加到模式,然後添加您的LDIF更改記錄。

+0

謝謝你,所以你知道如何使用unboundid它添加到模式-ldap-SDK? – user2586917

+0

這取決於正在使用的服務器。如果服務器支持模式的LDAP後端,則可以使用「ModifyRequest」來添加模式。 –