Extracting Data from LDAP icon

Extracting Data from LDAP

(0 reviews)

home

Learn how to connect to an LDAP directory using Mule and retrieve a list of users.


Screenshot of the main flow in Anypoint Studio, view full image here

Description

This example illustrates how to connect to an LDAP directory in Mule and retrieve a list of users stored in it.

Example Use Case

The example application connects to the LDAP directory and retrieves a list of LDAP users. This list is then split into individual rows, logged and then aggregated back to a single list. We use Flow control Components such as the Collection Splitter and the Collection Aggregator to do so.

Set Up and Run the Example

  1. Setup LDAP on your machine

    • For Windows: Install OpenLDAP.
    • For MacOS: OpenLDAP comes bundled with MacOS, so no need to download LDAP.
  2. Install Apache Directory Studio.

  3. Navigate to etc\openldap\slapd.conf in your OpenLDAP installation directory and set rootpw in BDB database definitions section to root.

  4. Start the LDAP server

    • For Windows: Enter libexec\StartLDAP.cmd in the command line.
    • For MacOS: Enter sudo /usr/libexec/slapd -d 255
  5. Start Apache Directory Studio and create a new connection, File > New ... > LDAP Connection using following setup:

     name        local LDAP
     hostname    localhost
     port        389

    Click Check network parameter. if the test is not succesful, your ldap server is not running, otherwise click Next.

  6. Set Bind dn or user to cn=Manager,dc=my-domain,dc=com and Bind password to root. Click Check Authentication to verify the connection. Click Finish.

  7. Click File > Import... > LDIF into LDAP and then click Next.

  8. Set a path to ldap.ldif located in the scr/test/resources directory of this project. Set Import into to local LDAP. Click Finish to finish the import process.

  9. If you click on ROOT DSE in the panel LDAP browser, you should see the imported data structure.

  10. Create the example application in Anypoint Studio.

  11. Double-click on ldap.xml under src/main/app directory and open Global Elements tab. Open LDAP configuration and fill in these values if you strictly followed the instructions:

    Principal DN    cn=Manager,dc=my-domain,dc=com
    Password        root
    URL             ldap://localhost:389/dc=my-domain,dc=com
  12. Run it as Mule Application.

  13. Open your browser and type http://localhost:8081/ in the address bar.

  14. You should see three user records logged in the console output similar to this one:

    [dn: cn=mmc,ou=people
    uid: mmc
    sn: mmc
    userPassword:: bW1jMTIz
    cn: mmc
    objectClass: top
    objectClass: person
    objectClass: organizationalPerson
    objectClass: inetOrgPerson
    
    , dn: cn=testuser1,ou=people
    uid: testuser1
    sn: testuser1
    userPassword:: dGVzdHVzZXIxMTIz
    cn: testuser1
    objectClass: top
    objectClass: person
    objectClass: organizationalPerson
    objectClass: inetOrgPerson
    
    , dn: cn=admin,ou=people
    uid: admin
    sn: admin
    userPassword:: bW1jYWRtaW4=
    cn: admin
    objectClass: top
    objectClass: person
    objectClass: organizationalPerson
    objectClass: inetOrgPerson
    
    ]

Documentation

Read full documentation in GitHub


Reviews

TypeExample
OrganizationMuleSoft
Published by
MuleSoft Organization
Published onJun 22, 2017
Asset overview

Asset versions for 1.3.x

Asset versions
VersionActions
1.3.3