Klipfolio. The KPI Dashboard - Evolved
The KPI Dashboard – Evolved
1-877-233-6149
Contact Us

Displaying data from the LDAP directory server

Problem:

I want to make use of LDAP to retrive data from my LDAP directory server.

Solution:

This object is only available in a licensed version of Klipfolio Dashboard. Contact Klipfolio for further details.

LDAP (Lightweight Directory Access Protocol) is a protocol that allows you to access data from an information directory of entries, such as contact information, from a server via TCP/IP. An example can be accessing organizational structure within an "employee" directory, which consists of a list of names, e-mail addresses, and telephone numbers.

Download the sample LDAP Klip.

To illustrate how to use this feature, we will use a simple example by building a Klip that obtains information from your LDAP directory. According to the API, the Engines.LDAP.search(...) function requires a query as input, which contains the search filters. The LDAP query is a string based on the RFC 2254 syntax. Consider the following example where we attempt to access data using LDAP:


function onLoad () {
    query = "(&(objectClass=person)(|(givenName=A*)(mail=A*)))";

    // Send the LDAP query
    var ar = Engines.LDAP.search (
        query,
        "cn,title,mail,telephoneNumber"
    );

    // Process the response from the LDAP query
    Items.clear (true);
    Engines.Data.process (ar);
}

The query stores the search filters, which needs to be in prefix notation (Polish notation). In prefix notation, the operator precedes the operands. In this example, we want to filter out "all items that are a person AND have either their givenName OR e-mail address to start with the letter A".

The attribute is an optional argument, and will store the attribute names that we want returned. As a result, you should create a stylesheet to map the elements to columns in the Klip. For example:


    <style>
        row 
        {
            type: item; 
            definition: all;
        }
        cn
        {
            itemcol: 1; 
            noterow: 1; 
            emphasis: strong; 
            notelabel: false; 
            label: "Employee Name";
            name: "EmployeeName";
            wrap: false;
        } 
        mail
        {
            itemcol: 2; 
            noterow: 2; 
            notelabel: false; 
            label: "Email Address";
            name: "mail";
            wrap: false;
        } 
        telephoneNumber 
        {
            itemcol: 3; 
            noterow: 3; 
            label: "Phone #";
            wrap: false;
        }
    </style>

Going back to the onLoad(...) function, the query and attribute variables are then passed to the Engines.LDAP.search(...), and we then call Engines.Data.process(...) to extract and create an Item object, and update the Klip.

Using the Engines.LDAP object provides a simple method to retrieve information from your LDAP directory server. To see the complete source code for this example, check out the sample LDAP Klip.

Leave a Comment

To leave a comment, you must sign in or register (it's free).

   
Comment Type:
Title:
Comment: