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 text area.

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:

    // Create an instance of the Bean
    var getter = new netscape.ldap.beans.LDAPGetEntries();
    // 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 );
    // Do the search
    netscape.security.PrivilegeManager.enablePrivilege("UniversalConnect");
    values = getter.getEntries();
    // Display the results
    if ( values != null ) {
        document.output.results.value=getter.convertToString( values );
    } else {
        var err = getter.getErrorCode();
        showError( err );
    }