Code

Added password check hook to userManagement
[gosa.git] / gosa-core / plugins / admin / users / class_userManagement.inc
index 8d4e1b5283b89c908c08eb3ea8d645e576d57df4..2d27f7c4f50c7a51662ddec92b8a73ea1d7c3e3b 100644 (file)
@@ -253,7 +253,7 @@ class userManagement extends management
         $this->enforcePasswordChange = isset($_POST['new_password']) && isset($_POST['enforcePasswordChange']);
 
         $smarty = get_smarty();
-        $smarty->assign("proposal" , $this->proposal);
+        $smarty->assign("proposal" , set_post($this->proposal));
         $smarty->assign("proposalEnabled" , $this->proposalEnabled);
         $smarty->assign("proposalSelected" , $this->proposalSelected);
 
@@ -280,7 +280,7 @@ class userManagement extends management
             $smarty->assign("enforcePasswordChange" , $this->enforcePasswordChange);
 
             // Assign proposal variables
-            $smarty->assign("proposal" , $this->proposal);
+            $smarty->assign("proposal" , set_post($this->proposal));
             $smarty->assign("proposalEnabled" , $this->proposalEnabled);
             $smarty->assign("proposalSelected" , $this->proposalSelected);
 
@@ -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
@@ -378,8 +387,8 @@ class userManagement extends management
                     if($samba){
                         $sambaAccount = new sambaAccount($this->config, $this->dn);
                         $sambaAccount->is_modified=TRUE;
-                        $sambaAccount->kickoff_time_set  = "1";
-                        $sambaAccount->sambaKickoffTime= date('d.m.Y', time() - (1 * 24 * 60 *60));
+                        $sambaAccount->flag_enforcePasswordChange = TRUE;
+                        $sambaAccount->flag_cannotChangePassword = FALSE;
                         $sambaAccount->save();
                     }
                 }
@@ -564,7 +573,6 @@ class userManagement extends management
             return($smarty->fetch(get_template_path('template.tpl', TRUE)));
         }
 
-
         /********************
          * 2   There was a template selected, now ask for the uid.
          ********************/
@@ -581,6 +589,7 @@ class userManagement extends management
             $ldap= $this->config->get_ldap_link();
             $ldap->cd ($dn);
             $ldap->search ("(&(sn=".normalizeLdap($this->sn).")(givenName=".normalizeLdap($this->givenName)."))", array("givenName"));
+
             if ($ldap->count () != 0){
                 msg_dialog::displayChecks(array(msgPool::duplicated(_("Name"))));
             }else{
@@ -603,7 +612,7 @@ class userManagement extends management
 
             // Assign user input 
             foreach(array("sn", "givenName", "uid", "got_uid") as $attr){
-                $smarty->assign("$attr", $this->$attr);
+                $smarty->assign("$attr", set_post($this->$attr));
             }
             if (isset($_POST['template'])){
                 $smarty->assign("template", get_post('template'));
@@ -884,7 +893,7 @@ class userManagement extends management
                 "apple-user" => array("image" => "plugins/netatalk/images/select_netatalk.png",
                     "plugin" => "netatalk",
                     "alt" => _("Netatalk"),
-                    "title" => _("Edit netatalk properties")),
+                    "title" => _("Edit Netatalk properties")),
                 "gotoEnvironment" => array("image" => "plugins/users/images/small_environment.png",
                     "plugin" => "environment",
                     "alt" => _("Environment"),