Code

Updated samba tab
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 7 Jul 2010 14:09:28 +0000 (14:09 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 7 Jul 2010 14:09:28 +0000 (14:09 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6@18952 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/samba/personal/samba/class_sambaAccount.inc
gosa-plugins/samba/personal/samba/samba3.tpl

index ee352e7cb9f5be0dea0f7dd05b67363c378d3b06..15952a5107f9922621aac8d5dd1a2a0229cac164 100644 (file)
@@ -76,7 +76,7 @@ class sambaAccount extends plugin
   var $objectclasses= array('sambaSamAccount');
   
   var $uid= "";
-  var $CopyPasteVars = array("kickoff_time_set","logoff_time_set","logon_time_set","mungedObject","orig_sambaDomainName");
+  var $CopyPasteVars = array("kickoff_time_set","logoff_time_set","logon_time_set","mungedObject","orig_sambaDomainName","enforcePasswordChange");
 
   var $multiple_support = TRUE;
 
@@ -86,6 +86,8 @@ class sambaAccount extends plugin
   var $no_expiry = FALSE;
   var $multiple_sambaUserWorkstations = array();
 
+  var $enforcePasswordChange = FALSE;
+
   function sambaAccount (&$config, $dn= NULL)
   {
     $this->mungedObject= new sambaMungedDial;
@@ -173,6 +175,18 @@ class sambaAccount extends plugin
     #TODO: use date format
     $this->sambaKickoffTime= $this->sambaKickoffTime == 0?"":date('d.m.Y', $this->sambaKickoffTime);
     $this->sambaPwdMustChange= $this->sambaPwdMustChange == 2147483647?"":date('d.m.Y', $this->sambaPwdMustChange);
+
+    // Enforce password change?
+    // ------------------------
+    // Check if we've the attribute 'sambaPwdLastSet' set and if its value is 0,
+    //  in this case a password change is forced for this account.
+    $this->enforcePasswordChange = (isset($this->attrs['sambaPwdLastSet']) && $this->attrs['sambaPwdLastSet'][0] == '0');
+
+    // User cannot change his password?  (sambaPwdLastSet int max(Int))
+    // --------------------------------
+    // The user is not able to change his password while sambaPwdCanChange is 4294967295 (Integer 32 Bit max)
+    $this->cannotChangePassword = (isset($this->attrs['sambaPwdCanChange']) && $this->attrs['sambaPwdCanChange'][0] == '4294967295');
+
   }
 
   function execute()
@@ -523,7 +537,7 @@ class sambaAccount extends plugin
           "onnectclientprinters","defaultprinter","shadow","brokenconn",
           "reconn","allow_pwchange","connectclientprinters","no_expiry","no_password_required","temporary_disable", 
           "password_expires","logon_time_set","logoff_time_set","kickoff_time_set","SetSambaLogonHours",
-          "workstation_list") as $attr){
+          "workstation_list","enforcePasswordChange","cannotChangePassword") as $attr){
       if(in_array($attr,$this->multi_boxes)){
         $smarty->assign("use_".$attr,TRUE);
       }else{
@@ -571,8 +585,10 @@ class sambaAccount extends plugin
 
     /* Show main page */
     $smarty->assign("multiple_support",$this->multiple_support_active);
-    $display.= $smarty->fetch (get_template_path('samba3.tpl', TRUE, dirname(__FILE__)));
 
+    $smarty->assign('enforcePasswordChange', $this->enforcePasswordChange);
+    $smarty->assign("cannotChangePassword", $this->cannotChangePassword);
+    $display.= $smarty->fetch (get_template_path('samba3.tpl', TRUE, dirname(__FILE__)));
     return ($display);
   }
 
@@ -956,6 +972,9 @@ class sambaAccount extends plugin
     if (isset($_POST['sambaTab'])){
       plugin::save_object();
 
+      $this->enforcePasswordChange = (isset($_POST['enforcePasswordChange']));
+      $this->cannotChangePassword = (isset($_POST['cannotChangePassword']));
+
       if(isset($_POST['display_information'])){
         msg_dialog::display(_("Information"), 
           $this->get_samba_information(),
@@ -1128,6 +1147,21 @@ class sambaAccount extends plugin
     }
     $this->attrs['objectClass']= $tmp;
 
+    // Enforce password change
+    if($this->enforcePasswordChange){
+        $this->attrs['sambaPwdLastSet'] = 0;
+    }else{
+        if ($this->sambaPwdLastSet != "0"){
+            $this->attrs['sambaPwdLastSet']= $this->sambaPwdLastSet;
+        } else {
+            $this->attrs['sambaPwdLastSet']= array();
+        }
+    }
+
+    if($this->cannotChangePassword){
+        $this->attrs['sambaPwdCanChange'] = 4294967295;
+    }
+
     /* Generate rid / primaryGroupId */
     if (!isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'])){
       msg_dialog::display(_("Warning"), _("Undefined Samba SID detected. Please fix this problem manually!"), WARNING_DIALOG);
@@ -1194,12 +1228,6 @@ class sambaAccount extends plugin
     } else {
       $this->attrs['sambaPwdMustChange']= array();
     }
-    /* Make sure not to save zero in sambaPwdLastset */
-    if ($this->sambaPwdLastSet != "0"){
-      $this->attrs['sambaPwdLastSet']= $this->sambaPwdLastSet;
-    } else {
-      $this->attrs['sambaPwdLastSet']= array();
-    }
     /* Account expiery */
     if ($this->logon_time_set == "1"){
       $this->attrs['sambaLogonTime']= $this->sambaLogonTime;
@@ -1353,10 +1381,9 @@ class sambaAccount extends plugin
             "sambaAcctFlagsN"             => _("Login from windows client requires no password"),
             "sambaAcctFlagsX"             => _("Password never expires"),
             "sambaAcctFlagsL"             => _("Lock samba account"),
-            "sambaKickoffTime"            => _("Account expires") ,
             "sambaPwdMustChange"          => _("Password expires") ,
-            "sambaLogonTime"              => _("Limit Logon Time") ,
-            "sambaLogoffTime"             => _("Limit Logoff Time") ,
+            "enforcePasswordChange"       => _("Enforce password change"),
+            "cannotChangePassword"        => _("Cannot change password"),
             "sambaLogonHours"             => _("Logon hours") ,
             "sambaUserWorkstations"       => _("Allow connection from"))
           ));
@@ -1379,7 +1406,7 @@ class sambaAccount extends plugin
             "onnectclientprinters","defaultprinter","shadow","brokenconn",
             "reconn","allow_pwchange","connectclientprinters","no_expiry","no_password_required","temporary_disable",
             "password_expires","logon_time_set","logoff_time_set","kickoff_time_set","SetSambaLogonHours",
-            "workstation_list") as $attr){
+            "workstation_list","enforcePasswordChange","cannotChangePassword") as $attr){
         if(isset($_POST["use_".$attr])){
           $this->multi_boxes[] = $attr;
         }
@@ -1569,7 +1596,15 @@ class sambaAccount extends plugin
     if(in_array("temporary_disable",$this->multi_boxes)){
       $ret['temporary_disable'] = $this->temporary_disable;
     }
-    
+   
+    if(in_array("enforcePasswordChange",$this->multi_boxes)){
+        $ret['enforcePasswordChange'] = $this->enforcePasswordChange;
+    }
+    if(in_array("cannotChangePassword",$this->multi_boxes)){
+        $ret['cannotChangePassword'] = $this->cannotChangePassword;
+    }
+
     if(in_array("SetSambaLogonHours",$this->multi_boxes)){
       $ret['sambaLogonHours'] = $this->sambaLogonHours;
     }
index f78c1348b2961cab0b9b93c239128107584223c5..ba683c234ad9ff6cec586cdfd779b199d512d93f 100644 (file)
 
 <h2><img class="center" alt="" align="middle" src="images/lists/key.png" />&nbsp;{t}Access options{/t}</h2>
 
+
+
 <table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4 border=0>
  <tr>
   <td colspan=2 style="width:50%; vertical-align:top;">
 
-   <!-- Samba policies -->
+        <!-- Samba policies -->
    <table>
-    <tr>
-     <td colspan=2>
-      {render acl=$sambaAcctFlagsXACL  checkbox=$multiple_support checked=$use_no_expiry}
-       <input id="no_expiry" type=checkbox name="no_expiry" value="1" {$flagsX} class="center">
-      {/render}
-      <label for="no_expiry">{t}The password never expires{/t}</label>
-     </td>
-    </tr>
-    <tr>
-     <td colspan=2>
-      {render acl=$sambaAcctFlagsNACL  checkbox=$multiple_support checked=$use_no_password_required}
-       <input id="no_password_required" type=checkbox name="no_password_required" value="1" {$flagsN} class="center">
-      {/render}
-      <label for="no_password_required">{t}Login from windows client requires no password{/t}</label>
-     </td>
-    </tr>
-<!--
-    <tr>
-     <td colspan=2 style="vertical-align:top;">
-      {render acl=$sambaPwdCanChangeACL  checkbox=$multiple_support checked=$use_allow_pwchange}
-       <input id="allow_pwchange" type=checkbox name="allow_pwchange" value="1" {$flagsP} class="center">
-      {/render}
-      <label for="allow_pwchange">{t}Allow user to change password from client{/t}</label>
-     </td>   
-    </tr>
--->
-    <tr>
-     <td colspan=2>
-      {render acl=$sambaAcctFlagsLACL  checkbox=$multiple_support checked=$use_temporary_disable}
-       <input id="temporary_disable" type=checkbox name="temporary_disable" value="1" {$flagsD} class="center">
-      {/render}
-      <label for="temporary_disable">{t}Lock samba account{/t}</label>
-     </td>
-    </tr>
-<!--
-    <tr>
-     <td>
-      {render acl=$sambaPwdMustChangeACL  checkbox=$multiple_support checked=$use_password_expires}
-      <input id="password_expires" type=checkbox name="password_expires" value="1" {$flagsC} class="center"
-               onClick="document.mainform.submit();">
-      {/render}
-      <label for="password_expires">{t}Password expires on{/t}</label>
-     </td>
-     <td style='width:55%'>
-      {render acl=$sambaPwdMustChangeACL}
-        <input type="text" id="sambaPwdMustChange" name="sambaPwdMustChange" class="date" style='width:100px' value="{$sambaPwdMustChange}">
-        {if $sambaPwdMustChangeACL|regex_replace:"/[cdmr]/":"" == "w"}
-        <script type="text/javascript">
-          {literal}
-          var datepicker  = new DatePicker({ relative : 'sambaPwdMustChange', language : '{/literal}{$lang}{literal}', keepFieldEmpty : true, enableCloseEffect : false, enableShowEffect : false });
-          {/literal}
-        </script>
-        {/if}
-      {/render}
-     </td>
-    </tr>
-  -->
-       {if $additional_info_PwdMustChange}
-    <tr>
-     <td colspan=2 style='padding-left: 10px;'>
-         <i>({$additional_info_PwdMustChange})</i>
-     </td>
-    </tr>
-       {/if}
-    <tr>
-     <td>
-      {render acl=$sambaKickoffTimeACL  checkbox=$multiple_support checked=$use_kickoff_time_set}
-       <input id="kickoff_time_set" type=checkbox name="kickoff_time_set" value="1" {$flagsK} class="center">
-      {/render}
-      <label for="kickoff_time_set">{t}Account expires after{/t}</label>
-        </td>
-     <td>
-      {render acl=$sambaKickoffTimeACL}
-        <input type="text" id="sambaKickoffTime" name="sambaKickoffTime" class="date" style='width:100px' value="{$sambaKickoffTime}">
-        {if $sambaKickoffTimeACL|regex_replace:"/[cdmr]/":"" == "w"}
-        <script type="text/javascript">
-          {literal}
-          var datepicker2 = new DatePicker({ relative : 'sambaKickoffTime', language : '{/literal}{$lang}{literal}', keepFieldEmpty : true, enableCloseEffect : false, enableShowEffect : false });
-          {/literal}
-        </script>
+       <tr>
+            <td>
+                {render acl=$enforcePasswordChangeACL checkbox=$multiple_support checked=$use_enforcePasswordChange}
+                 <input type='checkbox' value='1' name='enforcePasswordChange'
+                  {if $enforcePasswordChange} checked {/if} id='enforcePasswordChange'>
+                {/render}
+            </td>
+            <td>
+                <label for='enforcePasswordChange'>{t}Enforce password change{/t}</label>
+            </td>
+        </tr>
+        <tr>
+            <td>
+                {render acl=$sambaAcctFlagsXACL  checkbox=$multiple_support checked=$use_no_expiry}
+                <input id="no_expiry" type=checkbox name="no_expiry" value="1" {$flagsX} class="center">
+                {/render}
+            </td>
+            <td>
+                <label for="no_expiry">{t}The password never expires{/t}</label>
+            </td>
+        </tr>
+        <tr>
+            <td>
+                {render acl=$sambaAcctFlagsNACL  checkbox=$multiple_support checked=$use_no_password_required}
+                <input id="no_password_required" type=checkbox name="no_password_required" value="1" {$flagsN} class="center">
+                {/render}
+            </td>
+            <td>
+                <label for="no_password_required">{t}Login from windows client requires no password{/t}</label>
+            </td>
+        </tr>
+        <tr>
+            <td>
+                {render acl=$sambaAcctFlagsLACL  checkbox=$multiple_support checked=$use_temporary_disable}
+                <input id="temporary_disable" type=checkbox name="temporary_disable" value="1" {$flagsD} class="center">
+                {/render}
+            </td>
+            <td>
+                <label for="temporary_disable">{t}Lock samba account{/t}</label>
+            </td>
+        </tr>
+        <tr>
+            <td>
+                {render acl=$cannotChangePasswordACL  checkbox=$multiple_support checked=$use_cannotChangePassword}
+                 <input id="cannotChangePassword" type=checkbox name="cannotChangePassword" value="1" class="center"
+                    {if $cannotChangePassword} checked {/if}>
+                {/render}
+            </td>
+            <td>
+                <label for="cannotChangePassword">{t}Cannot change password{/t}</label>
+            </td>
+        </tr>
+
+           {if $additional_info_PwdMustChange}
+        <tr>
+            <td colspan=2 style='padding-left: 10px;'>
+                   <i>({$additional_info_PwdMustChange})</i>
+            </td>
+        </tr>
         {/if}
-      {/render}
-     </td>
-    </tr>
-    <tr>
-     <td colspan=2>&nbsp;</td>
-    </tr>
-    <tr>
-     <td colspan=2>
-      {render acl=$sambaLogonHoursACL mode=read_active  checkbox=$multiple_support checked=$use_SetSambaLogonHours}
-       {t}Samba logon times{/t}&nbsp;<input type='submit' name='SetSambaLogonHours' value='{t}Edit settings...{/t}'>
-      {/render}
-     </td>
-    </tr>
-   </table>
+    </table>
+
+    <p class="seperator">&nbsp;</p>
+    <br>
+
+   {render acl=$sambaLogonHoursACL mode=read_active  checkbox=$multiple_support checked=$use_SetSambaLogonHours}
+     {t}Samba logon times{/t}&nbsp;<input type='submit' name='SetSambaLogonHours' value='{t}Edit settings...{/t}'>
+   {/render}
    <!-- /Samba policies -->
 
   </td>