A complete LDAP server setup with LDAPS (LDAP over SSL) support using self-signed certificates. Features automatic directory structure loading and comprehensive testing.
- ✅ LDAP on port 389 (unencrypted)
- ✅ LDAPS on port 636 (SSL encrypted with self-signed certificates)
- ✅ Automatic structure loading - No manual LDIF imports needed
- ✅ Pre-configured users and service accounts
- ✅ phpLDAPadmin web interface
- ✅ Comprehensive test suites
chmod +x generate-certs.sh
./generate-certs.shdocker-compose up -dThis will:
- Start OpenLDAP with SSL/TLS enabled
- Automatically load the directory structure from
01-structure.ldif - Start phpLDAPadmin web interface
- Make both LDAP (389) and LDAPS (636) available
chmod +x test-ldap.sh test-ldaps.sh
./test-ldap.sh # Tests general LDAP functionality
./test-ldaps.sh # Tests SSL/TLS specific features- LDAP (unencrypted):
ldap://localhost:389 - LDAPS (SSL):
ldaps://localhost:636
- Base DN:
dc=example,dc=local - Admin DN:
cn=admin,dc=example,dc=local - Admin Password:
admin123
- Bind DN:
cn=svc_elk_ldap,ou=Service_Accounts,ou=User_Accounts,dc=example,dc=local - Password:
ServiceAccount123!
| User | Username | Password |
|---|---|---|
| John Doe | uid=jdoe |
UserPassword123! |
| Jane Smith | uid=jsmith |
UserPassword123! |
| Test User | uid=testuser |
TestPassword123! |
- URL: http://localhost:8080
- Login DN:
cn=admin,dc=example,dc=local - Password:
admin123
The following structure is automatically created:
dc=example,dc=local
└── ou=User_Accounts
├── ou=Service_Accounts
│ └── cn=svc_elk_ldap (service account)
├── cn=John Doe (test user)
├── cn=Jane Smith (test user)
└── cn=Test User (test user)
# Ignore certificate verification (development only)
LDAPTLS_REQCERT=never ldapsearch -x -H ldaps://localhost:636 \
-D "cn=admin,dc=example,dc=local" \
-w "admin123" \
-b "dc=example,dc=local" \
"(objectClass=*)"# Export the CA certificate
docker exec ldap-server cat /container/service/slapd/assets/certs/ca.crt > ca.crt
# Add to system keychain
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ca.crtLDAPTLS_REQCERT=never ldapsearch -x -H ldaps://localhost:636 \
-D "cn=svc_elk_ldap,ou=Service_Accounts,ou=User_Accounts,dc=example,dc=local" \
-w 'ServiceAccount123!' \
-b "ou=User_Accounts,dc=example,dc=local" \
"(objectClass=inetOrgPerson)"ldapsearch -x -H ldap://localhost:389 \
-D "cn=svc_elk_ldap,ou=Service_Accounts,ou=User_Accounts,dc=example,dc=local" \
-w 'ServiceAccount123!' \
-b "ou=User_Accounts,dc=example,dc=local" \
"(objectClass=inetOrgPerson)"# Via LDAPS
LDAPTLS_REQCERT=never ldapwhoami -x -H ldaps://localhost:636 \
-D "cn=John Doe,ou=User_Accounts,dc=example,dc=local" \
-w 'UserPassword123!'
# Via LDAP
ldapwhoami -x -H ldap://localhost:389 \
-D "cn=John Doe,ou=User_Accounts,dc=example,dc=local" \
-w 'UserPassword123!'generate-certs.sh- Generates self-signed SSL certificatesdocker-compose.yml- Container configuration with SSL settings01-structure.ldif- Directory structure and users (auto-loaded)load-structure.sh- Script that loads LDIF (runs automatically)test-ldap.sh- General LDAP functionality teststest-ldaps.sh- SSL/TLS specific testscleanup.sh- Removes all containers, data, and certificates
docker-compose logs -f openldapecho | openssl s_client -connect localhost:636 -showcerts./cleanup.sh
./generate-certs.sh
docker-compose up -d- SSL Certificates: The
generate-certs.shscript creates self-signed certificates in the./certsdirectory - Automatic Loading: The
ldap-loadercontainer waits for the LDAP server to be healthy, then loads01-structure.ldif - Dual Protocol: Both LDAP (389) and LDAPS (636) are available simultaneously
- Health Checks: Docker health checks ensure the server is ready before loading data
- This setup uses self-signed certificates suitable for development/testing
- For production, use proper CA-signed certificates
- Default passwords should be changed in production environments
- The
LDAPTLS_REQCERT=neveroption should not be used in production
To completely remove the LDAP environment:
./cleanup.shThis removes:
- All Docker containers and volumes
- LDAP data directory
- Generated certificates
- Temporary files