osixia / docker-phpLDAPadmin

phpLDAPadmin container image 🐳🌴
MIT License
844 stars 197 forks source link

Autogenerate the LDAP "cn=config" entry into "ldap_pla" in "config.php" #31

Open konvergence opened 7 years ago

konvergence commented 7 years ago

Hi osixia, thanks a lot for your Dockerfile.

It will really cool that you Autogenerate the "cn=config" LDAP server entry "ldap_pla" into config.php

Example : a container with variable ; -e PHPLDAPADMIN_LDAP_HOSTS=myldap I will get into the config.php :

/*********************************************
 * Define your LDAP servers in this section  *
 *********************************************/

$servers = new Datastore();

/*
 * Autogenerated servers variables will come here
 */
$servers->newServer('ldap_pla');
$servers->setValue('server','name','myldap');
$servers->setValue('server','host','myldap');

$servers->newServer('ldap_pla');
$servers->setValue('server','name','myldap-config');
$servers->setValue('server','host','myldap');
$servers->setValue('server','base',array( 'cn=config' ));
eMPee584 commented 5 years ago
From fda9169542b6777fd38b45bd1e566f6a82d0e3e5 Mon Sep 17 00:00:00 2001
From: Marcel Partap <mpartap@gmx.net>
Date: Tue, 14 May 2019 16:19:21 +0200
Subject: [PATCH] Autogenerate cn=config server entries

---
 image/service/phpldapadmin/startup.sh | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git image/service/phpldapadmin/startup.sh image/service/phpldapadmin/startup.sh
index 048971c..f74533a 100755
--- image/service/phpldapadmin/startup.sh
+++ image/service/phpldapadmin/startup.sh
@@ -78,6 +78,13 @@ if [ ! -e "/var/www/phpldapadmin/config/config.php" ]; then
       append_to_file "\$servers->setValue($TO_PRINT$php_value);"
     }

+    append_cn_config() {
+      append_to_file "\$servers->newServer('ldap_pla');"
+      append_to_file "\$servers->setValue('server','name','${!host}-config');"
+      append_to_file "\$servers->setValue('server','host','${!host}');"
+      append_to_file "\$servers->setValue('server','base',array('cn=config'));"
+    }
+
     print_by_php_type() {
       if [ "$1" == "True" ]; then
         echo "true"
@@ -124,10 +131,12 @@ if [ ! -e "/var/www/phpldapadmin/config/config.php" ]; then
         fi
         append_to_file "\$servers->setValue('server','name','$hostname');"
         host_info "" "$info"
+        append_cn_config

       else
         append_to_file "\$servers->setValue('server','name','${!host}');"
         append_to_file "\$servers->setValue('server','host','${!host}');"
+        append_cn_config
       fi
     done

-- 
2.20.1
eMPee584 commented 3 years ago

Uhm, you added the help-wanted tag.. The patch I posted before that implements the feature..