From ceede4f253c601c41333e0a72c64b03721bf9a7f Mon Sep 17 00:00:00 2001 From: Kevin Duret <kduret@centreon.com> Date: Tue, 5 Jun 2018 16:29:40 +0200 Subject: [PATCH] fix(ldap): remove contact password if ldap password storage is disabled --- www/class/centreonLDAP.class.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/www/class/centreonLDAP.class.php b/www/class/centreonLDAP.class.php index 8b9924dd29..d094c32a9e 100644 --- a/www/class/centreonLDAP.class.php +++ b/www/class/centreonLDAP.class.php @@ -922,6 +922,10 @@ class CentreonLdapAdmin $this->db->query($query); } $this->updateLdapServers($arId); + + /* Remove contact passwords if store password option is disabled */ + $this->manageContactPasswords($arId); + return $arId; } @@ -1229,4 +1233,29 @@ class CentreonLdapAdmin } return $arr; } + + /** + * Remove contact passwords if password storage is disabled + * + * @param int $arId | Auth resource id + * @return void + */ + private function manageContactPasswords($arId) + { + $result = $this->db->query( + 'SELECT ari_value ' . + 'FROM auth_ressource_info ' . + 'WHERE ar_id = ' . $this->db->escape($arId) . ' ' . + 'AND ari_name = "ldap_store_password" ' + ); + if ($row = $result->fetchRow()) { + if ($row['ari_value'] == '0') { + $this->db->query( + "UPDATE contact " . + "SET contact_passwd = NULL " . + "WHERE ar_id = " . $this->db->escape($arId) + ); + } + } + } } -- GitLab