Code

Updated passworch changing
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 9 Sep 2010 12:57:11 +0000 (12:57 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 9 Sep 2010 12:57:11 +0000 (12:57 +0000)
-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
gosa-core/plugins/personal/password/class_password.inc

index 6c04fb525e204debfa9709179cffa16bc94fac16..fc5fe83afac6f99c43f98002f0e2cc39f980a693 100644 (file)
@@ -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));
         }
     }
 
index a436e941f263ba89df9ddfc37e9e9a613ce7e292..84422ce039527cc816b155970d2bbd3f5f0d8eda 100644 (file)
@@ -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";
             }