Extracting Data from LDAP icon

Extracting Data from LDAP

(0 reviews)

home

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

Example

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

Set Up and Run the Example

  1. Set up 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 the rootpw in the 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 successful, 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 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.

  9. Click ROOT DSE in the panel LDAP browser to 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 Inc.
Published by
MuleSoft Organization
Published onMar 17, 2018
Asset overview

Asset versions for 1.4.x

Asset versions
VersionActions
1.4.0