Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Note
titleWork in progress

This site is in the process of being reviewed and updated.

Embedding ApacheDS as a Web Application

...

Table of Contents
minLevel2
maxLevel2
typelist
Info
titleVersion check

Although the concepts depicted below apply to all version of ApacheDS (even before 1.0), the configuration for starting and stopping the embedded server uses the style introduced with ApacheDS 1.5.1. Be sure that you use this version of the server, or a later one.

Solution Outline

Note
titleProof of concept character

Although it works well, please note that this is just an example on how to embed ApacheDS in an application! If you plan to run the server as LDAP production system, this is not the first option to consider. Some more steps have to be done, especially in the area of configuration.

...

Code Block
java
java
titleEnvHelper.java
package org.apache.directory.samples.embed.webapp;

import java.util.Hashtable;
import java.util.Properties;

import javax.naming.Context;

public class EnvHelper {

    public static Hashtable createEnv() {
        Hashtable env = new Properties();

        env.put(Context.PROVIDER_URL, "");
        env.put(Context.INITIAL_CONTEXT_FACTORY,
                "org.apache.directory.server.jndi.ServerContextFactory");

        env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
        env.put(Context.SECURITY_CREDENTIALS, "secret");
        env.put(Context.SECURITY_AUTHENTICATION, "simple");

        return env;
    }
}

The listener class

...

titleVersion check

...

The class StartStopListener implements ServletContextListener and therefore contains the following two life cycle methods:

...