J'essaie d'exécuter un ApacheDS intégré dans mon application. Après avoir lu http://directory.apache.org/apacheds/1.5/41-embedding-apacheds-into-an-application.html Je construis ceci:Exécution d'Apache DS intégré dans mon application
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);
}
}
Mais je ne peux pas se connecter au serveur après l'exécuter. Quel est le port par défaut? Ou est-ce que je manque quelque chose?
Voici la solution:
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();
Mais est-ce le port par défaut pour Apach eDS aussi? Et ApacheDS crée-t-il un accès LDAP avec le code ci-dessus ...? – cringe
J'utilise Apache Directory Studio pour parcourir LDAP, mais je ne suis pas familier avec l'exécution d'un ApacheDS intégré. Vous venez de répondre à votre question sur le port par défaut de LDAP. – JuanZe
J'ai téléchargé l'exemple de code et les bibliothèques et je l'ai exécuté à partir d'Eclipse. La sortie affiche: log4j: WARN Aucun appender n'a pu être trouvé pour logger (org.apache.directory.server.schema.registries.DefaultNormalizerRegistry). log4j: WARN Veuillez initialiser correctement le système log4j. entrée Trouvé: ServerEntry dn [n]: dc = Apache, dc = org objectClass: extensibleObject objectClass: Domaine objectClass: top dc: Apache – JuanZe