1

プログラムでパーティションを作成しようとしています。ApacheDS Web サイト ( https://directory.apache.org/apacheds/basic-ug/1.4.3-adding-partition.html#adding-a-partition-programmatically ) の例に従ってみましたが、この例はは絶対に正しくありません。

これが私のコードです:

LdapConnection connection = new LdapNetworkConnection(host, port);     
connection.bind(admin, password);

connection.loadSchema();
SchemaManager schemaManager = connection.getSchemaManager();
Dn suffixDn = new Dn(schemaManager, "dc=newParition,dc=com");

JdbmPartition newPartition = new JdbmPartition(schemaManager);
newPartition.setId("newParition");
newPartition.setSuffixDn(suffixDn);
newPartition.setCacheSize(1000);
newPartition.setPartitionPath(new URI("file:///var/lib/apacheds-2.0.0-M15/default/partitions/newParition"));

newPartition.addIndex(new JdbmIndex("objectClass", false));
newPartition.addIndex(new JdbmIndex("dc", false));

Entry contextEntry = new DefaultEntry(schemaManager, suffixDn);
contextEntry.put("objectClass", "domain", "top");
contextEntry.put("dc", "newParition");

newPartition.initialize();
newPartition.add(new AddOperationContext(null, contextEntry)); 

contextEntry をパーティションに追加しようとすると、次のエラーが表示されます。

org.apache.directory.api.ldap.model.exception.LdapSchemaViolationException: ERR_219 Entry dc=newParition,dc=com contains no entryCsn attribute: Entry …

パーティションがサーバーに追加されているようにも見えません (Apache サーバーを再起動すると、ルート DSE の下に新しい NamingContext が表示されません)。ここでいくつかの手順が欠落していると思いますが、それらが何であるかはわかりません。

4

1 に答える 1

-1

Apache DS 開発者のメーリング リストからのアドバイス:

"// 常に CoreSession の API を使用してエントリを追加します". パーティションを追加する方法のほぼ完全な例については、http://apaste.info/KHXを確認してください。欠落しているクラス EmbeddedServer は次のとおりです。

 private static final class EmbeddedServer {
    private DirectoryService directoryService;
    private LdapServer ldapService;

    public EmbeddedServer(final String host, final int port) throws Exception {
        init(host, port);
    }

    private void init(final String host, final int port) throws Exception {

        DefaultDirectoryServiceFactory factory = new DefaultDirectoryServiceFactory();
        factory.init("Test");
        this.directoryService = factory.getDirectoryService();
        this.directoryService.getChangeLog().setEnabled(false);
        this.directoryService.setShutdownHookEnabled(true);
        this.directoryService.setInstanceLayout(new InstanceLayout("/tmp/ldapServer"));

        this.ldapService = new LdapServer();
        this.ldapService.setTransports(new TcpTransport(host, port));
        this.ldapService.setDirectoryService(this.directoryService);
    }

    public void start() throws Exception {

        this.directoryService.startup();
        this.ldapService.start();
    }

    public void stop() throws Exception {

        this.ldapService.stop();
        this.directoryService.shutdown();
    }
}
于 2014-09-29T14:31:08.197 に答える