From e53c2f9d384ca42872641a712936f2ebc3bc5c28 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 9 Sep 2010 12:57:11 +0000 Subject: [PATCH] Updated passworch changing -Updated check Hook call git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19586 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/html/password.php | 38 +++++++++++-------- .../personal/password/class_password.inc | 8 ++-- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/gosa-core/html/password.php b/gosa-core/html/password.php index 6c04fb525..fc5fe83af 100644 --- a/gosa-core/html/password.php +++ b/gosa-core/html/password.php @@ -237,11 +237,6 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['apply'])) { // Once an error has occured it is stored here. $message = array(); - // Call the check hook - $attrs = array(); - $attrs['current_password'] = escapeshellarg($current_password); - $attrs['new_password'] = escapeshellarg($new_password); - // Perform GOsa password policy checks if(!tests::is_uid($uid)) { $message[]= msgPool::invalid(_("Login")); @@ -260,16 +255,29 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['apply'])) { } // Connect as the given user and load its ACLs - $ui= ldap_login_user($uid, $current_password); - if ($ui === NULL) { - $message[]= _("Please check the username/password combination!"); - } else { - $tmp= new acl($config, NULL, $ui->dn); - $ui->ocMapping= $tmp->ocMapping; - $ui->loadACL(); - $acls = $ui->get_permissions($ui->dn, "users/password"); - if (!preg_match("/w/i", $acls)) { - $message[]= _("You have no permissions to change your password!"); + if(!count($message)){ + $ui= ldap_login_user($uid, $current_password); + if ($ui === NULL) { + $message[]= _("Please check the username/password combination!"); + } else { + $tmp= new acl($config, NULL, $ui->dn); + $ui->ocMapping= $tmp->ocMapping; + $ui->loadACL(); + $acls = $ui->get_permissions($ui->dn, "users/password"); + if (!preg_match("/w/i", $acls)) { + $message[]= _("You have no permissions to change your password!"); + } + } + } + + // Call external check hook to validate the password change + if(!count($message)){ + $attrs = array(); + $attrs['current_password'] = escapeshellarg($current_password); + $attrs['new_password'] = escapeshellarg($new_password); + $checkRes = password::callCheckHook($config,$ui->dn,$attrs); + if(count($checkRes)){ + $message[] = sprintf(_("Check-hook reported a problem: %s. Password change canceled!"),implode($checkRes)); } } diff --git a/gosa-core/plugins/personal/password/class_password.inc b/gosa-core/plugins/personal/password/class_password.inc index a436e941f..84422ce03 100644 --- a/gosa-core/plugins/personal/password/class_password.inc +++ b/gosa-core/plugins/personal/password/class_password.inc @@ -131,7 +131,7 @@ class password extends plugin // Call external check hook to validate the password change if(!count($message)){ - $checkRes = $this->callCheckHook($attrs); + $checkRes = $this->callCheckHook($this->config,$this->dn,$attrs); if(count($checkRes)){ $message[] = sprintf(_("Check-hook reported a problem: %s. Password change canceled!"),implode($checkRes)); } @@ -179,13 +179,13 @@ class password extends plugin { } - function callCheckHook($attrs = array()) + static function callCheckHook($config,$dn,$attrs = array()) { - $command = $this->config->configRegistry->getPropertyValue(get_class($this),"check"); + $command = $config->configRegistry->getPropertyValue("password","check"); if (!empty($command)){ // Build up ldif to send to the check hook - $ldif= "dn: $this->dn\n"; + $ldif= "dn: $dn\n"; foreach ($attrs as $name => $value){ $ldif.= "{$name}: {$value}\n"; } -- 2.30.2