testcontainers-dotnet icon indicating copy to clipboard operation
testcontainers-dotnet copied to clipboard

[Enhancement]: Add new module for OpenLDAP support (Testcontainers.Ldap)

Open alisadeghi77 opened this issue 7 months ago • 2 comments

Problem

Currently, Testcontainers for .NET does not provide any built-in support for LDAP services. Developers who need to test applications relying on directory services like OpenLDAP or Active Directory must manually configure containers using the generic TestcontainersBuilder.

In the past week, I implemented a custom LDAP test container from scratch for one of my projects. The process of loading and setting up the LDAP configuration was complicated and prone to bugs, especially for developers without deep knowledge of LDAP protocols and setup details. This increases maintenance overhead and reduces test reliability.

Solution

Initially, implement a basic configuration that provides a ready-to-use OpenLDAP container with default settings (admin user, password, domain, port mapping). Then, gradually develop the module to support configuring organizations, users, groups, and other LDAP entities internally within the container setup.

This approach aims to prevent increased maintenance overhead and reduce test reliability issues by hiding complex LDAP setup details from users and providing sensible defaults out-of-the-box.

var container = new LdapBuilder().Build();
await container.StartAsync();
var ldapConfig = container.GetLdapConnectionConfig();
container.AddOrganization("");

Benefit

  • Simplifies LDAP integration testing with a ready-to-use container.
  • Reduces setup time and errors for developers.

Alternatives

  • Use generic TestcontainersBuilder with manual LDAP setup.
  • Use in-memory or mock LDAP servers (less realistic).

Would you like to help contributing this enhancement?

Yes

alisadeghi77 avatar Jun 12 '25 15:06 alisadeghi77

Thanks for bringing this up. Are you referring to bitnami/openldap? That sounds like a good idea. There's already a Java implementation available, and we usually try to keep the implementations aligned.

HofmeisterAn avatar Jun 13 '25 05:06 HofmeisterAn

I started with osixia/openldap, but happy to switch to bitnami/openldap for alignment. I’ll review the Java module and follow the same approach.

alisadeghi77 avatar Jun 14 '25 14:06 alisadeghi77