Code

Updated samba tab
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 14 Jan 2009 13:32:15 +0000 (13:32 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 14 Jan 2009 13:32:15 +0000 (13:32 +0000)
- Added pasword expiry informations

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13348 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index 2f3df17e3f73537515556acbbf73b08fbd01b541..83cfce3127b50000cddbe339908d9eb4ebe0df26 100644 (file)
@@ -691,6 +691,45 @@ class sambaAccount extends plugin
       $smarty->assign("tsloginstate","");
     }
 
+    /* Create additional info for sambaKickOffTime and sambaPwdMustChange. 
+       e.g. Display effective kickoff time. Domain policy + user settings. 
+     */
+    $additional_info_KickoffTime = "";
+    $additional_info_PwdMustChange = "";
+
+    /* Calculate effective max Password Age 
+        This can only be calculated if sambaPwdLastSet ist set. 
+     */
+    $this->attrs['sambaPwdLastSet'][0] = time() - (60 *60);
+    if(isset($this->attrs['sambaPwdLastSet'][0])){
+      $last = $this->attrs['sambaPwdLastSet'][0];
+
+      $sid = $this->get_domain_info();
+      if(isset($sid['sambaMaxPwdAge'][0])){
+        $d = ($last + $sid['sambaMaxPwdAge'][0]) - time();
+
+        /* A negative value means the password is outdated 
+         */
+        if($d < 0){
+          $additional_info_PwdMustChange = sprintf(_("Invalid by domain policiy, since %s."),
+              date("d.m.Y H:i:s",$last + $sid['sambaMaxPwdAge'][0]));
+        }else{
+          if($this->password_expires && ($last + $sid['sambaMaxPwdAge'][0]) > $this->sambaPwdMustChange){
+            $additional_info_PwdMustChange = sprintf(_("Invalid by user policiy, on %s."),
+                date("d.m.Y H:i:s",  $this->sambaPwdMustChange));
+          }else{
+             $additional_info_PwdMustChange = sprintf(_("Invalid by domain policiy, on %s."),
+                date("d.m.Y H:i:s",  ($last + $sid['sambaMaxPwdAge'][0])));
+          }
+        }
+      }
+    }
+    
+    $additional_info_KickoffTime = "asdf";
+
+    $smarty->assign("additional_info_KickoffTime",$additional_info_KickoffTime);
+    $smarty->assign("additional_info_PwdMustChange",$additional_info_PwdMustChange);
+
     /* Show main page */
     $smarty->assign("multiple_support",$this->multiple_support_active);
     if ($this->samba3){
@@ -710,6 +749,29 @@ class sambaAccount extends plugin
   }
 
 
+  /*! \brief  Returns the samba Domain object, selected in the samba tab.   
+   */
+  function get_domain_info()
+  {
+    /* Only search once, return last result if available
+     */
+    if(!isset($this->cache['DOMAIN'][$this->sambaDomainName])){
+      $this->cache['DOMAIN'][$this->sambaDomainName] = array();
+      if(!empty($this->sambaDomainName) && isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName])){
+        $cfg = $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName];
+        $ldap = $this->config->get_ldap_link();
+        $ldap->cd($this->config->current['BASE']);
+        $ldap->search("(&(objectClass=sambaDomain)(sambaSID=".$cfg['SID']."))",array("*"));
+        if($ldap->count()){
+          $this->cache['DOMAIN'][$this->sambaDomainName] = $ldap->fetch();
+        }
+      }
+    }
+    return($this->cache['DOMAIN'][$this->sambaDomainName]);
+  }
+
+
+
   function get_samba_information()
   {
 
index 250639b858c34df3066b1a26bcf6178c4c8e7f2c..c58cdbc11fc6920f396202bc198124f96025f1ca 100644 (file)
        {html_options values=$years output=$years selected=$year}
       </select>
       {/render}
+         <br>{$additional_info_PwdMustChange}
      </td>
     </tr>
     <tr>
       <input type="hidden" name="sambaPwdMustChange" value="{$sambaPwdMustChange}">
       <input type="hidden" name="sambaPwdCanChange" value="{$sambaPwdMustChange}">
       <input type="hidden" name="sambaKickoffTime" value="{$sambaKickoffTime}">
+         <br>{$additional_info_KickoffTime}
      </td>
     </tr>
     <tr>