我試圖在我的應用程序中運行嵌入式ApacheDS。在閱讀http://directory.apache.org/apacheds/1.5/41-embedding-apacheds-into-an-application.html我建立這個:運行嵌入在我的應用程序中的Apache DS
public void startDirectoryService() throws Exception {
service = new DefaultDirectoryService();
service.getChangeLog().setEnabled(false);
Partition apachePartition = addPartition("apache", "dc=apache,dc=org");
addIndex(apachePartition, "objectClass", "ou", "uid");
service.startup();
// Inject the apache root entry if it does not already exist
try
{
service.getAdminSession().lookup(apachePartition.getSuffixDn());
}
catch (LdapNameNotFoundException lnnfe)
{
LdapDN dnApache = new LdapDN("dc=Apache,dc=Org");
ServerEntry entryApache = service.newEntry(dnApache);
entryApache.add("objectClass", "top", "domain", "extensibleObject");
entryApache.add("dc", "Apache");
service.getAdminSession().add(entryApache);
}
}
但我運行它後無法連接到服務器。什麼是默認端口?或者我錯過了什麼?
這裏是解決方案:
service = new DefaultDirectoryService();
service.getChangeLog().setEnabled(false);
Partition apachePartition = addPartition("apache", "dc=apache,dc=org");
LdapServer ldapService = new LdapServer();
ldapService.setTransports(new TcpTransport(389));
ldapService.setDirectoryService(service);
service.startup();
ldapService.start();
但它是爲APACH的默認端口eDS呢?並且是使用上面的代碼創建LDAP訪問的ApacheDS ...? – cringe
我使用Apache Directory Studio瀏覽LDAP,但我不熟悉運行嵌入式ApacheDS。剛剛回答了有關LDAP的默認端口的問題。 – JuanZe
我下載了示例代碼和庫,並從Eclipse運行它。輸出顯示: log4j:警告沒有appender可以找到記錄器(org.apache.directory.server.schema.registries.DefaultNormalizerRegistry)。 log4j:WARN請正確初始化log4j系統。 實測值條目:ServerEntry DN [N]:DC =阿帕奇,DC =組織 的objectClass:extensibleObject的 的objectClass:域 objectClass的:頂 DC:阿帕奇 – JuanZe