LDAP requests work similarly to database requests and data sources. They can be used to retrieve data from an LDAP server dynamically.
If you need to filter the returned data, you can also add an appropriate LDAP filter.

Creating an LDAP query


Configuration screen for creating LDAP queries: (1) list of existing LDAP queries, (2) editor for defining the query, (3) settings panel of the query, (4) attribute filters for the query, (5) Generated servlet URL for using the LDAP query, (6) console for testing the query

  • Provide a name for the LDAP query, and optionally a description.
  • Select the LDAP connection to use; either client's LDAP connection or another custom LDAP connection.
  • Enter the base DN (distinguished name) for the query. This is the root path for the LDAP search.
  • Enter the LDAP query with the LDAP filter syntax, see here for a tutorial). You may also use placeholders (question mark, ?) that will be replaced with the values from a GET HTTP request for this LDAP query, see below.
  • Optionally, enter a list of attributes. The query will return only those attributes, filtered on the server. When no parameters are specified, all attributes will be returned.

Using LDAP queries

LDAP queries can also be accessed via a GET HTTP request. This allows you to access LDAP queries via JavaScript. The URL endpoint is:

http://<server>/formcycle/datenabfrageldap

The following URL parameters are available:

Name of the parameterDescriptionRequired
nameThe name of the LDAP request.Yes
mandantNameThe name of the client who owns this LDAP query.Yes, when projektId was not specified.
projektIdThe ID of the form. The form ID can be accessed via the JavaScript object window.XFC_METADATA.currentProject.id.Yes, when mandantName was not specified.
queryParameterWhen the LDAP query contains placeholders (question marks, ?), a list of parameters must be supplied for each placeholder. The items are separated with the delimiter as defined by the URL parameter delimiter.No
delimiterThe delimiter for the placeholder values, see queryParameter. Defaults to a comma ,No

When you want to initiate an LDAP query from a form via JavaScript, use the URL provided by the JavaScript object window.XFC_METADATA. The LDAP query URL can be accessed via window.XFC_METADATA.urls.datasource_ldap.

The LDAP queries returns a JSON object that can be parsed with JSON.parse(...)

Examples for LDAP queries

The following shows how to retrieve the result of an LDAP query via an HTTP request. The demo pages also include an example illustrating how to setup a select element with the result of an LDAP query.

Assuming an LDAP query has been created already and was named MyQuery.

((distinguishedName=?,?)

You need to provide two values for the the two placeholders (question marks). Send a GET request to the following URL to perform the LDAP query:

http://<server>/formcycle/datenabfrageldap?name=MyQuery&mandantName=MyClient&queryParameter=Value,1;Value,2&delimiter=;

Within a form, the following code can be used to perform the LDAP query via an asynchronous HTTP request:

function ldapQuery(name, queryParameter, delimiter, callback) {
    $.ajax({
        url: XFC_METADATA.urls.dataquery_ldap,
        method: 'GET',
        async: true,
        cache: false,
        dataType: 'json',
        data: {
            name: name,
            mandantName: XFC_METADATA.currentClient.name,
            queryParameter: queryParameter,
            delimiter: delimiter || ','
        }
    }).success(callback);
}
Tags:
Created by gru on 25.03.2019, 11:57
Translated into en by gru on 25.03.2019, 11:57
Copyright 2000-2024