diff --git a/bitnami/openldap/2.5/debian-11/rootfs/opt/bitnami/scripts/libopenldap.sh b/bitnami/openldap/2.5/debian-11/rootfs/opt/bitnami/scripts/libopenldap.sh index 5aa54187cfecd..2d078706f99c3 100644 --- a/bitnami/openldap/2.5/debian-11/rootfs/opt/bitnami/scripts/libopenldap.sh +++ b/bitnami/openldap/2.5/debian-11/rootfs/opt/bitnami/scripts/libopenldap.sh @@ -65,7 +65,8 @@ export LDAP_EXTRA_SCHEMAS="${LDAP_EXTRA_SCHEMAS:-cosine,inetorgperson,nis}" export LDAP_SKIP_DEFAULT_TREE="${LDAP_SKIP_DEFAULT_TREE:-no}" export LDAP_USERS="${LDAP_USERS:-user01,user02}" export LDAP_PASSWORDS="${LDAP_PASSWORDS:-bitnami1,bitnami2}" -export LDAP_USER_DC="${LDAP_USER_DC:-users}" +export LDAP_USER_OU="${LDAP_USER_OU:-users}" +export LDAP_GROUP_OU="${LDAP_GROUP_OU:-groups}" export LDAP_GROUP="${LDAP_GROUP:-readers}" export LDAP_ENABLE_TLS="${LDAP_ENABLE_TLS:-no}" export LDAP_REQUIRE_TLS="${LDAP_REQUIRE_TLS:-no}" @@ -512,10 +513,14 @@ objectClass: organization dc: $dc o: $o -dn: ${LDAP_USER_DC/#/ou=},${LDAP_ROOT} +dn: ${LDAP_USER_OU/#/ou=},${LDAP_ROOT} objectClass: organizationalUnit ou: users +dn: ${LDAP_GROUP_OU/#/ou=},${LDAP_ROOT} +objectClass: organizationalUnit +ou: groups + EOF read -r -a users <<< "$(tr ',;' ' ' <<< "${LDAP_USERS}")" read -r -a passwords <<< "$(tr ',;' ' ' <<< "${LDAP_PASSWORDS}")" @@ -523,7 +528,7 @@ EOF for user in "${users[@]}"; do cat >> "${LDAP_SHARE_DIR}/tree.ldif" << EOF # User $user creation -dn: ${user/#/cn=},${LDAP_USER_DC/#/ou=},${LDAP_ROOT} +dn: ${user/#/cn=},${LDAP_USER_OU/#/ou=},${LDAP_ROOT} cn: User$((index + 1 )) sn: Bar$((index + 1 )) objectClass: inetOrgPerson @@ -540,7 +545,7 @@ EOF done cat >> "${LDAP_SHARE_DIR}/tree.ldif" << EOF # Group creation -dn: ${LDAP_GROUP/#/cn=},${LDAP_USER_DC/#/ou=},${LDAP_ROOT} +dn: ${LDAP_GROUP/#/cn=},${LDAP_GROUP_OU/#/ou=},${LDAP_ROOT} cn: $LDAP_GROUP objectClass: groupOfNames # User group membership @@ -548,7 +553,7 @@ EOF for user in "${users[@]}"; do cat >> "${LDAP_SHARE_DIR}/tree.ldif" << EOF -member: ${user/#/cn=},${LDAP_USER_DC/#/ou=},${LDAP_ROOT} +member: ${user/#/cn=},${LDAP_USER_OU/#/ou=},${LDAP_ROOT} EOF done @@ -566,7 +571,7 @@ EOF ######################### ldap_add_custom_ldifs() { info "Loading custom LDIF files..." - warn "Ignoring LDAP_USERS, LDAP_PASSWORDS, LDAP_USER_DC and LDAP_GROUP environment variables..." + warn "Ignoring LDAP_USERS, LDAP_PASSWORDS, LDAP_USER_OU, LDAP_GROUP_OU and LDAP_GROUP environment variables..." find "$LDAP_CUSTOM_LDIF_DIR" -maxdepth 1 \( -type f -o -type l \) -iname '*.ldif' -print0 | sort -z | xargs --null -I{} bash -c ". /opt/bitnami/scripts/libos.sh && debug_execute ldapadd -f {} -H 'ldapi:///' -D \"$LDAP_ADMIN_DN\" -w \"$LDAP_ADMIN_PASSWORD\"" } diff --git a/bitnami/openldap/2.6/debian-11/rootfs/opt/bitnami/scripts/libopenldap.sh b/bitnami/openldap/2.6/debian-11/rootfs/opt/bitnami/scripts/libopenldap.sh index 5aa54187cfecd..2d078706f99c3 100644 --- a/bitnami/openldap/2.6/debian-11/rootfs/opt/bitnami/scripts/libopenldap.sh +++ b/bitnami/openldap/2.6/debian-11/rootfs/opt/bitnami/scripts/libopenldap.sh @@ -65,7 +65,8 @@ export LDAP_EXTRA_SCHEMAS="${LDAP_EXTRA_SCHEMAS:-cosine,inetorgperson,nis}" export LDAP_SKIP_DEFAULT_TREE="${LDAP_SKIP_DEFAULT_TREE:-no}" export LDAP_USERS="${LDAP_USERS:-user01,user02}" export LDAP_PASSWORDS="${LDAP_PASSWORDS:-bitnami1,bitnami2}" -export LDAP_USER_DC="${LDAP_USER_DC:-users}" +export LDAP_USER_OU="${LDAP_USER_OU:-users}" +export LDAP_GROUP_OU="${LDAP_GROUP_OU:-groups}" export LDAP_GROUP="${LDAP_GROUP:-readers}" export LDAP_ENABLE_TLS="${LDAP_ENABLE_TLS:-no}" export LDAP_REQUIRE_TLS="${LDAP_REQUIRE_TLS:-no}" @@ -512,10 +513,14 @@ objectClass: organization dc: $dc o: $o -dn: ${LDAP_USER_DC/#/ou=},${LDAP_ROOT} +dn: ${LDAP_USER_OU/#/ou=},${LDAP_ROOT} objectClass: organizationalUnit ou: users +dn: ${LDAP_GROUP_OU/#/ou=},${LDAP_ROOT} +objectClass: organizationalUnit +ou: groups + EOF read -r -a users <<< "$(tr ',;' ' ' <<< "${LDAP_USERS}")" read -r -a passwords <<< "$(tr ',;' ' ' <<< "${LDAP_PASSWORDS}")" @@ -523,7 +528,7 @@ EOF for user in "${users[@]}"; do cat >> "${LDAP_SHARE_DIR}/tree.ldif" << EOF # User $user creation -dn: ${user/#/cn=},${LDAP_USER_DC/#/ou=},${LDAP_ROOT} +dn: ${user/#/cn=},${LDAP_USER_OU/#/ou=},${LDAP_ROOT} cn: User$((index + 1 )) sn: Bar$((index + 1 )) objectClass: inetOrgPerson @@ -540,7 +545,7 @@ EOF done cat >> "${LDAP_SHARE_DIR}/tree.ldif" << EOF # Group creation -dn: ${LDAP_GROUP/#/cn=},${LDAP_USER_DC/#/ou=},${LDAP_ROOT} +dn: ${LDAP_GROUP/#/cn=},${LDAP_GROUP_OU/#/ou=},${LDAP_ROOT} cn: $LDAP_GROUP objectClass: groupOfNames # User group membership @@ -548,7 +553,7 @@ EOF for user in "${users[@]}"; do cat >> "${LDAP_SHARE_DIR}/tree.ldif" << EOF -member: ${user/#/cn=},${LDAP_USER_DC/#/ou=},${LDAP_ROOT} +member: ${user/#/cn=},${LDAP_USER_OU/#/ou=},${LDAP_ROOT} EOF done @@ -566,7 +571,7 @@ EOF ######################### ldap_add_custom_ldifs() { info "Loading custom LDIF files..." - warn "Ignoring LDAP_USERS, LDAP_PASSWORDS, LDAP_USER_DC and LDAP_GROUP environment variables..." + warn "Ignoring LDAP_USERS, LDAP_PASSWORDS, LDAP_USER_OU, LDAP_GROUP_OU and LDAP_GROUP environment variables..." find "$LDAP_CUSTOM_LDIF_DIR" -maxdepth 1 \( -type f -o -type l \) -iname '*.ldif' -print0 | sort -z | xargs --null -I{} bash -c ". /opt/bitnami/scripts/libos.sh && debug_execute ldapadd -f {} -H 'ldapi:///' -D \"$LDAP_ADMIN_DN\" -w \"$LDAP_ADMIN_PASSWORD\"" } diff --git a/bitnami/openldap/README.md b/bitnami/openldap/README.md index 286ace2fb26d5..ad986dd037dac 100644 --- a/bitnami/openldap/README.md +++ b/bitnami/openldap/README.md @@ -186,12 +186,13 @@ The Bitnami Docker OpenLDAP can be easily setup with the following environment v * `LDAP_CONFIG_ADMIN_PASSWORD_FILE`: Path to a file that contains the LDAP configuration admin user password. This will override the value specified in `LDAP_CONFIG_ADMIN_PASSWORD`. No defaults. * `LDAP_USERS`: Comma separated list of LDAP users to create in the default LDAP tree. Default: **user01,user02** * `LDAP_PASSWORDS`: Comma separated list of passwords to use for LDAP users. Default: **bitnami1,bitnami2** -* `LDAP_USER_DC`: DC for the users' organizational unit. Default: **users** +* `LDAP_USER_OU`: Name for the user's organizational unit. Default: **users** +* `LDAP_GROUP_OU`: Name for the group's organizational unit. Default: **groups** * `LDAP_GROUP`: Group used to group created users. Default: **readers** * `LDAP_ADD_SCHEMAS`: Whether to add the schemas specified in `LDAP_EXTRA_SCHEMAS`. Default: **yes** * `LDAP_EXTRA_SCHEMAS`: Extra schemas to add, among OpenLDAP's distributed schemas. Default: **cosine, inetorgperson, nis** -* `LDAP_SKIP_DEFAULT_TREE`: Whether to skip creating the default LDAP tree based on `LDAP_USERS`, `LDAP_PASSWORDS`, `LDAP_USER_DC` and `LDAP_GROUP`. Please note that this will **not** skip the addition of schemas or importing of LDIF files. Default: **no** -* `LDAP_CUSTOM_LDIF_DIR`: Location of a directory that contains LDIF files that should be used to bootstrap the database. Only files ending in `.ldif` will be used. Default LDAP tree based on the `LDAP_USERS`, `LDAP_PASSWORDS`, `LDAP_USER_DC` and `LDAP_GROUP` will be skipped when `LDAP_CUSTOM_LDIF_DIR` is used. When using this it will override the usage of `LDAP_USERS`, `LDAP_PASSWORDS`, `LDAP_USER_DC` and `LDAP_GROUP`. You should set `LDAP_ROOT` to your base to make sure the `olcSuffix` configured on the database matches the contents imported from the LDIF files. Default: **/ldifs** +* `LDAP_SKIP_DEFAULT_TREE`: Whether to skip creating the default LDAP tree based on `LDAP_USERS`, `LDAP_PASSWORDS`, `LDAP_USER_OU`, `LDAP_GROUP_OU` and `LDAP_GROUP`. Please note that this will **not** skip the addition of schemas or importing of LDIF files. Default: **no** +* `LDAP_CUSTOM_LDIF_DIR`: Location of a directory that contains LDIF files that should be used to bootstrap the database. Only files ending in `.ldif` will be used. Default LDAP tree based on the `LDAP_USERS`, `LDAP_PASSWORDS`, `LDAP_USER_OU`, `LDAP_GROUP_OU` and `LDAP_GROUP` will be skipped when `LDAP_CUSTOM_LDIF_DIR` is used. When using this it will override the usage of `LDAP_USERS`, `LDAP_PASSWORDS`, `LDAP_USER_OU`, `LDAP_GROUP_OU` and `LDAP_GROUP`. You should set `LDAP_ROOT` to your base to make sure the `olcSuffix` configured on the database matches the contents imported from the LDIF files. Default: **/ldifs** * `LDAP_CUSTOM_SCHEMA_FILE`: Location of a custom internal schema file that could not be added as custom ldif file (i.e. containing some `structuralObjectClass`). Default is **/schema/custom.ldif**" * `LDAP_CUSTOM_SCHEMA_DIR`: Location of a directory containing custom internal schema files that could not be added as custom ldif files (i.e. containing some `structuralObjectClass`). This can be used in addition to or instead of `LDAP_CUSTOM_SCHEMA_FILE` (above) to add multiple schema files. Default: **/schemas** * `LDAP_ULIMIT_NOFILES`: Maximum number of open file descriptors. Default: **1024**.