Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET embedded LDAP server

Tags:

c#

ldap

Is there any embedded LDAP server that could be used in integration tests written in c#? I know some java solutions, but can't find anything for .NET.

Thanks, Michal

like image 491
Michal Avatar asked May 03 '26 12:05

Michal


1 Answers

I like to use docker images for testing. Somebody else has already done the work of setting up the environment. All you have to do is set a few configuration variables and run docker-compose up. Here is one such environment: [docker-test-openldap][1] Install Docker, Create a docker compose yml file with the settings for this project. Then from the same directory, run:

Docker-compose up

This starts a virtual service exposing the ports in the way you configured in the file. Docker does all the work of downloading and managing the services for you so all you have to focus on is the yml file. Here is a sample yml file from the repo.

version: '2'

services:
    ldap:
        container_name: ldap
        # use the image tag to pull directly from the repo
        # image: rroemhild/test-openldap
        environment:
            LDAP_FORCE_STARTTLS: "true"
            LDAP_DOMAIN: "customdomain.com"
            LDAP_BASEDN: "dc=customdomain,dc=com"
            LDAP_ORGANISATION: "Custom Domain, Inc."
            LDAP_BINDDN: "cn=admin,dc=customdomain,dc=com"
        # use build tag to use the local repo
        build:
            context: ./
            dockerfile: ./Dockerfile
        ports:
            - '10389:10389'
            - '10636:10636'
#        volumes:
#            - data_volume:/var/lib/ldap/
#
#volumes:
#    data_volume:

You can see the ports are configurable. In this sample, port 10389 is mapped to the same port, but if you're using that port, you can change it. Uncommit the image line to download the image automatically (then commit the build section), and uncommit the volume section if you need the image to hold persistent data, (not be reset every time you start the image) [1]: https://github.com/rroemhild/docker-test-openldap

like image 89
Alex T. Avatar answered May 06 '26 01:05

Alex T.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!