Mule 4 LDAP Operations:

  1. Search
  2. Create OU(organizationalUnit)
  3. Create a user
  4. Modify
  5. Delete

Pre-requisites:

  1. MuleSoft Anypoint Studio 7
  2. Java 8
  3. OpenLDAP, OUD, OID, Microsoft AD.

Acronyms:

mule ldap acronyms

1. Search operation

Step 1: Create a project in MuleSoft Anypoint Studio and drag and drop all the required components from the Mule component palette as shown in the below flow.

ldap sample flow

Step 2: Installed Oracle unified directory LDAP server, as mentioned in the below screenshot. Next, traverse the tree structure of the LDAP server.

unified directory ldap server

Step 3: In the search component we must configure LDAP server details.

ldap configuration

Step 4: After configuring LDAP server details we must provide the Distinguished Name (DN) and filter (should be Common Name(CN)) these are the main fields to search in the LDAP server.

OUDSearch DN filter

Step 5: Once the application has run, it must be deployed status.

deployed status

Step 6: To test the result open postman hit the send button, and see the result below. The common name ramesh was used as a filter for the results given below. localhost:8089/oud

postman hit send

2. Create OU(organizationalUnit)

Step 1: Create a project in MuleSoft Anypoint Studio. Drag and drop all the required components from the Mule component palette as mentioned in the below flow.

ldap ou creation flow

Step 2: In the add entry component tab, we need to select the structural class as organizationalUnit because I am creating a group on to the LDAP server to create multiple users on this unit.

organizationalunit

Step 3: In DataWeave I am creating a group as DevOpsGroup like organizational Unit(OU). Here I am getting Distinguished Name(dn) from queryparams.

Top Class: is the superclass of all the classes in every LDAP server’s language. if you want to create any user or OU etc…. we must import top class.

ldapgroup

Step 4: Once we hit the API from postman we can see the logs for add entry operation in the console like below for the organizational Unit.

logs add entry

Logs:

logs

Step 5: I have logged into OUD LDAP server and refreshed it to get the updated entry onto the server. Now I can able to see the LDAPGroup OU creation.

ldapgroup ou

3. Create a user under OU:

Step 1: Create a project in MuleSoft Anypoint Studio. Drag and drop all the required components from the Mule component palette as mentioned in the below flow.

user creation flow

Step 2: In add entry component we need to select the structural class as Person because I am creating a user on to the LDAP server.

structural class person

Step 3: In DataWeave I am creating a user LdapUser as common name (cn) into DevOpsGroup organizationalUnit(OU). Here I am getting Distinguished Name(dn) from queryparams.

devopsgroup

Step 4: Once we hit the API from postman we can see the logs for add entry operation in the console like below.

postman logs

Logs:

logs

Step 5: I have logged into OUD LDAP server and refreshed it to get the updated entry on to the server. Now, I am able to see the LdapUser creation.

oud ldap server

4. Modify a User:

Step 1: Create a project in MuleSoft Anypoint Studio. Drag and drop all the required components from the Mule component palette as below flow.

modifyldapuserflow

Step 2: In modify entry component, we need to select the structural class as Person because I am modifying a user’s data onto the LDAP server.

modify entry

Step 3: Before modifying the user’s data, DataWeave code needs to be written as mentioned below.

dataweavecode

Step 4: After modifying the user’s data DataWeave could be like below. Here I am trying to modify LdapUser’s data.

ldapusersdata

Step 5: Once we hit the API from the postman, can see the logs for modified entry data in the console like below.

modified data entry

Logs:

logs

Step 6: Before modifying the user’s data in OUD LDAP server

user data

After the modified operation, the user’s data changed as shown below.

user data

5. Delete operation:

Step 1: Create a project in MuleSoft Anypoint Studio. Drag and drop all the required components from the Mule component palette as mentioned in the below flow.

oucdeleteuserflow

Step 2: In the delete component, we must provide the DN. The user will delete based on the DN condition like below.

DN

Step 3: Once we hit the API from postman we can see the logs for add entry operation in the console like below.

logs
logs

Step 4: Before deleting a user on the LDAP server we can see Test User as mentioned in the below screen.

test user

After deleting a user on the LDAP server.

delete user

XTIVIA Blog CTA MuleSoft

Ran into trouble trying to complete the Mule 4 LDAP connectivity or any associated operations? XTIVIA is here to help whether you need assistance with just a specific problem or even completing the task for you. If you would like to learn more about how we can help you with your MuleSoft integration, don’t hesitate to contact us today. We also have a great MuleSoft blog, check it out here!