A very simple example of fetching all matching LDAP entries (distinguished names only), using the LDAPGetEntries JavaBean. JavaScript fetches user-entered values from form fields and retrieves all matching entries from the specified directory, by setting properties on an LDAPGetEntries object and calling its getEntries() method. The results are displayed in a Java applet with settable colors and font.

Examples of filters to test:
objectclass=person
objectclass=organization
objectclass=groupOfUniqueNames
cn=*Jensen
Host:
Port:
Directory base:
Filter:

The JavaScript code to do this is as follows:

    APPLET code="TestBeanApplet.class" NAME="TestBeanApplet" MAYSCRIPT="true"
    width=450 height=200>
    /APPLET

var getter;
function getEntries() {
    // Get parameters from form fields
    getter.setHost( document.input.host.value );
    getter.setPort( parseInt(document.input.port.value) );
    getter.setBase( document.input.base.value );
    getter.setFilter( document.input.filter.value );
    getter.setAttribute( "cn" );
    // Must request rights to do network connections
    netscape.security.PrivilegeManager.enablePrivilege("UniversalConnect");
    // Do the search
    values = getter.getEntries();
    if ( values == null ) {
        var err = getter.getErrorCode();
        showError( err );
    }
}

// Instantiate Bean and hook it up to applet
function doWire() {
    // Create an instance of the Bean
    getter = new netscape.ldap.beans.LDAPGetEntries();
    // Hook it up to the applet
    getter.addPropertyChangeListener( document.TestBeanApplet );
    // Set some interesting colors and font for the applet
    document.TestBeanApplet.setBackgroundColor( "yellow" );
    document.TestBeanApplet.setForegroundColor( "blue" );
    document.TestBeanApplet.setTextFont( "Helvetica-bolditalic-20" );
}
window.onload=doWire()