Sun Java Solaris Communities My SDN Account
 
Code Samples & Apps

LDAP Login Example

This app provides a simple example of login authentication using Netscape's LDAP Java API.

 
 

The example contains one AppLogic, Login.java (plus the standard base classes Session and BaseAppLogic), and two HTML files: LDAPLogin.html and wrongLogin.html. The login page, LDAPLogin.html, lets the user enter a user name and password, which are used to authenticate the user on the LDAP server. If successful, the user's LDAP attributes are streamed out to the client. (In a real app, this would probably call a method to extract a user ID or role to save to the session, and then call another App Logic that goes into the application itself.) If the login is not successful, then the user is redirected to wrongLogin.html and allowed to try again, up to a maximum number of failures, after which all login attempts will be refused, until the user's session expires.

In addition to the standard execute() and guid() method, the Login AppLogic contains the following methods:

  • maxFailuresReached: determines if the user's maximum number of failed logins has been reached.
  • getDN: gets the LDAP distinguished name for the specified user
  • authenticateUser: attempts to authenticate the user with the specified password on the specified LDAP server.

To get this example working you need to do the following:

  1. Put the LDAP JAR file, LDAPJDK.JAR, on your NAS machine, and add it to your system CLASSPATH.
  2. Because Java classes with native methods must be loaded by the default Java VM classloader, aka the 'primordial' classloader, instead of the KIVA classloader, you must edit a filter list in the registry. Start up kreg tool (Regedit on NT: HKEY_LOCAL_MACHINE).

    Navigate in the tree to the following key...

        SOFTWARE/KIVA/Enterprise/2.0/CCS0/SYSTEM_JAVA
    

    Edit the GX_CLASSPATH_CORE value. It's default installed value should be...

        java.;gx.;com.kivasoft.
    

    Add "netscape." so that it now looks like:

        java.;gx.;com.kivasoft.;netscape.
    
  3. Then restart your Netscape Application Server.

    Download the example source

    Release Notes

    For Solaris, make sure to compile on the deployed server to ensure all necessary classes are included in the CLASSPATH.

spacer spacer

Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.