Skip to content

Commit d11265c

Browse files
committed
Merge branch 'bersace-ldapadd' into hotfix-1.1.9
2 parents 6353a84 + dc5fbb9 commit d11265c

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,23 @@ For more information about docker data volume, please refer to:
104104

105105
Do not edit slapd.conf it's not used. To modify your server configuration use ldap utils: **ldapmodify / ldapadd / ldapdelete**
106106

107+
#### Seed ldap database with ldif
108+
109+
This image can load ldif files at startup with either `ldapadd` or `ldapmodify`.
110+
Mount `.ldif` in `/container/service/slapd/assets/config/bootstrap/ldif/`
111+
directory. Files containing `changeType:` attributes will be loaded with `ldapmodify`.
112+
113+
The startup script provide some substitution in bootstrap ldif files: `{{
114+
LDAP_BASE_DN }}` and `{{ LDAP_BACKEND }}` values are supported. Other `{{ * }}`
115+
substitution are left as is.
116+
117+
Since startup script modifies `ldif` files, you **must** add `--copy-service`
118+
argument to entrypoint.
119+
120+
docker run \
121+
--volume ./bootstrap.ldif:/container/service/slapd/assets/config/bootstrap/ldif/50-bootstrap.ldif \
122+
osixia/openldap:1.1.9 --copy-service
123+
107124
### Use an existing ldap database
108125

109126
This can be achieved by mounting host directories as volume.

image/service/slapd/startup.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,11 @@ EOF
229229
log-helper debug "Processing file ${f}"
230230
sed -i "s|{{ LDAP_BASE_DN }}|${LDAP_BASE_DN}|g" $f
231231
sed -i "s|{{ LDAP_BACKEND }}|${LDAP_BACKEND}|g" $f
232-
ldapmodify -Y EXTERNAL -Q -H ldapi:/// -f $f 2>&1 | log-helper debug || ldapmodify -h localhost -p 389 -D cn=admin,$LDAP_BASE_DN -w $LDAP_ADMIN_PASSWORD -f $f 2>&1 | log-helper debug
232+
if grep -iq changetype $f ; then
233+
ldapmodify -Y EXTERNAL -Q -H ldapi:/// -f $f 2>&1 | log-helper debug || ldapmodify -h localhost -p 389 -D cn=admin,$LDAP_BASE_DN -w $LDAP_ADMIN_PASSWORD -f $f 2>&1 | log-helper debug
234+
else
235+
ldapadd -Y EXTERNAL -Q -H ldapi:/// -f $f |& log-helper debug
236+
fi
233237
done
234238

235239
# read only user

0 commit comments

Comments
 (0)