A very simple example of user authentication with LDAP. There is a small invisible JavaBean - LDAPSimpleAuth. JavaScript fetches user-entered values and validates the user against the specified directory, by setting properties on LDAPSimpleAuth and calling its authenticate() method.

An example of an entry to test is:
Distinguished Name: uid=prose, ou=People, o=Airius.com
Password: regatta
Host:
Port:
Distinguished Name:
Password:

The JavaScript code to do this is as follows:

    auth = new Packages.netscape.ldap.beans.LDAPSimpleAuth();
    auth.setHost( document.input.host.value );
    auth.setPort( parseInt(document.input.port.value) );
    auth.setAuthDN( document.input.dn.value );
    auth.setAuthPassword( document.input.password.value );
    // Must request rights to do network connections
    netscape.security.PrivilegeManager.enablePrivilege("UniversalConnect");
    // And for property reads, to get LDAP error strings
    netscape.security.PrivilegeManager.enablePrivilege("UniversalPropertyRead");
    result = auth.authenticate();
    if ( result == "N" )
        msg =  "Incorrect password";
    else
        msg = "Successful login";
    alert( msg );