Thursday, November 17, 2022
HomeData ScienceCreate an LDAP Sandbox for Pipeline Testing | by Henry Alpert |...

Create an LDAP Sandbox for Pipeline Testing | by Henry Alpert | Nov, 2022


Use Docker containers, both domestically or within the cloud

Photograph by Laura Ockel on Unsplash

Many corporations use LDAP, or Light-weight Listing Entry Protocol, to retailer details about workers and to permit workers to entry organizational sources relying on what their particular person roles are. Microsoft’s Lively Listing (AD) is the best-known database that makes use of this protocol.

For a current information engineering challenge, a consumer wanted a pipeline created that may batch-add new workers to its on-premise AD and assign these new workers roles, usernames, and different attributes primarily based on varied distinctive components. Whereas engaged on the challenge, I wanted some option to take a look at my work in progress. However the consumer couldn’t permit entry to the AD server due to safety causes, and even when they might, the server was in energetic use and never a very good platform for testing.

To create a testing sandbox for this pipeline, I used:

  • Docker and a cloud service, in my case Azure. As an alternative of a cloud service, I may additionally use a tunneling service to my native machine.
  • An interface to work together with the server
  • A pipeline integration platform, in my case SnapLogic

Listed here are my steps to create the sandbox, with a few totally different choices proven.

OpenLDAP is an open-source implementation of LDAP, and I’m working it utilizing the osixia/openldap docker picture. (Try the hyperlinks for documentation.)

Possibility 1: Run it as an Azure container occasion

I first want an Azure account and to have the Azure CLI put in on my pc. Then, I run the next within the terminal:

When the container is created, it seems within the Azure portal within the useful resource group’s container situations. Discover in the proper column how Azure has assigned the container a public IP deal with.

Possibility 2: Run the container in your native machine

You may not have a subscription to Azure or one other cloud service, otherwise you simply might choose to run the container domestically. With docker put in on my Mac, I create a docker container with an equal command to the one for Azure above.

LDAP servers use port 389 in order that must be included within the -p flags. Port 636 is usually used as nicely.

Possibility 1: Spin up an interface in a docker container

Based on its primary web page, “phpLDAPadmin is a web-based LDAP consumer. It offers straightforward, anywhere-accessible, multi-language administration on your LDAP server.” And like with the OpenLDAP server, this consumer exists as a docker picture; it’s discovered at osixia/phpldapadmin.

With this picture, I’m going to create the container domestically, however I’ll join it to the Azure occasion of the server. Observe how in an atmosphere variable, I embrace the IP deal with created by Azure for the LDAP server container.

The consumer container makes use of port 443, and the picture documentation says to map it to port 6443. When it’s up and working, I can go to localhost:6443 to entry the consumer. I’m introduced with a login web page.

I exploit the atmosphere variables I outlined when creating the server on Azure for the login credentials. Observe, nonetheless, the login username isn’t merely admin. I want the admin’s distinguished identify, which on this case is cn=admin,dc=instance,dc=com, and in an atmosphere variable, the password I outlined as pass_word.

As soon as I login, I can create pattern consumer accounts, organizational models, and different objects.

Possibility 2: Create a tunnel to your localhost

If I selected to do Possibility 2 above the place I created the container on my native machine, I may join the native server to the native consumer interface container, however do not forget that finally I need to join the LDAP server to an information integration platform, and that platform is within the cloud. To get that connection from the cloud to a server on my native machine to work, I must work out tips on how to bypass the firewall, take care of probably altering IP addresses, and different complications.

It simpler to create a tunnel, and a service referred to as ngrok permits me to do exactly that. Once I enroll, I get one free energetic tunnel, and as soon as the ngrok agent is put in on my pc, I can run:

ngrok tcp 389

That tells ngrok to create a TCP connection to port 389, which is mapped on the localhost to the server container. (It is advisable to use the TCP protocol as an alternative of HTTP, as a result of LDAP makes use of TCP.) Ngrok will generate a web page like this one within the terminal.

Discover the Forwarding line, the place a URL is forwarded to my localhost:389. That URL will likely be used within the subsequent step.

One other line to note is that the online interface is at http://127.0.0.1:4040. Ngrok lets you monitor the tunnel at that deal with, however for it to work, you might want to additionally publish port 4040 when creating the container.

As soon as once more, I want an interface to work together with the LDAP server. I may use phpLDAPadmin once more, however this time to indicate one other chance, I’ll use the Apache Listing Studio LDAP browser, which may be dowloaded at no cost for Home windows, Mac, and Linux.

When I’ve it put in, I can go to the connections pane and create a brand new connection. Within the Community Parameter panel, I enter the URL created by ngrok and its related ngrok port quantity (not port 389).

And within the Authentication panel, I’ll enter the identical distinguished identify and password as within the first choice above. When the connection is authenticated, I can begin including entries to the server.

As talked about earlier than, I’m utilizing SnapLogic for my pipeline. With a view to work together with the server, I’ve so as to add my account with the proper credentials within the platform.

If I’m doing Possibility 1 with the server working on a container on Azure, I want so as to add the URL created by Azure together with the usual LDAP port 389 and the admin’s distinguished identify and password.

If I’m doing Possibility 2 with the server working domestically on my machine, I want so as to add the ngrok tunnel’s URL, its port, and, once more, the admin’s distinguished identify and password.

And that ought to do it. I offered a few totally different choices. Whichever one I select, my sandbox is able to go.

OpenLDAP comes with commonplace object courses, however if you happen to want object courses with customized attributes, you’ll have so as to add your individual schema.

On this case, I’ll be exhibiting tips on how to do it with the native server.

To start, I create a textual content file with the extension of .schema. Right here, I’m saving it as cs.schema. Listed here are the contents of this file:

On this file, I’m creating solely two new attributes, ‘sAMAccountType’ and ‘myadditionnalAttr’ in a brand new object class referred to as ‘personnel’ which is predicated on inetOrgPerson. The primary attribute is an current one for LDAP and the second is a made-up one for this schema. For more information on LDAP schema construction, attributes, and codes, try different documentation such because the LDAP wiki.

Right here’s the docker command I exploit to to create a brand new container, which has similarities to the one above with a couple of modifications:

With the --volume flag, I’m mounting the schema file into a specific listing within the container. Additionally, for this to work proper, it seems I want to make use of the picture’s --copy-service command.

When the container is up and working, once more I can create a tunnel to it utilizing ngrok and proceed following the Possibility 2 steps above.

Possibility 1

  • Create a server container on a cloud platform similar to Azure
  • Create an interface container domestically and hyperlink it to the server within the cloud
  • Hyperlink the pipeline to the server within the cloud

Possibility 2

  • Create a server container domestically
  • Create a tunnel to the server
  • Hyperlink an interface to the server through the tunnel
  • Hyperlink the pipeline to the server through the tunnel
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments