★ wanayoo — archive 1999 http://developer.iplanet.com/docs/examples/appserver/ldap.htmlNouvelle recherche | Portail wanayoo
iPlanet

You are here:  Home > Developers > Sample Code > LDAP > LDAP Sample Code
LDAP Sample Code
 iPlanet Developers


Developer Program
  Membership
  One-to-One Support
  Newsgroups
  Member Services

Developer Publications
  View Source
  Developer News

Documentation
  Technical Manuals
  White Papers
  TechNotes
  Sample Code
  FAQs
  Books

Technologies
  Application Server   CSS
  DOM
  CORBA
  Directory & LDAP
  Dynamic HTML
  Java
  JavaScript
  Linux
  RDF
  Security
  SSJS
  XML
  XUL

Developer Downloads
  Tools & SDKs
  Patches

iPlanet Products
  Technical Resources










spacer
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.


    Related Readings:


    Any sample code included above is provided for your use on an "AS IS" basis, under the Netscape License Agreement - Terms of Use

spacer spacer


                                                       
iPlanet International | Year 2000 | Site Map | Feedback
Products | Solutions | Support | Services | Download | About Us | Developer
© 2000 Sun-Netscape Alliance. All Rights Reserved  Privacy Policy