Skip to content

Commit 2f80ce6

Browse files
committed
making sure we can completely customize the users DN and email. pre-requsite for letsencrypt certs
1 parent c61f87e commit 2f80ce6

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ EXPOSE 10389 10636
3737

3838
CMD ["/init"]
3939

40-
HEALTHCHECK CMD ldapsearch -H ldap://127.0.0.1:10389 -D cn=admin,dc=planetexpress,dc=com -w GoodNewsEveryone -b cn=admin,dc=planetexpress,dc=com
40+
HEALTHCHECK CMD ["ldapsearch", "-H", "ldap://127.0.0.1:10389", "-D", "${LDAP_BINDDN}", "-w", "${LDAP_SECRET}", "-b", "${LDAP_BINDDN}"]

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ ldapsearch -H ldap://localhost:10389 -ZZ -x -b "ou=people,dc=planetexpress,dc=co
4343
4444
# Enforce StartTLS with self-signed cert
4545
LDAPTLS_REQCERT=never ldapsearch -H ldap://localhost:10389 -ZZ -x -b "ou=people,dc=planetexpress,dc=com" -D "cn=admin,dc=planetexpress,dc=com" -w GoodNewsEveryone "(objectClass=inetOrgPerson)"
46-
47-
4846
```
4947

5048
## Exposed ports

docker-compose.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ services:
77
# image: rroemhild/test-openldap
88
environment:
99
LDAP_FORCE_STARTTLS: "true"
10-
10+
LDAP_DOMAIN: "customdomain.com"
11+
LDAP_BASEDN: "dc=customdomain,dc=com"
12+
LDAP_ORGANISATION: "Custom Domain, Inc."
13+
LDAP_BINDDN: "cn=admin,dc=customdomain,dc=com"
1114
# use build tag to use the local repo
1215
build:
1316
context: ./

rootfs/etc/cont-init.d/050-openldap-populate

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ load_initial_data() {
4040
local data=$(find ${DATA_DIR} -maxdepth 1 -name \*_\*.ldif -type f | sort)
4141
for ldif in ${data}; do
4242
echo "Processing file ${ldif}..."
43+
if [ ! -z "$LDAP_BASEDN" ]; then
44+
echo "updating base dn dc=planetexpress,dc=com -> ${LDAP_BASEDN}"
45+
sed -i "s/dc=planetexpress,dc=com/${LDAP_BASEDN}/g" "${ldif}"
46+
fi
47+
if [ "$LDAP_DOMAIN" != "planetexpress.com" ]; then
48+
echo "updating emails @planetexpress.com -> @${LDAP_DOMAIN}"
49+
sed -i "s/@planetexpress.com/@${LDAP_DOMAIN}/g" "${ldif}"
50+
fi
51+
4352
ldapadd -x -H ldapi:/// \
4453
-D ${LDAP_BINDDN} \
4554
-w ${LDAP_SECRET} \

rootfs/opt/openldap/bootstrap/data/10_people_bender.ldif

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
dn:: Y249QmVuZGVyIEJlbmRpbmcgUm9kcsOtZ3VleixvdT1wZW9wbGUsZGM9cGxhbmV0ZXhwcmV
2-
zcyxkYz1jb20=
1+
dn: cn=Bender Bending Rodriguez,ou=people,dc=planetexpress,dc=com
32
objectClass: inetOrgPerson
43
objectClass: organizationalPerson
54
objectClass: person
65
objectClass: top
7-
cn:: QmVuZGVyIEJlbmRpbmcgUm9kcsOtZ3Vleg==
8-
sn:: Um9kcsOtZ3Vleg==
6+
cn: cn=Bender Bending Rodriguez
7+
sn: Rodriguez
98
description: Robot
109
displayName: Bender
1110
employeeType: Ship's Robot

0 commit comments

Comments
 (0)