Skip to content

Commit

Permalink
Merge branch 'bersace-ldapadd' into hotfix-1.1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
BertrandGouny committed Jul 19, 2017
2 parents 6353a84 + dc5fbb9 commit d11265c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,23 @@ For more information about docker data volume, please refer to:

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

#### Seed ldap database with ldif

This image can load ldif files at startup with either `ldapadd` or `ldapmodify`.
Mount `.ldif` in `/container/service/slapd/assets/config/bootstrap/ldif/`
directory. Files containing `changeType:` attributes will be loaded with `ldapmodify`.

The startup script provide some substitution in bootstrap ldif files: `{{
LDAP_BASE_DN }}` and `{{ LDAP_BACKEND }}` values are supported. Other `{{ * }}`
substitution are left as is.

Since startup script modifies `ldif` files, you **must** add `--copy-service`
argument to entrypoint.

docker run \
--volume ./bootstrap.ldif:/container/service/slapd/assets/config/bootstrap/ldif/50-bootstrap.ldif \
osixia/openldap:1.1.9 --copy-service

### Use an existing ldap database

This can be achieved by mounting host directories as volume.
Expand Down
6 changes: 5 additions & 1 deletion image/service/slapd/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,11 @@ EOF
log-helper debug "Processing file ${f}"
sed -i "s|{{ LDAP_BASE_DN }}|${LDAP_BASE_DN}|g" $f
sed -i "s|{{ LDAP_BACKEND }}|${LDAP_BACKEND}|g" $f
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
if grep -iq changetype $f ; then
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
else
ldapadd -Y EXTERNAL -Q -H ldapi:/// -f $f |& log-helper debug
fi
done

# read only user
Expand Down

0 comments on commit d11265c

Please sign in to comment.