CodeBlog
Published in

CodeBlog

WSO2 EI with LDAP Connector

LDAP with WSO2

The Lightweight Directory Access Protocol (LDAP)is an open, industry standard application protocol for accessing and maintaining distributed directory information services over an Internet Protocol.

In this blog we are going to use WSO2 EI LDAP connector [1]to connect to Apache Directory and perform CRUD (Create, Read, Update, Delete) operations on LDAP entries. WSO2 LDAP connector use JAVA JNDI APIs to connect to a required LDAP server.
GitHub Project

Below is the system diagram of what we are going to create.

System Diagram

Prerequisites:

Lets create an integration project using WSO2 Enterprise studio.
Go to File> New> Integration Project

Creating an integration Project

Then a window will open to name your integration project. I have named my project as ldap_project.

Now I’ll be creating an API and this API will have 4 resources which will add, search, update and delete LDAP entries of employees. In the blog i’ll explain how to create the add employee function. You can find the full project from GitHub.

Lets create an API by going to ldap_projectConfigs > src > main >synapse-config right click on the api and go to new >REST API create an API name Employee.

After creating the API, You have to add the LDAP connector to to the workspace. To do the right click on the ldap_projectConfigs and go to New> Other and search for Add Connector to workspace Select it and go next and search for LDAP connector and download it and add it to the workspace.

In the API, I’ll be adding some property mediator in the in- sequence. This is to get the values from the payload that we are sending to the API and set it to the LDAP connector properties. Below is the full configuration of my Employee API.

Now we have to add the connector to the .car apps. To do that we have to create a connector exporter project by right clicking on the ldap_projectConfigs folder and New > other and select Connector Exporter and click next. Then give a name for the connector exporter project and click finish.

After that you have to add the LDAP connector to this project. To do that you find the created project from the Project Explorer and right click on it and go to new > Add/Remove connectors. Then click the workspace button and select the LDAP connector and click finish.

Lets deploy the .car file to the WSO2 MI server.
To do that go to ldap_projectCompositeExporter > pom.xml and tick the folders as below to be included in the .car

Now right click on the ldap_projectCompositeExporter and click on Export project artifact and run.

Now MI server will start and deploy the .car file to it. You can check if the the .car file deployed correctly from the console.

Before invoking the API you have to start the Apache Directory studio and start the server.

Lets invoke the Employee API using the below payload to add a employee entry to LDAP server. Im going to add a employee name kamal to LDAP sever.

I’ll be using postman to test this API call.

I’m going to send a POST request to the http://localhost:8290/employee/addemp

In the body of the request I’m going to include the below payload

You will get a successful response back as below.

Now lets see if this kamal entry has really got added to LDAP sever. As you can see below the entry has been added, Simple Right 😃.

[1]. https://ei.docs.wso2.com/en/7.2.0/micro-integrator/references/connectors/ldap-connector/ldap-connector-overview/

--

--

--

All about new goodies for people who are intrested in coding

Recommended from Medium

HMART — Simple Grocery Story Mobile Application with HMS Kit

Create a New User in ArgoCD using the CLI and ConfigMap

How to learn a programming language in a week

Getting started with RealityKit: Collisions and other Events

Code Signing Certificates are not enough

Java Interview Series: JUnit

Baking is for cookies (not code)

Amazon SQS service use case

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Isuru Liyanage

Isuru Liyanage

Software engineer @ WSO2

More from Medium

Practical Progressive Delivery with Argo Rollouts — Setup

Proposal for use case, Middleware Rack stack Call:

Pulsar Pseudo Cluster Deployment

Secure connections using Shared Signals and Events (SSE) Framework