Estoy tratando de ejecutar un ApacheDS incrustado en mi aplicación. Después de leer http://directory.apache.org/apacheds/1.5/41-embedding-apacheds-into-an-application.html construyo esto:Ejecución de Apache DS incrustado en mi aplicación
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);
}
}
Pero no puedo conectar con el servidor después de ejecutar. ¿Cuál es el puerto predeterminado? ¿O me estoy perdiendo algo?
Aquí está la solución:
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();
Pero es el puerto predeterminado para Apach eDS también? ¿ApacheDS está creando un acceso LDAP con el código anterior ...? – cringe
Uso Apache Directory Studio para explorar LDAP, pero no estoy familiarizado con la ejecución de un ApacheDS incrustado. Acabo de responder su pregunta sobre el puerto predeterminado para LDAP. – JuanZe
He descargado el código de muestra y las bibliotecas y lo ejecuté desde Eclipse. El resultado muestra: log4j: WARN No se encontraron appenders para logger (org.apache.server.server.schema.registries.DefaultNormalizerRegistry). log4j: WARN Inicialice el sistema log4j correctamente. entrada Encontrado: ServerEntry dn [n]: dc = Apache, dc = Org objectClass: extensibleObject objectClass: dominio objectClass: top dc: Apache – JuanZe