Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

anchortop
top 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.

...

This article is organized in the following sections:

...

Starting the LDAP server

In this release of Geronimo, the Apache Directory v0.92 is already included with the distribution although it is not started by default. You can either start the server from command line using the deployer tool or via the Geronimo Administration Console.

...

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.

Source Code

You can checkout the source code of this sample from SVN:

svn checkout http://svn.apache.org/repos/asf/geronimo/samples/trunk/samples/ldap-sample-app

Back to Top

Add LDAP entries

...

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 For example, to export the initial configuration using the ldapsearch tool execute the following command:

ldapsearch -h localhost -p 10389 -b "ou=system" -D "uid=admin,ou=system" -w secret -x "(objectclass=*)"

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.

...

borderStylesolid
titleldap-sample.ldif

...

To import the data with ldapmodify tool execute the following command:

ldapmodify -h localhost -p 10389 -D "uid=admin,ou=system" -w secret -x -a -f <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.

...

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.

...

...

This deployment plan tell Geronimo all the connection and search paraments against the LDAP database. This plan also specifies to record each login attempt into the login-attempts.log log file.

...

Once deployed you should see a confirmation message similar to the following example:
No FormatbgColor
#000000borderStylesolid D:\geronimo-tomcat6-jee5-2.0\bin>deploy deploy \samples\2.0\ldap-sample-app\ldap-realm.xml Using GERONIMO_BASE: D:\geronimo-tomcat6-jee5-2.0 Using GERONIMO_HOME: D:\geronimo-tomcat6-jee5-2.0 Using GERONIMO_TMPDIR: D:\geronimo-tomcat6-jee5-2.0\var\temp Using JRE_HOME: C:\Java\jdk1.5.0_06\\jre Deployed console.realm/LDAP_Sample_Realm/1.0/car
Back to Top

For further details refer to the LDAP Realm section.

...

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.

...

...

The first part of the deployment plan is straight forward. However, the security configuration is tricky. The <security-realm-name> is described in the <security> element through a sequence of declarations in the <realms> element.

...

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.

...

...

Back to Top

Package the sample application

...

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

No FormatbgColor#000000borderStylesolid D:\geronimo-tomcat6-jee5-2.0\bin>deploy deploy \samples\2.0\ldap-sample-app\ldap-demo.war Using GERONIMO_BASE: D:\geronimo-tomcat6-jee5-2.0 Using GERONIMO_HOME: D:\geronimo-tomcat6-jee5-2.0 Using GERONIMO_TMPDIR: D:\geronimo-tomcat6-jee5-2.0\var\temp Using JRE_HOME: C:\Java\jdk1.5.0_06\\jre Deployed samples/LDAP_Sample/1.2/war @ http://localhost:8080/LDAP_Sample

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

...