Code

Updated in
[gosa.git] / gosa-core / plugins / admin / users / class_userManagement.inc
index 807634a645631c39a5b10f51a380bbe08a383aac..29eb9e1613f4126f6f74af8765b2c638109b291c 100644 (file)
@@ -274,8 +274,8 @@ class userManagement extends management
           $ldap->cat($this->dn);
           $attrs = $ldap->fetch();
           $this->passwordChangeForceable =
-              in_array('sambaAccount', $attrs['objectClass']) ||
-              (in_array('posixAccount', $attrs['objectClass']) && isset($attrs['shadowMax']));
+              in_array_strict('sambaAccount', $attrs['objectClass']) ||
+              (in_array_strict('posixAccount', $attrs['objectClass']) && isset($attrs['shadowMax']));
           $smarty->assign("passwordChangeForceable" , $this->passwordChangeForceable);
           $smarty->assign("enforcePasswordChange" , $this->enforcePasswordChange);
 
@@ -326,7 +326,7 @@ class userManagement extends management
                   return($smarty->fetch(get_template_path('password.tpl', TRUE)));
               }
 
-              // Change cassword
+              // Change password
               if(isset($this->force_hash_type[$this->dn])){
                   if(!change_password ($this->dn, $new_password,0,$this->force_hash_type[$this->dn])){
                       return($smarty->fetch(get_template_path('password.tpl', TRUE)));
@@ -341,9 +341,20 @@ class userManagement extends management
                   $ldap->cd($this->config->current['BASE']);
                   $ldap->cat($this->dn,array('uid'));
                   $attrs = $ldap->fetch();
-                  exec($this->config->get_cfg_value("passwordHook")." ".$attrs['uid'][0]." ".$_POST['new_password'], $resarr);
+                  exec($this->config->get_cfg_value("passwordHook")." ".
+                          escapeshellarg($attrs['uid'][0])." ".escapeshellarg($new_password), $resarr);
+                  $check_hook_output = "";
+                  if(count($resarr) > 0) {
+                      $check_hook_output= join('\n', $resarr);
+                  }
+                  if(!empty($check_hook_output)){
+                      $message[] = sprintf(_("Check-hook reported a problem: %s. Password change canceled!"),$check_hook_output);
+                      msg_dialog::displayChecks($message);
+                      return($smarty->fetch(get_template_path('password.tpl', TRUE)));
+                  }
               }
 
+
               // The user has to change his password on next login
               // - We are going to update samba and posix attributes here, to enforce
               //   such a password change.
@@ -354,8 +365,8 @@ class userManagement extends management
                   $ldap->cd($this->config->current['BASE']);
                   $ldap->cat($this->dn);
                   $attrs = $ldap->fetch();
-                  $samba = in_array('sambaSamAccount', $attrs['objectClass']);
-                  $posix = in_array('posixAccount', $attrs['objectClass']);
+                  $samba = in_array_strict('sambaSamAccount', $attrs['objectClass']);
+                  $posix = in_array_strict('posixAccount', $attrs['objectClass']);
 
                   // Update the posix shadow flag...
                   if($posix){
@@ -377,8 +388,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();
                   }
               }
@@ -472,6 +483,7 @@ class userManagement extends management
       $smarty->assign("template",  array_pop($target));
       $smarty->assign("templates", $templates);
       $smarty->assign("edit_uid", "");
+      $smarty->assign("allowUidProposalModification", $this->config->get_cfg_value("allowUidProposalModification", "false"));
       return($smarty->fetch(get_template_path('template.tpl', TRUE)));
 
       // -> See 'templateContinue' for further handling!
@@ -508,6 +520,7 @@ class userManagement extends management
       $smarty->assign("template", "none");
       $smarty->assign("templates", $templates);
       $smarty->assign("edit_uid", "");
+      $smarty->assign("allowUidProposalModification", $this->config->get_cfg_value("allowUidProposalModification", "false"));
       return($smarty->fetch(get_template_path('template.tpl', TRUE)));
 
       // -> See 'templateContinue' for further handling!
@@ -561,6 +574,7 @@ class userManagement extends management
       $smarty->assign("templates",$templates);
       $smarty->assign("got_uid", $this->got_uid);
       $smarty->assign("edit_uid",false);
+      $smarty->assign("allowUidProposalModification", $this->config->get_cfg_value("allowUidProposalModification", "false"));
       return($smarty->fetch(get_template_path('template.tpl', TRUE)));
     }
 
@@ -609,6 +623,7 @@ class userManagement extends management
         $smarty->assign("template", $_POST['template']);
       }
       $smarty->assign("templates",$templates); 
+      $smarty->assign("allowUidProposalModification", $this->config->get_cfg_value("allowUidProposalModification", "false"));
       return($smarty->fetch(get_template_path('template.tpl', TRUE)));
     }