Code

Added password check hook to userManagement
[gosa.git] / gosa-core / plugins / admin / users / class_userManagement.inc
index b4bb70beb3a3bc80c8bbd0b46cf73f78d0c19a6a..2d27f7c4f50c7a51662ddec92b8a73ea1d7c3e3b 100644 (file)
@@ -320,29 +320,38 @@ class userManagement extends management
                     }
                 }
 
+                // Call external check hook to validate the password change
+                if(!count($message)){
+                    $attrs = array();
+                    $attrs['current_password'] = '';
+                    $attrs['new_password'] = $new_password;
+                    $checkRes = password::callCheckHook($this->config,$this->dn,$attrs);
+                    if(count($checkRes)){
+                        $message[] = sprintf(_("Check-hook reported a problem: %s. Password change canceled!"), 
+                                implode($checkRes));
+                    }
+                }
+
                 // Display errors
                 if (count($message) != 0){
                     msg_dialog::displayChecks($message);
                     return($smarty->fetch(get_template_path('password.tpl', TRUE)));
                 }
 
+
+
                 // Change cassword 
                 if(isset($this->force_hash_type[$this->dn])){
-                    if(!change_password ($this->dn, $new_password,0,$this->force_hash_type[$this->dn])){
+                    if(!change_password ($this->dn, $new_password,0,$this->force_hash_type[$this->dn],'', $message)){
+                        msg_dialog::displayChecks(array($message));
                         return($smarty->fetch(get_template_path('password.tpl', TRUE)));
                     }
                 }else{
-                    if(!change_password ($this->dn, $new_password)){
+                    if(!change_password ($this->dn, $new_password,0,'','',$message)){
+                        msg_dialog::displayChecks(array($message));
                         return($smarty->fetch(get_template_path('password.tpl', TRUE)));
                     }
                 }
-                if ($this->config->get_cfg_value("core","passwordHook") != ""){
-                    $ldap = $this->config->get_ldap_link();
-                    $ldap->cd($this->config->current['BASE']);
-                    $ldap->cat($this->dn,array('uid'));
-                    $attrs = $ldap->fetch();
-                    exec($this->config->get_cfg_value("core","passwordHook")." ".$attrs['uid'][0]." ".$new_password, $resarr);
-                }
         
                 // The user has to change his password on next login
                 // - We are going to update samba and posix attributes here, to enforce