Child pages
  • LDAP sample application
Skip to end of metadata
Go to start of metadata

Geronimo uses the Apache Directory Server for its directory service, this is part of the Apache Directory Project. Geronimo implements the following two projects from the ApacheDS project.

  • ApacheDS Core:
    Server's core contains all backend subsystems. It depends on protocol and uses it with seda to service LDAP requests. The core contains the JNDI provider, interceptor framework, interceptor services, the schema subsystem and the database subsystem. Hence the core is the heart of the server.
  • ApacheDS Shared:
    Created to eliminate cyclic project dependencies between the core and the maven plug-in. Any code shared across modules in general can go here so long as it does not depend on other modules.

More information about these two projects can be found at the ApacheDS project URL:

At this point, Geronimo does not provide LDAP client commands for configuring the server, however this feature is in plan for the next release of Geronimo. Currently, you could use any LDAP client such as ldapbrowser/editor, jxplorer or gq for browsing and editing the configurations of the Directory Server in Geronimo.

In this release of Geronimo, that is v1.1 and v1.1.x, Apache Directory is provided as a security plugin that you need to install in a separated process. This is very simple to accomplish and the steps are described in the following seciton.

Installing Apache Directory in Geronimo

Installing a Geronimo plugin is a relatively simple procedure. In this case, the Apache Directory server is provided as a plugin with all the dependencies included.

  1. Start Geronimo and log into the Administration Console
  2. Click on Create/Install under the Plugins folder
  3. If there are no repositories in the list click the Update Repository List link
  4. Click on Search for Plugins
  5. From the list select Apache Directory 0.92 for Geronimo (1.1)
  6. Click on Install Plugin
    All the needed components will be download and, if successful, you will see a message indicating that the plugin was installed.
  7. Click on Start geronimo/directory/1.1/car

Back to Top

LDAP sample application

For your conveniece we have prodived the sample application and deployment plans packaged into a zip file.
Download the sample application from the following URL:

After extracting the zip file a ldap-sample-app directory is created, from now on this directory will be referred as <ldap_home>.

At this point it is assumed that you have installed an LDAP client and you are capable of exporting/importing an .ldif file to a directory server.

Back to Top

Add LDAP entries

Ensure that Geronimo is up and running and the Directory service is started. Start your LDAP client and create a new connection profile with the following values:





Base DN:


User DN:




Once you connect to the Geronimo Directory server you will see the initial configuration, this configuration can be exported as a backup in a ldif file. Depending the LDAP client you are using the export/import steps will be different. When you export the initial configuration you get an ldif file with a content similar as the one shown in the following example.


Back to Top

Now you need to import the entries needed to run the sample application. Packaged with the sample application is a sample .ldif file with all the entries necessary to run the LDAP sample application, this file is located in <ldap_home>/ldap-sample.ldif.

The following example shows the content of the ldap-sample.ldif file.


Once the file is imported you should get a confirmation that five entries were successfully imported.

Back to Top

Deploy the LDAP realm

The LDAP sample application provides a security realm that needs to be deployed before the deployment of the application itself. This realm is located in <ldap_home>/ldap-realm.xml and the content is illustrated in the following example.

xmlsolidldap-realm.xml samples ldap-realm-1 1.1 geronimo j2ee-security car true initialContextFactory=com.sun.jndi.ldap.LdapCtxFactory connectionURL=ldap://localhost:1389 connectionUsername=uid=admin,ou=system connectionPassword=secret connectionProtocol= authentication=simple userBase=ou=users,ou=system userSearchMatching=uid={0} userSearchSubtree=false roleBase=ou=groups,ou=system roleName=cn roleSearchMatching=(uniqueMember={0}) roleSearchSubtree=false userRoleName= ldap-realm-1 ldap-realm-1 ldap-login ServerInfo JaasLoginService REQUIRED ldap-login ]]>

To deploy the ldap-realm.xml run the following command from the <geronimo_home>/bin directory:

java -jar deployer.jar --user system --password manager deploy <ldap_home>/ldap-realm.xml

Once deployed you should see a confirmation message similar to the following example:
#000000solidjava -jar deployer.jar --user system --password manager deploy \ldap-sample-app\ldap-realm.xml Deployed samples/ldap-realm-1/1.1/car ]]>
Back to Top

For further details refer to the LDAP Realm section.

Deployment plans

The deployment plans are located in the <ldap_home>/WEB-INF directory. Clearly, geronimo-web.xml is the Geronimo specific deployment plan. It provides the details on what security realm to use and user role mappings as well as the Geronimo specific namespace used to identify the elements in the security configuration. Common to other types of applications, not just security, the deployment plan also provides the main namespace for the deployment plan, a module identification (optional), a parent module configuration ID (also optional) and a context root. The following example illustrates the Geronimo specific deployment plan.

xmlsolidgeronimo-web.xml samples ldap-realm-1-app 1.1 /ldap-demo-1 ldap-realm-1 ]]>

Note that these role mappings will be overridden by the actual roles (what users pertaining to what groups) defined in the LDAP server. Ultimately it is the realm defined in the application deployment plan who determines the velidation method. Nevertheless, for this particular example, you still need to define principals and role mappings as determined in the XML schemas.

Back to Top

The web.xml deployment descriptor shown in the following example (also located in the <ldap_home>/WEB-INF diretory) adds security constraints based on the location of the files.

xmlsolidweb.xml index.html Admin Role /protect/* content-administrator No Access /forbidden/* FORM ldap-realm-1 /auth/logon.html?param=test /auth/logonError.html?param=test content-administrator ]]>

Back to Top

Package the sample application

Now that all the elements have been identified, it is necessary to package the sample application in a Web application Archive (.war). Open a command line window, change directory to <ldap_home> and run the following command:

jar -cvf ldap-demo.war *

This command will package all the existing files and directories inside <ldap_home>. Although not needed inside the .war file, the ldap-realm.xml and ldap-sample.ldif files will also be included.

Back to Top

Deploy the application

To deploy the LDAP sample application make sure the Geronimo server is up and running. Open a command line window, change directory to <geronimo_home>/bin and run the following command:

java -jar deployer.jar --user system --password manager deploy <ldap_home>/ldap-demo.war

Once the Web application is successfully deployed you should see a confirmation message similar as the one shown in the following example:

#000000solidjava -jar deployer.jar --user system --password manager deploy \ldap-sample-app\ldap-demo.war Deployed samples/ldap-realm-1-app/1.1/war @ http://hc2t60p:8080/ldap-demo-1 ]]>

To test the LDAP application open a Web browser and access the following URL:


The following figure shows the welcome page for the LDAP sample application.

Click on Protect to validate against the LDAP Directory Server.

Enter system as the username and manager as the password and click Login. The username and password you provide here is the same you use to access the Geronimo Web console and it is stored in the Directory Server database. Once you are logged in you should see the following screen.

At this point you have an application that is validating username and passwords against an LDAP Directory Server database based on the security configuration you provided earlier in the LDAP realm. Now, if you go back to the welcome page and click on Forbidden you should receive a 403 - Forbidden HTTP error similar to the one shown in the following figure.

Depending on the web container you are using (that is Jetty or Tomcat) the presentation of that screen may be slightly different.

To further test this example you could now try the different users provided in the ldap-sample.ldif, use your LDAP client and add/remove users from the different groups. You will notice the changes immediatly (you may need to close your web browser).

Back to Top

  • No labels