Select options from an LDAP query

Last modified by Andre Wachsmuth on 26.06.2018

Demo form with several select elements. Their options are taken from an LDAP query.

LDAP queries are used to access data from an LDAP directory, such as the data for persons or employees.

This page demonstrates how you can setup a selectAuswahlelement with data from an LDAP query. The returned data is used to setup the options of the select element, ie. to display a list of all employees.

The demo form is available here: http://demo.formcycle.de/formcycle/form/provide/402 The name of the form is LDAPQueryToSelect.

You can also download the form directly:

- as a form export from the Xima® Formcycle Designer: http://help.formcycle.eu/xwiki/bin/download/Main/AuswahlLDAP/formcycle-project-LDAPQueryToSelect.json
- as a project export: http://help.formcycle.eu/xwiki/bin/download/Main/AuswahlLDAP/formcycle-project-LDAPQueryToSelect.zip

Required steps

Currently there exists no user interface for connecting an LDAP query with a select element. This means that we need to implement this functionality with JavaScript.
The following code samples make use of feature from the new JavaScript version ES6 that may not be supported by older browsers.. If older browsers need to be supported, you can either convert the code via babel; or use the code provided at the end of this page.

The following steps are required:

  1. Retrieving the data from the LDAP query via an asynchronous HTTP request to Xima® Formcycle.
  2. Taking care of errors in case the request failed.
  3. Setting up the select element with the returned data.
  4. Synchronizing the select element with a hidden input field.

The last step is required because otherwise, the selected option cannot be displayed when the form is opened again after submission. The hidden input field carries the value of the selected option, and should be used when you need to access the form field via variables. The select element provides a view to the user, letting them see and change the currently selected option.

Helper functions

We do not want to write the code from scratch for each select element, so we create several helper functions first.

First, we need a function for performing the LDAP query. We prepare and send an HTTP request, as described in the help page on LDAP queries.
The URL endpoint is taken from the form metadata. This function also interprets the result as either an error or success, and calls the appropriate callback. By default, it is treated as an error when the LDAP query does not return any (0) results. This behavior can be changed by setting the option treatEmptyAsError  to false.

Function for performing the LDAP request via HTTP

/**
 * Performs an LDAP query asynchronously. Takes the URL endpoint and the client
 * name from the currently opened from. (via window.XFC_METADATA).
 *
 * @param {string} name The name of the LDAP query.
 * @param {fn} callback Callback function when the data is ready. First argument is an array with the results.
 * @param {fn} errorCallback Called when the query was not successful. First argument is an Error object.
 * @param {string} queryParameter Optional additional parameters for the LDAP query, separated with the given delimiter.
 * @param {string} delimiter Optional delimiter for the queryParameter, default to a comma ",".
 * @param {boolean} treatEmptyAsError Whether no items being returned by the data is treated as an error.
 */

function ldapQuery({
    name,
    callback = undefined,
    errorCallback = e => console.error("LDAP query failed", e),
    queryParameter = undefined,
    delimiter = ",",
    treatEmptyAsError = false,
    }) {
   // Send an asynchronous HTTP request for performing the LDAP query.
   $.ajax({
       // Get the LDAP query URL endpoint from the form metadata.
       url: XFC_METADATA.urls.dataquery_ldap,
       // The LDAP query returns a JSON response.
       dataType: 'json',
        method: 'GET',
        async: true,
        cache: false,
        data: {
            name,
            delimiter,
            queryParameter,
           // Get the client name from the form metadata.
           mandantName: XFC_METADATA.currentClient.name,
        }
    })
    .success(data => {
       // Check if the LDAP query was successful.
       if (!data) {
            errorCallback(new Error("No data received"));
           return;
        }
       else if (data.success === false) {
            errorCallback(new Error(data.msg ? data.msg : "LDAP query did not return success"));
           return;
        }
       // Extract the array of returned items of the query.
       const result = "result" in data ? data.result : data;
       const array = Array.isArray(result) ? result : [result];
       if (treatEmptyAsError && array.length === 0) {
            errorCallback(new Error("LDAP query did not return any items."));
           return;
        }
       // If it was successful, call the callback with the returned data.
       callback && callback(array);
    })
   // If not successful, handle the error.
   .fail(errorCallback);
}

Next, we need a function that sets up the select element. It removes all options from the select element and adds the given options, by creating
new option HTML elements. Also, in case the select element is a required field, the empty option with the text please select is added as well.

The initial value for the select element is taken from the hidden input field. Additionally, Whenever the selected option changes, it is written to the hidden
input field. This hidden input field should be created as a variable.

To inform the user about any errors that occurred during the LDAP request, this function also lets you change the text displayed when no option is selected.

Function for setting up a select element with custom options

/**
 * Sets the options of a single-select element to the given options. Stores the value (the selected option)
 * in a hidden text input field for persistence. Otherwise the selected option cannot be displayed when
 * the form is opened again.
 *
 * @param {jQuery} $element  Select element whose options are to be set.
 * @param {object} options The options to be set. Property keys represent the value for the option, the property value the displayed text of the option.,
 * @param {jQuery} $textElement Hidden text element for storing the value of the text element.
 * @param {string} emptyText Text displayed for the empty option. If the select field is a required field, tThe empty option is the "please select" option by default. If the select field is not required and this parameter is given, a new empty option is created.
 */

function setOptions($element, options, $textElement = undefined, emptyText = undefined) {
   // Attrbute "idx" of the options.
   let idx = 0;
   // Prefix for the ID of the options
   const baseId = $element.attr("id") + "_";
   // If the select element is required, add back the option that says "please select" later.
   let $requiredOption = $element.find('[idx=0]').clone(true);
   // If given, show the emptyText for the empty option.
   if (emptyText !== undefined) {
       // Recycle the required option if it exists.
       if ($requiredOption.length > 0) {
            $requiredOption.data("originalText", $requiredOption.text());
            $requiredOption.text(emptyText);
        }
       // Create a new empty option.
       else {
            $requiredOption = $("<option>").attr("value", "").attr("idx", 0).attr("id", baseId + "0").text(emptyText);
        }
    }
   else {
       // Restore the original text of the empty option, or remove the empty option if it was not present.
       if ($requiredOption.length > 0) {
           const originalText = $requiredOption.data("originalText");
           if (originalText !== undefined) $requiredOption.text(originalText);
           else $requiredOption = $();
        }
    }
   // Clear all existing option elements.
   $element.empty();
   // Add back the required option.
   $element.prepend($requiredOption);
   // Add the new option elements.
   $element.append($.map(options, (text, value) => $("<option>")
        .text(text)
        .attr("value", value)
        .attr("idx", ++idx)
        .attr("id", baseId + idx)
    ));
   if ($textElement) {
       // Take and set the value of the select element from the hidden text element.
       $element.val($textElement.val());
       // Store the value of the select element in the hidden text element.
       $element.on("change", () => $textElement.val($element.val()));
    }
}

In order to sort the items returned by the LDAP query, we need to create a comparator function. The following function compares to objects by one or several
of their properties, starting with the property given first, then by the second, and so on.

Function for comparing two objects

/**
 * Creates a comparator for sorting items by the given properties. Items
 * are sorted first by the first property. If equal, they are sorted by
 * the second property etc.
 * @param {string[]} Properties to sort by.
 * @return A comparator for sorting items by the given properties.
 */

function sortBy(...properties) {
   // Return a function comparing two items according to the given properties.
   return (lhs, rhs) => {
       // Compare the values of each property, starting with the first.
       for (const property of properties) {
           // Retrieve the property from the item.
           const l = lhs[property];
           const r = rhs[property];
           // In JavaScript, undefined is always sorted last.
           if (l === undefined) return r === undefined ? 0 : 1;
           if (r === undefined) return -1;
           // Return -1 or 1, depending on whether the left-hand side or right-hand side is larger.
           if (l < r) return -1;
           if (l > r) return 1;
        }
       // All property values compared equal, so the two items compare equal.
       return 0;
    };
}

Finally, we can create a function that performs the LDAP query, takes the result, and writes it to the select element. Then we only need to call this function
for each select element.

Funktion für die LDAP-Anfrage per HTTP

/**
 * Take the name of a select element and sets its options from the result of an LLDAP query.
 * @param {string} selectName Name of the select element to setup.
 * @param {string} textName Name of the hidden text element used to store the selected option. Defaults to the selectName suffixed with `_value`.
 * @param {string} ldapQueryName Name of the LDAP query to perform.
 * @param {fn} valueExtractor Function that takes each item from the LDAP query and returns the value for the option.
 * @param {fn} textExtractor Function that takes each item from the LDAP query and returns the displayed for the option. If not given, uses the valueExtractor.
 * @param {fn} check Function that takes each item and returns `true` iff the item is to be used as an option for the select element, otherwise false. If not given, every item is used.
 * @param {string} delimiter Delimiter for the queryParameters for the LDAP query. Defaults to a comma (",").
 * @param {string} queryParameter Optional query parameter for the LDAP query. Must be separated by the given delimiter.
 * @param {fn} sortBy Optional comparator function for sorting the items. if not given, no sort is performed. Takes two arguments and returns -1 iff the first argument is strictly smaller than the second argument, +1 iff the first argument is strictly greater than the second; or 0 otherwise.
 * @param {boolean} autocomplete Whether the select element should be converted to an autocomplete, ie. a text input field offering suggestions. Defaults to `false`.
 * @param {boolean} loadingText Text shown to the user while loading the data. It is displayed as the the text of the only option of the select element (with an empty value). Defaults to a generic message.
 * @param {string} errorText Text shown to the user in case an error occurs. It is displayed as the the text of the only option of the select element (with an empty value). Defaults to a generic message.
 * @param {boolean} treatEmptyAsError Whether an empty data set returned by the LDAP query is considered an error. Defaults to `true`.
 */

function comboboxWithLdap({
    selectName,
    ldapQueryName,
    valueExtractor,
    textName = selectName + "_value",
    textExtractor = valueExtractor,
    check = () => true,
    delimiter = ",",
    queryParameter = undefined,
    sortBy = undefined,
    autocomplete = false,
    treatEmptyAsError = true,
    loadingText = "Fetching data, hold on.",
    errorText = "Could not fetch data due to a network error.",
}) {
   // Find the element, Do nothing iff the element does not exist.
   const $element = $(document.getElementsByName(selectName)[0]);
   const $textElement = $(document.getElementsByName(textName)[0]);
   if ($element.length < 1 || $textElement.length < 1) {
        console.error("Did not find the select and/or text element", $element, $textElement);
       return;
    }
   // Inform the user we are loading the data.
   setOptions($element, {}, undefined, loadingText);
   // Run the LDAP query.
   ldapQuery({
        name: ldapQueryName,
        queryParameter,
        delimiter,
        treatEmptyAsError,
        callback: data => {
           // Sort the data we received.
           if (sortBy) data = data.sort(sortBy);
           // Take the person's mail as the value, and their name as the displayed text of the option.
           const options = data.reduce((opts, item) => {
               // Check if this item is to be used as an option.
               if (check(item)) {
                   // Extract the text and the value of the option from the item.
                   opts[valueExtractor(item)] = textExtractor(item);
                }
               return opts;
            }, {});
           // Setup the select element with the options.
           setOptions($element, options, $textElement);
           if (autocomplete) {
                $element.cob2auto();
            }
        },
       // Log the error and inform the user about the error.
       errorCallback: error => {
            console.error("Failed to load data from LDAP query.", "ldapQueryName:", ldapQueryName, "selectName:", selectName, error);
           // Do not pass the hidden text element, otherwise the currently selected option would be discarded.
           setOptions($element, {}, undefined, errorText);
            $element.val("");
        },
    });
}

Setting up the select elements

For each select element we now need to call the function comboboxWithLdap and provide the appropriate parameters.

The demo form linked above sets up two select elements:

We set up the select element with the name selPeople. The LDAP query is named LDAP_Abfrage, and return several persons. Only persons with at least a mail address and family name (property sn) are shown. The mail address is used as the value for the option, (ie. the value transmitted when the form is submitted). The displayed text for each option consists of the given name and the family name. All persons are sorted first by their given name, then by their family name.

Also, you need to create a variable named selPeople_value.

comboboxWithLdap({
    selectName: "selPeople",
    ldapQueryName: "LDAP_Abfrage",
    check: item => item.mail && item.sn,
    valueExtractor: item => item.mail,
    textExtractor: item => item.givenName + " " + item.sn,
    sortBy: sortBy("givenName", "sn"),
});

Now we set up the select element named selPeopleAuto. The options are similar to the select element above (selPeople). Additionally, we convert
the select element to an input field with autocomplete, ie. a text input field with suggestions while typing.

Also, you need to create a variable named selPeopleAuto_value.

comboboxWithLdap({
    selectName: "selPeopleAuto",
    ldapQueryName: "LDAP_Abfrage",
    check: item => item.mail && item.sn,
    valueExtractor: item => item.mail,
    textExtractor: item => item.givenName + " " + item.sn,
    sortBy: sortBy("givenName", "sn"),
    autocomplete: true,
});

Complete code

For reference, here is the complete code of the example. It was transpiled with Babel and should work in older browsers as well.

Complete code for older browsers

"use strict";

/**
 * Performs an LDAP query asynchronously. Takes the URL endpoint and the client
 * name from the currently opened from. (via window.XFC_METADATA).
 *
 * @param {string} name The name of the LDAP query.
 * @param {fn} callback Callback function when the data is ready. First argument is an array with the results.
 * @param {fn} errorCallback Called when the query was not successful. First argument is an Error object.
 * @param {string} queryParameter Optional additional parameters for the LDAP query, separated with the given delimiter.
 * @param {string} delimiter Optional delimiter for the queryParameter, default to a comma ",".
 * @param {boolean} treatEmptyAsError Whether no items being returned by the data is treated as an error.
 */

function ldapQuery(_ref) {
   var name = _ref.name,
        _ref$callback = _ref.callback,
        callback = _ref$callback === undefined ? undefined : _ref$callback,
        _ref$errorCallback = _ref.errorCallback,
        errorCallback = _ref$errorCallback === undefined ? function (e) {
       return console.error("LDAP query failed", e);
    } : _ref$errorCallback,
        _ref$queryParameter = _ref.queryParameter,
        queryParameter = _ref$queryParameter === undefined ? undefined : _ref$queryParameter,
        _ref$delimiter = _ref.delimiter,
        delimiter = _ref$delimiter === undefined ? "," : _ref$delimiter,
        _ref$treatEmptyAsErro = _ref.treatEmptyAsError,
        treatEmptyAsError = _ref$treatEmptyAsErro === undefined ? false : _ref$treatEmptyAsErro;

   // Send an asynchronous HTTP request for performing the LDAP query.
   $.ajax({
       // Get the LDAP query URL endpoint from the form metadata.
       url: XFC_METADATA.urls.dataquery_ldap,
       // The LDAP query returns a JSON response.
       dataType: 'json',
        method: 'GET',
        async: true,
        cache: false,
        data: {
            name: name,
            delimiter: delimiter,
            queryParameter: queryParameter,
           // Get the client name from the form metadata.
           mandantName: XFC_METADATA.currentClient.name
        }
    }).success(function (data) {
       // Check if the LDAP query was successful.
       if (!data) {
            errorCallback(new Error("No data received"));
           return;
        } else if (data.success === false) {
            errorCallback(new Error(data.msg ? data.msg : "LDAP query did not return success"));
           return;
        }
       // Extract the array of returned items of the query.
       var result = "result" in data ? data.result : data;
       var array = Array.isArray(result) ? result : [result];
       if (treatEmptyAsError && array.length === 0) {
            errorCallback(new Error("LDAP query did not return any items."));
           return;
        }
       // If it was successful, call the callback with the returned data.
       callback && callback(array);
    })
   // If not successful, handle the error.
   .fail(errorCallback);
}

/**
 * Sets the options of a single-select element to the given options. Stores the value (the selected option)
 * in a hidden text input field for persistence. Otherwise the selected option cannot be displayed when
 * the form is opened again.
 *
 * @param {jQuery} $element  Select element whose options are to be set.
 * @param {object} options The options to be set. Property keys represent the value for the option, the property value the displayed text of the option.,
 * @param {jQuery} $textElement Hidden text element for storing the value of the text element.
 * @param {string} emptyText Text displayed for the empty option. If the select field is a required field, tThe empty option is the "please select" option by default. If the select field is not required and this parameter is given, a new empty option is created.
 */

function setOptions($element, options) {
   var $textElement = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
   var emptyText = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;

   // Attrbute "idx" of the options.
   var idx = 0;
   // Prefix for the ID of the options
   var baseId = $element.attr("id") + "_";
   // If the select element is required, add back the option that says "please select" later.
   var $requiredOption = $element.find('[idx=0]').clone(true);
   // If given, show the emptyText for the empty option.
   if (emptyText !== undefined) {
       // Recycle the required option if it exists.
       if ($requiredOption.length > 0) {
            $requiredOption.data("originalText", $requiredOption.text());
            $requiredOption.text(emptyText);
        }
       // Create a new empty option.
       else {
                $requiredOption = $("<option>").attr("value", "").attr("idx", 0).attr("id", baseId + "0").text(emptyText);
            }
    } else {
       // Restore the original text of the empty option, or remove the empty option if it was not present.
       if ($requiredOption.length > 0) {
           var originalText = $requiredOption.data("originalText");
           if (originalText !== undefined) $requiredOption.text(originalText);else $requiredOption = $();
        }
    }
   // Clear all existing option elements.
   $element.empty();
   // Add back the required option.
   $element.prepend($requiredOption);
   // Add the new option elements.
   $element.append($.map(options, function (text, value) {
       return $("<option>").text(text).attr("value", value).attr("idx", ++idx).attr("id", baseId + idx);
    }));
   if ($textElement) {
       // Take and set the value of the select element from the hidden text element.
       $element.val($textElement.val());
       // Store the value of the select element in the hidden text element.
       $element.on("change", function () {
           return $textElement.val($element.val());
        });
    }
}

/**
 * Creates a comparator for sorting items by the given properties. Items
 * are sorted first by the first property. If equal, they are sorted by
 * the second property etc.
 * @param {string[]} Properties to sort by.
 * @return A comparator for sorting items by the given properties.
 */

function sortBy() {
   for (var _len = arguments.length, properties = Array(_len), _key = 0; _key < _len; _key++) {
        properties[_key] = arguments[_key];
    }

   // Return a function comparing two items according to the given properties.
   return function (lhs, rhs) {
       // Compare the values of each property, starting with the first.
       for (var i = 0; i < properties.length; ++i) {
           var property = properties[i];
           // Retrieve the property from the item.
           var l = lhs[property];
           var r = rhs[property];
           // In JavaScript, undefined is always sorted last.
           if (l === undefined) return r === undefined ? 0 : 1;
           if (r === undefined) return -1;
           // Return -1 or 1, depending on whether the left-hand side or right-hand side is larger.
           if (l < r) return -1;
           if (l > r) return 1;
        }
       // All property values compared equal, so the two items compare equal.
       return 0;
    };
}

/**
 * Take the name of a select element and sets its options from the result of an LLDAP query.
 * @param {string} selectName Name of the select element to setup.
 * @param {string} textName Name of the hidden text element used to store the selected option. Defaults to the selectName suffixed with `_value`.
 * @param {string} ldapQueryName Name of the LDAP query to perform.
 * @param {fn} valueExtractor Function that takes each item from the LDAP query and returns the value for the option.
 * @param {fn} textExtractor Function that takes each item from the LDAP query and returns the displayed for the option. If not given, uses the valueExtractor.
 * @param {fn} check Function that takes each item and returns `true` iff the item is to be used as an option for the select element, otherwise false. If not given, every item is used.
 * @param {string} delimiter Delimiter for the queryParameters for the LDAP query. Defaults to a comma (",").
 * @param {string} queryParameter Optional query parameter for the LDAP query. Must be separated by the given delimiter.
 * @param {fn} sortBy Optional comparator function for sorting the items. if not given, no sort is performed. Takes two arguments and returns -1 iff the first argument is strictly smaller than the second argument, +1 iff the first argument is strictly greater than the second; or 0 otherwise.
 * @param {boolean} autocomplete Whether the select element should be converted to an autocomplete, ie. a text input field offering suggestions. Defaults to `false`.
 * @param {boolean} loadingText Text shown to the user while loading the data. It is displayed as the the text of the only option of the select element (with an empty value). Defaults to a generic message.
 * @param {string} errorText Text shown to the user in case an error occurs. It is displayed as the the text of the only option of the select element (with an empty value). Defaults to a generic message.
 * @param {boolean} treatEmptyAsError Whether an empty data set returned by the LDAP query is considered an error. Defaults to `true`.
 */

function comboboxWithLdap(_ref2) {
   var selectName = _ref2.selectName,
        ldapQueryName = _ref2.ldapQueryName,
        valueExtractor = _ref2.valueExtractor,
        _ref2$textName = _ref2.textName,
        textName = _ref2$textName === undefined ? selectName + "_value" : _ref2$textName,
        _ref2$textExtractor = _ref2.textExtractor,
        textExtractor = _ref2$textExtractor === undefined ? valueExtractor : _ref2$textExtractor,
        _ref2$check = _ref2.check,
        check = _ref2$check === undefined ? function () {
       return true;
    } : _ref2$check,
        _ref2$delimiter = _ref2.delimiter,
        delimiter = _ref2$delimiter === undefined ? "," : _ref2$delimiter,
        _ref2$queryParameter = _ref2.queryParameter,
        queryParameter = _ref2$queryParameter === undefined ? undefined : _ref2$queryParameter,
        _ref2$sortBy = _ref2.sortBy,
        sortBy = _ref2$sortBy === undefined ? undefined : _ref2$sortBy,
        _ref2$autocomplete = _ref2.autocomplete,
        autocomplete = _ref2$autocomplete === undefined ? false : _ref2$autocomplete,
        _ref2$treatEmptyAsErr = _ref2.treatEmptyAsError,
        treatEmptyAsError = _ref2$treatEmptyAsErr === undefined ? true : _ref2$treatEmptyAsErr,
        _ref2$loadingText = _ref2.loadingText,
        loadingText = _ref2$loadingText === undefined ? "Fetching data, hold on." : _ref2$loadingText,
        _ref2$errorText = _ref2.errorText,
        errorText = _ref2$errorText === undefined ? "Could not fetch data due to a network error." : _ref2$errorText;

   // Find the element, Do nothing iff the element does not exist.
   var $element = $(document.getElementsByName(selectName)[0]);
   var $textElement = $(document.getElementsByName(textName)[0]);
   if ($element.length < 1 || $textElement.length < 1) {
        console.error("Did not find the select and/or text element", $element, $textElement);
       return;
    }
   // Inform the user we are loading the data.
   setOptions($element, {}, undefined, loadingText);
    $element.val("");
   // Run the LDAP query.
   ldapQuery({
        name: ldapQueryName,
        queryParameter: queryParameter,
        delimiter: delimiter,
        treatEmptyAsError: treatEmptyAsError,
        callback: function callback(data) {
           // Sort the data we received.
           if (sortBy) data = data.sort(sortBy);
           // Take the person's mail as the value, and their name as the displayed text of the option.
           var options = data.reduce(function (opts, item) {
               // Check if this item is to be used as an option.
               if (check(item)) {
                   // Extract the text and the value of the option from the item.
                   opts[valueExtractor(item)] = textExtractor(item);
                }
               return opts;
            }, {});
           // Setup the select element with the options.
           setOptions($element, options, $textElement);
           if (autocomplete) {
                $element.cob2auto();
            }
        },
       // Log the error and inform the user about the error.
       errorCallback: function errorCallback(error) {
            console.error("Failed to load data from LDAP query.", "ldapQueryName:", ldapQueryName, "selectName:", selectName, error);
           // Do not pass the hidden text element, otherwise the currently selected option would be discarded.
           setOptions($element, {}, undefined, errorText);
            $element.val("");
        }
    });
}

comboboxWithLdap({
    selectName: "selPeople",
    ldapQueryName: "LDAP_Abfrage",
    check: function check(item) {
       return item.mail && item.sn;
    },
    valueExtractor: function valueExtractor(item) {
       return item.mail;
    },
    textExtractor: function textExtractor(item) {
       return item.givenName + " " + item.sn;
    },
    sortBy: sortBy("givenName", "sn")
});

comboboxWithLdap({
    selectName: "selPeopleAuto",
    ldapQueryName: "LDAP_Abfrage",
    check: function check(item) {
       return item.mail && item.sn;
    },
    valueExtractor: function valueExtractor(item) {
       return item.mail;
    },
    textExtractor: function textExtractor(item) {
       return item.givenName + " " + item.sn;
    },
    sortBy: sortBy("givenName", "sn"),
    autocomplete: true
});

comboboxWithLdap({
    selectName: "selInvalidLdap",
    ldapQueryName: "INVALID_QUERY",
    check: function check(item) {
       return item.mail && item.sn;
    },
    valueExtractor: function valueExtractor(item) {
       return item.mail;
    }
});

Extensions

The code on this page performs one LDAP request for each select element. If you need to setup multiple select elements with data from the same LDAP query, you should run it only once to reduce traffic. You could cache the result of the LDAP query or extend the function comboboxWithLdap, so that is accepts multiple select elements.

Tags:
Created by superadmin on 26.06.2018
Translated into en by Andre Wachsmuth on 26.06.2018
  
Copyright 2000-2018