12
votes

Courir Apache DS intégré dans ma demande

J'essaie de gérer des apladies intégrées dans mon application. Après avoir lu http://directory.apache.org.org /Apacheds/1.5/41-Medding --Apacheds-into-an-Application.html I Construire ceci: xxx

mais je ne peux pas me connecter au serveur après l'exécution. Quel est le port par défaut? Ou est-ce que je manque quelque chose?

Voici la solution: xxx


0 commentaires

7 Réponses :


1
votes

Le port par défaut pour LDAP est 389.


3 commentaires

Mais est-ce le port par défaut pour les apladies aussi? Et les apladies créent-ils un accès LDAP avec le code ci-dessus ...?


J'utilise Apache Directory Studio pour parcourir LDAP, mais je ne connais pas d'exécution d'aplads intégrés. Je viens de répondre à votre question sur le port par défaut pour LDAP.


J'ai recommencé le code d'échantillon et les bibliothèques et l'exécutant de Eclipse. La sortie montre: log4J: warn Aucun annexe n'a pu être trouvé pour l'enregistreur (org.apache.directory.server.schema.registry.defultnormal izerregistry). LOG4J: Avertissez-vous s'il vous plaît initialiser correctement le système Log4J. Entrée trouvée: ServerEntry DN [N]: DC = Apache, DC = Org ObjectClass: ExtensibleObject ObjectClass: Classe de domaineClass: Top DC: Apache



6
votes

Voici une version abrégée de la façon dont nous l'utilisons: xxx


1 commentaires

Merci, c'est tout. J'ai dû changer certaines lignes pour faire correspondre ma version des apladies. Vous pouvez voir le résultat dans la question.



1
votes

Depuis Apacheds 1.5.7, vous obtiendrez une nullpoinpointException. S'il vous plaît utiliser le tutoriel à http://svn.apache.org/repos/astf / répertoire / documentation / échantillons / tronc / échantillon intégré


0 commentaires

1
votes

Ce projet m'a aidé: Projet d'échantillon incorporé

J'utilise ceci Dépendance dans POM.XML: P>

<dependency>
    <groupId>org.apache.directory.server</groupId>
    <artifactId>apacheds-server-integ</artifactId>
    <version>1.5.7</version>
    <scope>test</scope>
</dependency>


0 commentaires

4
votes

Je n'ai pas pu le faire courir ni avec Cringe, la version de Kevin's Nor Jörg Pfünder. Reçu constamment NPES de mon test JUnit. Je vous ai débogué et les compilé tous à une solution de travail:

public class DirContextSourceAnonAuthTest {

  private static DirectoryService directoryService;
  private static LdapServer ldapServer;

  @BeforeClass
  public static void startApacheDs() throws Exception {
    String buildDirectory = System.getProperty("buildDirectory");
    File workingDirectory = new File(buildDirectory, "apacheds-work");
    workingDirectory.mkdir();

    directoryService = new DefaultDirectoryService();
    directoryService.setWorkingDirectory(workingDirectory);

    SchemaPartition schemaPartition = directoryService.getSchemaService()
        .getSchemaPartition();

    LdifPartition ldifPartition = new LdifPartition();
    String workingDirectoryPath = directoryService.getWorkingDirectory()
        .getPath();
    ldifPartition.setWorkingDirectory(workingDirectoryPath + "/schema");

    File schemaRepository = new File(workingDirectory, "schema");
    SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(
        workingDirectory);
    extractor.extractOrCopy(true);

    schemaPartition.setWrappedPartition(ldifPartition);

    SchemaLoader loader = new LdifSchemaLoader(schemaRepository);
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    directoryService.setSchemaManager(schemaManager);

    schemaManager.loadAllEnabled();

    schemaPartition.setSchemaManager(schemaManager);

    List<Throwable> errors = schemaManager.getErrors();

    if (!errors.isEmpty())
      throw new Exception("Schema load failed : " + errors);

    JdbmPartition systemPartition = new JdbmPartition();
    systemPartition.setId("system");
    systemPartition.setPartitionDir(new File(directoryService
        .getWorkingDirectory(), "system"));
    systemPartition.setSuffix(ServerDNConstants.SYSTEM_DN);
    systemPartition.setSchemaManager(schemaManager);
    directoryService.setSystemPartition(systemPartition);

    directoryService.setShutdownHookEnabled(false);
    directoryService.getChangeLog().setEnabled(false);

    ldapServer = new LdapServer();
    ldapServer.setTransports(new TcpTransport(11389));
    ldapServer.setDirectoryService(directoryService);

    directoryService.startup();
    ldapServer.start();
  }

  @AfterClass
  public static void stopApacheDs() throws Exception {
    ldapServer.stop();
    directoryService.shutdown();
    directoryService.getWorkingDirectory().delete();
  }

  @Test
  public void anonAuth() throws NamingException {
    DirContextSource.Builder builder = new DirContextSource.Builder(
        "ldap://localhost:11389");
    DirContextSource contextSource = builder.build();

    DirContext context = contextSource.getDirContext();
    assertNotNull(context.getNameInNamespace());
    context.close();
  }

}


0 commentaires

0
votes

En outre, en 2.0. * Le directeur de travail et d'autres chemins ne sont plus définis dans Directoryservice, mais plutôt dans une classe distincte instanque, que vous devez instancier, puis appelez

InstanceLayout il = new InstanceLayout(BASE_PATH);
directotyService.setInstanceLayout(il);


0 commentaires