From a5276c8152681a9d4ab31c51698dc891b80bbf58 Mon Sep 17 00:00:00 2001 From: Etienne Pallier Date: Wed, 9 Jan 2019 12:38:39 +0100 Subject: [PATCH] ajout du mode ldap authentifié --- README.md | 6 +++--- database/update/db-update-2019-01-09-CRAL.sh | 40 ++++++++++++++++++++++++++++++++++++++++ database/update/db-update-2019-01-09.sh | 40 ++++++++++++++++++++++++++++++++++++++++ database/update/script_sql/db-update-2019-01-09-CRAL.sql | 14 ++++++++++++++ database/update/script_sql/db-update-2019-01-09.sql | 13 +++++++++++++ src/Controller/AppController.php | 4 ++-- src/Controller/ConfigurationsController.php | 2 +- src/Controller/DocumentsController.php | 2 +- src/Controller/FormulesController.php | 2 +- src/Controller/MaterielsController.php | 2 +- src/Controller/PagesController.php | 2 +- src/Controller/SuivisController.php | 2 +- src/Model/Entity/Configuration.php | 12 ++++++------ src/Model/Table/ConfigurationsTable.php | 12 ++++++------ src/Model/Table/LdapConnectionsTable.php | 54 +++++++++++++++++++++++++++++------------------------- src/Model/Table/UsersTable.php | 2 +- src/Template/Configurations/edit.ctp | 43 ++++++++++++++++++++++++++++--------------- src/Template/Configurations/view.ctp | 18 +++++++++--------- src/Template/Users/add.ctp | 10 +++++----- src/Template/Users/edit.ctp | 6 +++--- src/Template/Users/login.ctp | 2 +- tests/Fixture/ConfigurationsFixture.php | 24 ++++++++++++------------ webroot/js/script.js | 3 +++ 23 files changed, 221 insertions(+), 94 deletions(-) create mode 100755 database/update/db-update-2019-01-09-CRAL.sh create mode 100755 database/update/db-update-2019-01-09.sh create mode 100755 database/update/script_sql/db-update-2019-01-09-CRAL.sql create mode 100755 database/update/script_sql/db-update-2019-01-09.sql diff --git a/README.md b/README.md index c5c11f7..5797172 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,10 @@ Logiciel testé et validé sur les configurations suivantes : VERSION ACTUELLE -Date: 08/01/2019 -Version: 2.9.1.5 +Date: 09/01/2019 +Version: 2.9.1.6 Author: EP - - improving ldap + - improving ldap... Version majeure en cours : 2.9 (https://projects.irap.omp.eu/versions/207) diff --git a/database/update/db-update-2019-01-09-CRAL.sh b/database/update/db-update-2019-01-09-CRAL.sh new file mode 100755 index 0000000..bb5ae63 --- /dev/null +++ b/database/update/db-update-2019-01-09-CRAL.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +#myname=`basename $0 .sh` +myname=`basename $0` +myname=${myname%%.*} + +# Pour Mac OS recent (10.10, Yosemite), la syntaxe du SED est differente +# Il faut donc faire une copie de ce fichier et transformer les instructions sed a l'interieur +# Pour cela, il suffit d'executer ces 2 lignes : +# cp ce_script.sh ce_script_macosx.sh +# sed -e "s/ -i / -i '' /" -i '' ce_script_macosx.sh + +if [ ! -f ../../config/app.php ] ; then +echo "Vous devez executer ce script depuis le dossier database/update/" +exit 1 +fi + + +# Get login, pass, dbname, and hostname +username=$(grep "/\*d\*/'username'" ../../config/app.php | cut -d"'" -f4) +password=$(grep "/\*d\*/'password'" ../../config/app.php | cut -d"'" -f4) +database=$(grep "/\*d\*/'database'" ../../config/app.php | cut -d"'" -f4) +host=$(grep "/\*d\*/'host'" ../../config/app.php | cut -d"'" -f4) + + +#cp -p ./script_sql/db-update-2016-07-01-irap.sql ./script_sql/db-update-2016-07-01-irap-build.sql +cp -p ./script_sql/$myname.sql ./script_sql/$myname-build.sql + +# Execute sql update script +sed -e "s/database/$database/" -i ./script_sql/$myname-build.sql +mysql --user=$username --password=$password -h $host < ./script_sql/$myname-build.sql + +# Delete cakephp cache +sudo rm ../../tmp/cache/models/* +sudo rm ../../tmp/cache/persistent/* + +# Faire ca aussi si ca suffit pas... +#sudo chmod -R 777 ../../tmp +#sudo chmod -R 777 ../../vendor +#sudo chmod -R 777 ../../webroot diff --git a/database/update/db-update-2019-01-09.sh b/database/update/db-update-2019-01-09.sh new file mode 100755 index 0000000..0048691 --- /dev/null +++ b/database/update/db-update-2019-01-09.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +#myname=`basename $0 .sh` +myname=`basename $0` +myname=${myname%%.*} + +# Pour Mac OS recent (10.10, Yosemite), la syntaxe du SED est differente +# Il faut donc faire une copie de ce fichier et transformer les instructions sed a l'interieur +# Pour cela, il suffit d'executer ces 2 lignes : +# cp ce_script.sh ce_script_macosx.sh +# sed -e "s/ -i / -i '' /" -i '' ce_script_macosx.sh + +if [ ! -f ../../config/app.php ] ; then +echo "Vous devez executer ce script depuis le dossier database/update/" +exit 1 +fi + + +# Get login, pass, dbname, and hostname +username=$(grep "/\*d\*/'username'" ../../config/app.php | cut -d"'" -f4) +password=$(grep "/\*d\*/'password'" ../../config/app.php | cut -d"'" -f4) +database=$(grep "/\*d\*/'database'" ../../config/app.php | cut -d"'" -f4) +host=$(grep "/\*d\*/'host'" ../../config/app.php | cut -d"'" -f4) + + +#cp -p ./script_sql/db-update-2016-07-01-irap.sql ./script_sql/db-update-2016-07-01-irap-build.sql +cp -p ./script_sql/$myname.sql ./script_sql/$myname-build.sql + +# Execute sql update script +sed -e "s/database/$database/" -i ./script_sql/$myname-build.sql +mysql --user=$username --password=$password -h $host < ./script_sql/$myname-build.sql + +# Delete cakephp cache +sudo rm ../../tmp/cache/models/* +sudo rm ../../tmp/cache/persistent/* + +# Faire ca aussi si ca suffit pas... +#sudo chmod -R 777 ../../tmp +#sudo chmod -R 777 ../../vendor +#sudo chmod -R 777 ../../webroot \ No newline at end of file diff --git a/database/update/script_sql/db-update-2019-01-09-CRAL.sql b/database/update/script_sql/db-update-2019-01-09-CRAL.sql new file mode 100755 index 0000000..4d2e780 --- /dev/null +++ b/database/update/script_sql/db-update-2019-01-09-CRAL.sql @@ -0,0 +1,14 @@ +use database; + + +ALTER TABLE `configurations` CHANGE `anonymous_ldap` `ldap_anonymous` BOOLEAN NOT NULL DEFAULT TRUE; +ALTER TABLE `configurations` CHANGE `bindDn_ldap` `ldap_bindDn` VARCHAR(250) NULL DEFAULT NULL ; +ALTER TABLE `configurations` CHANGE `bindPass_ldap` `ldap_bindPass` VARCHAR(50) NULL DEFAULT NULL ; + + +ALTER TABLE `configurations` CHANGE `host_ldap` `ldap_host` VARCHAR(250) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL AFTER `ldap_bindPass`; +ALTER TABLE `configurations` CHANGE `use_ldap` `ldap_used` BOOLEAN NOT NULL DEFAULT FALSE AFTER `ldap_anonymous`; +ALTER TABLE `configurations` CHANGE `baseDn_ldap` `ldap_baseDn` VARCHAR(300) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL AFTER `ldap_host`; +ALTER TABLE `configurations` CHANGE `port_ldap` `ldap_port` VARCHAR(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL AFTER `ldap_host`; +ALTER TABLE `configurations` CHANGE `authentificationType_ldap` `ldap_authenticationType` VARCHAR(30) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL AFTER `ldap_port`; +ALTER TABLE `configurations` CHANGE `filter_ldap` `ldap_filter` VARCHAR(300) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL AFTER `ldap_baseDn`; diff --git a/database/update/script_sql/db-update-2019-01-09.sql b/database/update/script_sql/db-update-2019-01-09.sql new file mode 100755 index 0000000..9a96b8c --- /dev/null +++ b/database/update/script_sql/db-update-2019-01-09.sql @@ -0,0 +1,13 @@ +use database; + + +ALTER TABLE `configurations` ADD `ldap_anonymous` BOOLEAN NOT NULL DEFAULT TRUE ; +ALTER TABLE `configurations` ADD `ldap_bindDn` VARCHAR(250) NULL DEFAULT NULL ; +ALTER TABLE `configurations` ADD `ldap_bindPass` VARCHAR(50) NULL DEFAULT NULL ; + +ALTER TABLE `configurations` CHANGE `host_ldap` `ldap_host` VARCHAR(250) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL AFTER `ldap_bindPass`; +ALTER TABLE `configurations` CHANGE `use_ldap` `ldap_used` BOOLEAN NOT NULL DEFAULT FALSE AFTER `ldap_anonymous`; +ALTER TABLE `configurations` CHANGE `baseDn_ldap` `ldap_baseDn` VARCHAR(300) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL AFTER `ldap_host`; +ALTER TABLE `configurations` CHANGE `port_ldap` `ldap_port` VARCHAR(10) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL AFTER `ldap_host`; +ALTER TABLE `configurations` CHANGE `authentificationType_ldap` `ldap_authenticationType` VARCHAR(30) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL AFTER `ldap_port`; +ALTER TABLE `configurations` CHANGE `filter_ldap` `ldap_filter` VARCHAR(300) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL AFTER `ldap_baseDn`; diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index 8c6374c..0de3abc 100755 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -475,7 +475,7 @@ class AppController extends Controller { if (! $this->CURRENT_PRIVILEDGED_USER) { $configuration = $this->confLabinvent; - $username = $user ? $user[$configuration->authentificationType_ldap][0] : $this->LdapAuth->user($configuration->authentificationType_ldap)[0]; + $username = $user ? $user[$configuration->ldap_authenticationType][0] : $this->LdapAuth->user($configuration->ldap_authenticationType)[0]; $priviledgedUser = TableRegistry::get('Users')->find() ->where([ 'username' => $username @@ -642,7 +642,7 @@ class AppController extends Controller $configuration = $this->confLabinvent; $this->set('configuration', $configuration); - $this->request->session()->write("authType", $configuration->authentificationType_ldap); + $this->request->session()->write("authType", $configuration->ldap_authenticationType); // ATTENTION, $priviledgedUser = NULL si l'utilisateur courant n'est pas un utilisateur privilégié // (c'est à dire s'il n'est pas dans la table "utilisateurs") diff --git a/src/Controller/ConfigurationsController.php b/src/Controller/ConfigurationsController.php index b7a09f1..8d2e7f9 100644 --- a/src/Controller/ConfigurationsController.php +++ b/src/Controller/ConfigurationsController.php @@ -108,7 +108,7 @@ class ConfigurationsController extends AppController // Gestion du lieu de stockage : soit on cache la DIV 'interne' et on affiche la DIV 'externe', soit on fait l'inverse (par defaut, interne) $disp = 'display:block'; - $ldap = $configurationObj->get('use_ldap'); + $ldap = $configurationObj->get('ldap_used'); if ($ldap !== null) { if ($ldap) { $disp = 'display:block'; diff --git a/src/Controller/DocumentsController.php b/src/Controller/DocumentsController.php index 79f728c..2cadc1f 100755 --- a/src/Controller/DocumentsController.php +++ b/src/Controller/DocumentsController.php @@ -65,7 +65,7 @@ class DocumentsController extends AppController } $u = TableRegistry::get('Users')->find() ->where([ - 'username' => $user[$configuration->authentificationType_ldap][0] + 'username' => $user[$configuration->ldap_authenticationType][0] ]) ->first(); diff --git a/src/Controller/FormulesController.php b/src/Controller/FormulesController.php index bd2c6d3..0c48711 100644 --- a/src/Controller/FormulesController.php +++ b/src/Controller/FormulesController.php @@ -40,7 +40,7 @@ class FormulesController extends AppController $id = $this->getIdPassed(); if ($this->isOwnedBy($id, $user['sn'][0] . ' ' . $user['givenname'][0])) return true; - if ($role == 'Responsable' && $this->isRespGroup($id, $user[$configuration->authentificationType_ldap][0])) + if ($role == 'Responsable' && $this->isRespGroup($id, $user[$configuration->ldap_authenticationType][0])) return true; } diff --git a/src/Controller/MaterielsController.php b/src/Controller/MaterielsController.php index da81e0c..90b1f96 100755 --- a/src/Controller/MaterielsController.php +++ b/src/Controller/MaterielsController.php @@ -185,7 +185,7 @@ class MaterielsController extends AppController { $user = $userFromSession; $configuration = $this->confLabinvent; - $userCname = $user[$configuration->authentificationType_ldap][0]; + $userCname = $user[$configuration->ldap_authenticationType][0]; /* * $role = TableRegistry::get('Users')->find() * ->where(['username' => $user[$configuration->authentificationType_ldap][0]]) diff --git a/src/Controller/PagesController.php b/src/Controller/PagesController.php index 6ceb060..73385bc 100755 --- a/src/Controller/PagesController.php +++ b/src/Controller/PagesController.php @@ -79,7 +79,7 @@ class PagesController extends AppController // @todo : faire plus proprement, dans isAuthorized() // Si l'utilisateur n'est pas connecté, on le redirige vers la page login.ctp // sauf si l'action demandée est 'about' ou si le mode install est activé - if (! ($this->LdapAuth->user($configuration->authentificationType_ldap)[0]) && $path[0] != 'about' && ! ($configuration->mode_install)) { + if (! ($this->LdapAuth->user($configuration->ldap_authenticationType)[0]) && $path[0] != 'about' && ! ($configuration->mode_install)) { return $this->redirect([ 'controller' => 'users', 'action' => 'login' diff --git a/src/Controller/SuivisController.php b/src/Controller/SuivisController.php index 30034f8..098e4b5 100755 --- a/src/Controller/SuivisController.php +++ b/src/Controller/SuivisController.php @@ -45,7 +45,7 @@ class SuivisController extends AppController $id = $this->getIdPassed(); if ($this->isOwnedBy($id, $user['sn'][0] . ' ' . $user['givenname'][0])) return true; - if ($role == 'Responsable' && $this->isRespGroup($id, $user[$configuration->authentificationType_ldap][0])) + if ($role == 'Responsable' && $this->isRespGroup($id, $user[$configuration->ldap_authenticationType][0])) return true; } return parent::isAuthorized($user); diff --git a/src/Model/Entity/Configuration.php b/src/Model/Entity/Configuration.php index 2a9503b..7ad7570 100644 --- a/src/Model/Entity/Configuration.php +++ b/src/Model/Entity/Configuration.php @@ -10,12 +10,12 @@ use Cake\ORM\Entity; * @property string $nom * @property bool $mode_install * @property bool $mode_debug - * @property bool $use_ldap - * @property string $host_ldap - * @property string $port_ldap - * @property string $authentificationType_ldap - * @property string $baseDn_ldap - * @property string $filter_ldap + * @property bool $ldap_used + * @property string $ldap_host + * @property string $ldap_port + * @property string $ldap_authenticationType + * @property string $ldap_baseDn + * @property string $ldap_filter * @property string $labName * @property string $labNameShort * @property string $labPresent diff --git a/src/Model/Table/ConfigurationsTable.php b/src/Model/Table/ConfigurationsTable.php index ae85018..e8be834 100644 --- a/src/Model/Table/ConfigurationsTable.php +++ b/src/Model/Table/ConfigurationsTable.php @@ -50,17 +50,17 @@ class ConfigurationsTable extends AppTable $validator->boolean('mode_debug')->allowEmpty('mode_debug'); - $validator->boolean('use_ldap')->allowEmpty('use_ldap'); + $validator->boolean('ldap_used')->allowEmpty('ldap_used'); - $validator->allowEmpty('host_ldap'); + $validator->allowEmpty('ldap_host'); - $validator->allowEmpty('port_ldap'); + $validator->allowEmpty('ldap_port'); - $validator->allowEmpty('authentificationType_ldap'); + $validator->allowEmpty('ldap_authenticationType'); - $validator->allowEmpty('baseDn_ldap'); + $validator->allowEmpty('ldap_baseDn'); - $validator->allowEmpty('filter_ldap'); + $validator->allowEmpty('ldap_filter'); $validator->notEmpty('labName'); diff --git a/src/Model/Table/LdapConnectionsTable.php b/src/Model/Table/LdapConnectionsTable.php index b8e5d0a..cbbdcff 100755 --- a/src/Model/Table/LdapConnectionsTable.php +++ b/src/Model/Table/LdapConnectionsTable.php @@ -24,12 +24,12 @@ class LdapConnectionsTable extends AppTable /*MCM*/ // EP //private $anonymous; - private $anonymous_ldap; + private $ldap_anonymous; private $bindDn; private $bindPass; /* fin MCM*/ - private $USE_LDAP = TRUE; + private $LDAP_USED = TRUE; private $fakeLDAPUsers = []; @@ -47,7 +47,7 @@ class LdapConnectionsTable extends AppTable public function useLdap() { $this->checkConfiguration(); - return $this->USE_LDAP; + return $this->LDAP_USED; } private function buildFakeLdapUsers() @@ -140,10 +140,10 @@ class LdapConnectionsTable extends AppTable ]) ->first(); - $this->USE_LDAP = $config->use_ldap ? TRUE : FALSE; + $this->LDAP_USED = $config->ldap_used ? TRUE : FALSE; - if (! $this->USE_LDAP) { - $this->authenticationType = $config->authentificationType_ldap; + if (! $this->LDAP_USED) { + $this->authenticationType = $config->ldap_authenticationType; if (empty($this->fakeLDAPUsers)) $this->fakeLDAPUsers = $this->buildFakeLdapUsers(); return true; @@ -152,24 +152,28 @@ class LdapConnectionsTable extends AppTable $ldapConfig = $config->toArray(); - if (! empty($config->host_ldap) && ! empty($config->port_ldap) && ! empty($config->baseDn_ldap) && ! empty($config->authentificationType_ldap) && ! empty($config->filter_ldap)) { - $this->host = $config->host_ldap; - $this->port = $config->port_ldap; - $this->baseDn = $config->baseDn_ldap; - $this->filter = $config->filter_ldap; - $this->authenticationType = $config->authentificationType_ldap; + if (! empty($config->ldap_host) && ! empty($config->ldap_port) && ! empty($config->ldap_baseDn) && ! empty($config->ldap_authenticationType) && ! empty($config->ldap_filter)) { + $this->host = $config->ldap_host; + $this->port = $config->ldap_port; + $this->baseDn = $config->ldap_baseDn; + $this->filter = $config->ldap_filter; + $this->authenticationType = $config->ldap_authenticationType; /*MCM*/ - $NEW_CONF=FALSE; + /* + $NEW_CONF=TRUE; if ($NEW_CONF) { - $this->anonymous_ldap = $config->anonymous_ldap; - $this->bindDn = $config->bindDn_ldap; - $this->bindPass = $config->bindPass_ldap; + */ + $this->ldap_anonymous = $config->ldap_anonymous; + $this->bindDn = $config->ldap_bindDn; + $this->bindPass = $config->ldap_bindPass; + /* } else { - $this->anonymous_ldap = TRUE; + $this->ldap_anonymous = TRUE; $this->bindDn = NULL; $this->bindPass = NULL; } + */ /* fin MCM*/ return true; @@ -190,7 +194,7 @@ class LdapConnectionsTable extends AppTable try { if ($this->checkConfiguration()) { // REAL LDAP - if ($this->USE_LDAP) { + if ($this->LDAP_USED) { $ldapConnection = ldap_connect($this->host, $this->port); ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3); @@ -215,7 +219,7 @@ class LdapConnectionsTable extends AppTable try { if ($this->checkConfiguration()) { - if ($this->USE_LDAP) { + if ($this->LDAP_USED) { /* Code inutile car redondant: $ldapConnection = ldap_connect($this->host, $this->port); ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3); @@ -275,7 +279,7 @@ class LdapConnectionsTable extends AppTable $u = $this->getAllLdapUsers(); $utilisateurs = []; - if ($this->USE_LDAP) { + if ($this->LDAP_USED) { for ($i = 0; $i < $u['count']; $i ++) { $utilisateurs[$u[$i]['sn'][0] . ' ' . $u[$i]['givenname'][0]] = $u[$i]['sn'][0] . ' ' . $u[$i]['givenname'][0]; } @@ -296,7 +300,7 @@ class LdapConnectionsTable extends AppTable $u = $this->getAllLdapUsers(); $utilisateurs = []; - if ($this->USE_LDAP) { + if ($this->LDAP_USED) { for ($i = 0; $i < $u['count']; $i ++) { $utilisateurs[$u[$i]['sn'][0] . ' ' . $u[$i]['givenname'][0]] = $u[$i][$this->authenticationType][0]; } @@ -317,7 +321,7 @@ class LdapConnectionsTable extends AppTable $u = $this->getAllLdapUsers(); $utilisateurs = []; - if ($this->USE_LDAP) { + if ($this->LDAP_USED) { for ($i = 0; $i < $u['count']; $i ++) { if (isset($u[$i]['mail'][0])) { $utilisateurs[$u[$i]['sn'][0] . ' ' . $u[$i]['givenname'][0]] = $u[$i]['mail'][0]; @@ -341,7 +345,7 @@ class LdapConnectionsTable extends AppTable { $u = $this->getAllLdapUsers(); - if ($this->USE_LDAP) { + if ($this->LDAP_USED) { $nbUsers = $u['count']; } else { $nbUsers = sizeof($u) - 1; @@ -364,7 +368,7 @@ class LdapConnectionsTable extends AppTable try { if ($this->checkConfiguration()) { // We are using LDAP - if ($this->USE_LDAP) { + if ($this->LDAP_USED) { // CRAL must set this to FALSE //$LDAP_ANONYMOUS = TRUE; @@ -435,7 +439,7 @@ class LdapConnectionsTable extends AppTable /*MCM*/ // bind optionnel //if ($anonymous == '0') - if (! $this->anonymous_ldap) + if (! $this->ldap_anonymous) //$ldapbind = ldap_bind($ldapConnection, $binddn, $ldappass) or die("Could not bind to LDAP server.". ldap_error($ldapConnection) ); $ldapbind = ldap_bind($ldapConnection, $this->bindDn, $this->bindPass) or die("Could not bind to LDAP server.". ldap_error($ldapConnection) ); // EP: bind obligatoire diff --git a/src/Model/Table/UsersTable.php b/src/Model/Table/UsersTable.php index 5026d62..c4a43f3 100755 --- a/src/Model/Table/UsersTable.php +++ b/src/Model/Table/UsersTable.php @@ -81,7 +81,7 @@ class UsersTable extends AppTable 'id =' => 1 ]) ->first(); - if ($configuration->use_ldap) { + if ($configuration->ldap_used) { $validator->allowEmpty('email'); } else { $validator->email('email')->notEmpty('email', 'Un adresse mail est nécessaire'); diff --git a/src/Template/Configurations/edit.ctp b/src/Template/Configurations/edit.ctp index f80773a..9baa8d6 100644 --- a/src/Template/Configurations/edit.ctp +++ b/src/Template/Configurations/edit.ctp @@ -128,46 +128,59 @@ ]); echo ''; + + // LDAP SECTION echo '

'; echo ''; echo 'LDAP'; echo '

'; echo '
'; - echo $this->Form->input('use_ldap', [ + echo $this->Form->input('ldap_used', [ 'label' => 'Utilisation du LDAP', 'onchange' => 'display_ldap();' ]); + + // start LDAP DIV echo '
'; - echo $this->Form->input('host_ldap', [ + echo $this->Form->input('ldap_host', [ 'label' => 'Host du LDAP' ]); - echo $this->Form->input('port_ldap', [ + echo $this->Form->input('ldap_port', [ 'label' => 'Port du LDAP' ]); - echo $this->Form->input('authentificationType_ldap', [ + echo $this->Form->input('ldap_authenticationType', [ 'label' => 'Type d\'authentification du LDAP' ]); - echo $this->Form->input('baseDn_ldap', [ + echo $this->Form->input('ldap_baseDn', [ 'label' => 'Base DN du LDAP' ]); - echo $this->Form->input('filter_ldap', [ + echo $this->Form->input('ldap_filter', [ 'label' => 'Filtre du LDAP' ]); /*MCM*/ - echo $this->Form->input('anonymous_ldap', [ - 'label' => 'LDAP anonyme' - ]); - echo $this->Form->input('bindDn_ldap', [ - 'label' => 'Bind du LDAP' - ]); - echo $this->Form->input('bindPass_ldap', [ - 'label' => 'Password Bind du LDAP' - ]); + // start LDAP auth subsection (DIV) + echo $this->Form->input('ldap_anonymous', [ + 'label' => 'LDAP anonyme', + 'onchange' => 'display_ldap_auth();' + ]); + echo '
'; + echo $this->Form->input('ldap_bindDn', [ + 'label' => 'Bind du LDAP' + ]); + echo $this->Form->input('ldap_bindPass', [ + 'label' => 'Password Bind du LDAP' + ]); + echo '
'; + // end LDAP auth subsection (DIV) /* fin MCM */ echo '
'; + // end LDAP DIV + echo '
'; + // END LDAP SECTION + echo '

'; echo ''; diff --git a/src/Template/Configurations/view.ctp b/src/Template/Configurations/view.ctp index 801da70..497a648 100644 --- a/src/Template/Configurations/view.ctp +++ b/src/Template/Configurations/view.ctp @@ -30,7 +30,7 @@ $print = "Non"; } - if (h($configurationObj->use_ldap) == 1) { + if (h($configurationObj->ldap_used) == 1) { $ldap = "Oui"; } else { $ldap = "Non"; @@ -145,16 +145,16 @@ echo ''; echo ''; $displayElement(__('Utilisation du LDAP'), $ldap); - $displayElement(__('Host du LDAP'), h($configurationObj->host_ldap)); - $displayElement(__('Port du LDAP'), h($configurationObj->port_ldap)); - $displayElement(__('Type d\'authentification du LDAP'), h($configurationObj->authentificationType_ldap)); - $displayElement(__('Base DN du LDAP'), h($configurationObj->baseDn_ldap)); - $displayElement(__('Filtre du LDAP'), h($configurationObj->filter_ldap)); + $displayElement(__('Host du LDAP'), h($configurationObj->ldap_host)); + $displayElement(__('Port du LDAP'), h($configurationObj->ldap_port)); + $displayElement(__('Type d\'authentification du LDAP'), h($configurationObj->ldap_authenticationType)); + $displayElement(__('Base DN du LDAP'), h($configurationObj->ldap_baseDn)); + $displayElement(__('Filtre du LDAP'), h($configurationObj->ldap_filter)); /*MCM*/ - $displayElement(__('LDAP anonyme'), h($configurationObj->anonymous_ldap)); - $displayElement(__('Bind du LDAP'), h($configurationObj->bindDn_ldap)); - $displayElement(__('Password Bind du LDAP'), h($configurationObj->bindPass_ldap)); + $displayElement(__('LDAP anonyme'), h($configurationObj->ldap_anonymous)?"Oui":"Non" ); + $displayElement(__('Bind du LDAP'), h($configurationObj->ldap_bindDn)); + $displayElement(__('Password Bind du LDAP'), h($configurationObj->ldap_bindPass)); /*fin MCM*/ echo '
'; diff --git a/src/Template/Users/add.ctp b/src/Template/Users/add.ctp index 593ab42..7470bd5 100755 --- a/src/Template/Users/add.ctp +++ b/src/Template/Users/add.ctp @@ -1,7 +1,7 @@
Form->create($user) ?> - use_ldap; ?> + ldap_used; ?>

Ajouter un utilisateur privilégié @@ -9,7 +9,7 @@ Form->input('newname', [ 'label' => 'Nom', 'div' => 'input required' @@ -28,7 +28,7 @@ } echo '
Note: un utilisateur ne peut pas être présent deux fois dans l\'inventaire.
'; - $READONLY = $USE_LDAP ? true : false; + $READONLY = $LDAP_USED ? true : false; echo $this->Form->input('username', [ 'label' => 'Login', @@ -36,7 +36,7 @@ 'readonly' => $READONLY ]); - if (! $USE_LDAP) { + if (! $LDAP_USED) { echo $this->Form->input('password'); } @@ -89,7 +89,7 @@ echo $this->element('menu_form', [