Sunday, October 14, 2012

Mule ldap Connector

Ldap connector in mule has been broken for some time now. The good news however is that with mule 3.3 the ldap connector has been fixed.
Couldn't find any example for using the ldap connector so here is my poc for the same.

Just some basic concepts i learnt along the way,
baseDn --> its the top level in the ldap directory tree that you want to start your querying from.
                   e.g OU=Locations,dc=anil,dc=com (for something like anil.com)
authDn --> this is usually the authentication username with domain name usually
                  eg. apuliyeril@anil.com


http://jxplorer.org/ is a wonderful ldap browser that helps you start your venture and understand the structure of your ldap.

I'm not sure if the older versions of mule supports this but mule 3.3 does so if it doesn't seem to work you need to upgrade to mule 3.3.

Add the following link to you mule plugin updates.

If you are not sure how to add a plugin refer
install connector step.


Make a new project called Ldap connector with a mule-flow in it.

The ldap mule config

In this simple example there is a http endpoint which when you hit gives a list of csv of the user details present in the system. url needs to be given with the port (389) the authentication used here is simple There are different scopes available scope="SUB_TREE" is the one used here, this will search through out the tree structure and fetch all the information present.
Filter refers to the search filter here it is an and of  objectCategory=person and objectclass=user


The groovy file for the same
The groovy logic is pretty much straight forward. it is fetching the fields from the message.payload if the value is not null.
The tricky part is the date. it needs a formatter as it uses the UTC time format to show the data.