Code

Commented out options in template
[gosa.git] / gosa-plugins / samba / personal / samba / class_sambaAccount.inc
index b338fa811f0b16521887c10599c056e8c4ed2079..f4bc82270023471aab8ec8ee9e769d0d7c4bb5d3 100644 (file)
@@ -24,34 +24,13 @@ class sambaAccount extends plugin
   var $plHeadline= "Samba";
   var $plDescription= "This does something";
   var $view_logged = FALSE;
-
-  /* CLI vars */
-  var $cli_summary= "Manage users samba account";
-  var $cli_description= "Some longer text\nfor help";
-  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+  var $password_expires= 0;
 
   /* Switch for Samba version */
-  var $samba3= FALSE;
   var $uidNumber= 65535;
   var $gidNumber= 65535;
 
-  /* Samba 2 attributes */
-  var $pwdLastSet= "0";
-  var $logonTime= "0";
-  var $logoffTime= "2147483647";
-  var $kickoffTime= "2147483647";
-  var $pwdCanChange= "0";
-  var $pwdMustChange= "0";
-  var $password_expires= 0;
-  var $acctFlags= "[UX        ]";
-  var $smbHome= "";
-  var $homeDrive= "";
-  var $scriptPath= "";
-  var $profilePath= "";
-  var $rid= "";
-  var $primaryGroupID= "";
-
-  /* Samba 3 attributes */
+  /* Samba attributes */
   var $SID= "";
   var $ridBase= 0;
   var $sambaSID= "";
@@ -78,7 +57,8 @@ class sambaAccount extends plugin
   var $mungedObject;
 
   /* Helper */
-  var $show_ws_dialog= FALSE;
+  var $cache = array();
+  var $trustSelect= FALSE;
   var $logon_time_set= 0;
   var $logoff_time_set= 0;
   var $kickoff_time_set= 0;
@@ -96,31 +76,23 @@ class sambaAccount extends plugin
   /* Only used  for multiple edit */
   var $temporary_disable = FALSE;
   var $no_password_required = FALSE;
+  var $no_expiry = FALSE;
   var $multiple_sambaUserWorkstations = array();
 
   function sambaAccount (&$config, $dn= NULL)
   {
     /* Load attributes depending on the samba version */
-    $this->samba3= ($config->current['SAMBAVERSION'] == 3);
-
-    if ($this->samba3){
-      $this->attributes= array ("sambaSID", "sambaPwdLastSet", "sambaLogonTime",
-          "sambaLogoffTime", "sambaKickoffTime", "sambaPwdCanChange",
-          "sambaPwdMustChange", "sambaAcctFlags", "uid", "sambaMungedDial",
-          "sambaHomePath", "sambaHomeDrive", "sambaLogonScript",
-          "sambaProfilePath", "sambaPrimaryGroupSID", "sambaDomainName",
-          "sambaUserWorkstations", "sambaPasswordHistory",
-          "sambaLogonHours", "sambaBadPasswordTime",
-          "sambaBadPasswordCount");
-      $this->objectclasses= array ("sambaSamAccount");
-      $this->mungedObject= new sambaMungedDial;
-      $this->ctxattributes= $this->mungedObject->ctxattributes;
-    } else {
-      $this->attributes= array ("pwdLastSet", "logonTime", "logoffTime", "kickoffTime",
-          "pwdCanChange", "pwdMustChange", "acctFlags", "profilePath", "uid",
-          "smbHome", "homeDrive", "scriptPath", "rid", "primaryGroupID");
-      $this->objectclasses= array ("sambaAccount");
-    }
+    $this->attributes= array ("sambaSID", "sambaPwdLastSet", "sambaLogonTime",
+        "sambaLogoffTime", "sambaKickoffTime", "sambaPwdCanChange",
+        "sambaPwdMustChange", "sambaAcctFlags", "uid", "sambaMungedDial",
+        "sambaHomePath", "sambaHomeDrive", "sambaLogonScript",
+        "sambaProfilePath", "sambaPrimaryGroupSID", "sambaDomainName",
+        "sambaUserWorkstations", "sambaPasswordHistory",
+        "sambaLogonHours", "sambaBadPasswordTime",
+        "sambaBadPasswordCount");
+    $this->objectclasses= array ("sambaSamAccount");
+    $this->mungedObject= new sambaMungedDial;
+    $this->ctxattributes= $this->mungedObject->ctxattributes;
 
     plugin::plugin ($config, $dn);
 
@@ -130,7 +102,7 @@ class sambaAccount extends plugin
     }
 
     /* Get samba Domain in case of samba 3 */
-    if ($this->samba3 && $this->sambaSID != ""){
+    if ($this->sambaSID != ""){
       $this->SID= preg_replace ("/-[^-]+$/", "", $this->sambaSID);
       $ldap= $this->config->get_ldap_link();
       $ldap->cd($this->config->current['BASE']);
@@ -140,7 +112,7 @@ class sambaAccount extends plugin
         if(isset($attrs['sambaAlgorithmicRidBase'])){
           $this->ridBase= $attrs['sambaAlgorithmicRidBase'][0];
         } else {
-          $this->ridBase= $this->config->current['RIDBASE'];
+          $this->ridBase= $this->config->get_cfg_value("sambaRidBase");
         }
         if ($this->sambaDomainName == ""){
           $this->sambaDomainName= $attrs['sambaDomainName'][0];
@@ -149,8 +121,8 @@ class sambaAccount extends plugin
         if ($this->sambaDomainName == ""){
           $this->sambaDomainName= "DEFAULT";
         }
-        $this->ridBase= $this->config->current['RIDBASE'];
-        $this->SID= $this->config->current['SID'];
+        $this->ridBase= $this->config->get_cfg_value("sambaRidBase");
+        $this->SID= $this->config->get_cfg_value("sambaSid");
       }
 
       /* Save in order to compare later on */
@@ -158,7 +130,7 @@ class sambaAccount extends plugin
     }
 
     /* Fill mungedDial field */
-    if ($this->samba3 && isset($this->attrs['sambaMungedDial'])){
+    if (isset($this->attrs['sambaMungedDial'])){
       $this->mungedObject->load($this->sambaMungedDial);
     }
 
@@ -199,6 +171,11 @@ class sambaAccount extends plugin
 
     /* Save initial account state */
     $this->initially_was_account= $this->is_account;
+
+    /* Convert kickoff */
+    #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);
   }
 
   function execute()
@@ -218,8 +195,8 @@ class sambaAccount extends plugin
     }
     /* Do we represent a valid account? */
     if (!$this->is_account && $this->parent === NULL){
-      $display= "<img alt=\"\"src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
-        _("This account has no samba extensions.")."</b>";
+      $display= "<img alt=\"\"src=\"images/small-error.png\" align=\"middle\">&nbsp;<b>".
+        msgPool::noValidExtension(_("Samba"))."</b>";
       $display.= back_to_main();
       return ($display);
     }
@@ -231,8 +208,8 @@ class sambaAccount extends plugin
       $display= "";
       if ($this->parent !== NULL){
         if ($this->is_account){
-          $display= $this->show_disable_header(_("Remove samba account"),
-              _("This account has samba features enabled. You can disable them by clicking below."));
+          $display= $this->show_disable_header(msgPool::removeFeaturesButton(_("Samba")),
+              msgPool::featuresEnabled(_("Samba")));
         } else {
           $obj= $this->parent->by_object['posixAccount'];
 
@@ -241,11 +218,11 @@ class sambaAccount extends plugin
              uidNumbers. There'll be a better solution later
              on. */
           if ($obj->is_account){
-            $display= $this->show_enable_header(_("Create samba account"),
-                _("This account has samba features disabled. You can enable them by clicking below."));
+            $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Samba")),
+                msgPool::featuresDisabled(_("Samba")));
           } else {
-            $display= $this->show_enable_header(_("Create samba account"),
-                _("This account has samba features disabled. Posix features are needed for samba accounts, enable them first."), TRUE);
+            $display= $this->show_enable_header(msgPool::addFeaturesButton(_("Samba")),
+                msgPool::featuresDisabled(_("Samba"), _("POSIX")), TRUE);
           }
           return ($display);
         }
@@ -255,7 +232,7 @@ class sambaAccount extends plugin
     $SkipWrite = (!isset($this->parent) || !$this->parent) && !session::is_set('edit');
 
     /* Open Samaba Logong hours dialog */
-    if(isset($_POST['SetSambaLogonHours']) && $this->samba3 && $this->acl_is_writeable("sambaLogonHours")){
+    if(isset($_POST['SetSambaLogonHours']) && $this->acl_is_readable("sambaLogonHours")){
       $this->dialog = new sambaLogonHours($this->config,$this->dn,$this->sambaLogonHours);
     }
 
@@ -281,16 +258,15 @@ class sambaAccount extends plugin
 
     /* Prepare templating */
     $smarty= get_smarty();
+    $smarty->assign("usePrototype", "true");
 
     $tmp = $this->plInfo();
     foreach($tmp['plProvidedAcls'] as $var => $rest){
       $smarty->assign($var."ACL",$this->getacl($var,$SkipWrite));
     }
 
-    if ($this->sambaPwdMustChange=="0"){
-      $date= getdate();
-    } else {
-      $date= getdate($this->sambaPwdMustChange);
+    if(!session::is_set('edit') && !isset($this->parent)){
+      $smarty->assign("sambaLogonHoursACL","");
     }
 
     if ($this->sambaLogonTime=="2147483647" || $this->sambaLogonTime=="0"){
@@ -305,12 +281,6 @@ class sambaAccount extends plugin
       $sambaLogoffTime_date= getdate($this->sambaLogoffTime);
     }
     
-    if ($this->sambaKickoffTime=="2147483647" || $this->sambaKickoffTime=="0"){
-      $sambaKickoffTime_date= getdate();
-    } else {
-      $sambaKickoffTime_date= getdate($this->sambaKickoffTime);
-    }
-
     /* Remove user workstations? */
     if (isset($_POST["delete_ws"]) && isset($_POST['workstation_list'])){
 
@@ -337,268 +307,149 @@ class sambaAccount extends plugin
     /* Add user workstation? */
     if (isset($_POST["add_ws"])){
       if($this->acl_is_writeable("sambaUserWorkstations",$SkipWrite)){
-        $this->show_ws_dialog= TRUE;
+        $this->trustSelect= new trustSelect($this->config,get_userinfo());
         $this->dialog= TRUE;
       }
     }
 
     /* Add user workstation finished? */
-    if (isset($_POST["add_ws_finish"]) || isset($_POST["add_ws_cancel"])){
-      $this->show_ws_dialog= FALSE;
+    if (isset($_POST["add_ws_cancel"])){
+      $this->trustSelect= FALSE;
       $this->dialog= FALSE;
     }
 
-    /* Add user workstation? */
-    if (isset($_POST["add_ws_finish"]) && isset($_POST['wslist'])){
+    // Add selected machines to trusted ones.
+    if (isset($_POST["add_ws_finish"]) &&  $this->trustSelect){
+      $trusts = $this->trustSelect->detectPostActions();
+      if(isset($trusts['targets'])){
 
-      if($this->multiple_support_active){
-        foreach($_POST['wslist'] as $ws){
-          $this->multiple_sambaUserWorkstations[trim($we)] = array("Name" => trim($ws), "UsedByAllUsers" => TRUE);
-        }
-      }else{
-        $tmp= $this->sambaUserWorkstations;
-        foreach($_POST['wslist'] as $ws){
-          $tmp.= ",$ws";
+        $headpage = $this->trustSelect->getHeadpage();
+        if($this->multiple_support_active){
+          foreach($trusts['targets'] as $id){
+            $attrs = $headpage->getEntry($id);
+            $we =$attrs['cn'][0];
+            $this->multiple_sambaUserWorkstations[trim($we)] = array("Name" => trim($ws), "UsedByAllUsers" => TRUE);
+          }
+        }else{
+
+          $tmp= $this->sambaUserWorkstations;
+          foreach($trusts['targets'] as $id){
+            $attrs = $headpage->getEntry($id);
+            $we =$attrs['cn'][0];
+            $tmp.= ",$we";
+          }
+          $tmp= preg_replace('/,+/', ',', $tmp);
+          $this->sambaUserWorkstations= trim($tmp, ',');
         }
-        $tmp= preg_replace('/,+/', ',', $tmp);
-        $this->sambaUserWorkstations= trim($tmp, ',');
+
+        $this->is_modified= TRUE;
       }
-      $this->is_modified= TRUE;
+      $this->trustSelect= NULL;
+      $this->dialog= FALSE;
     }
 
     /* Show ws dialog */
-    if ($this->show_ws_dialog){
-
-      /* Save data */
-      $sambafilter= session::get("sambafilter");
-      foreach( array("depselect", "regex") as $type){
-        if (isset($_POST[$type])){
-          $sambafilter[$type]= $_POST[$type];
-        }
-      }
-      if (isset($_GET['search'])){
-        $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
-        if ($s == "**"){
-          $s= "*";
-        }
-        $sambafilter['regex']= $s;
-      }
-      session::set("sambafilter", $sambafilter);
+    if ($this->trustSelect){
 
-      /* Get workstation list */
-      $exclude= "";
-
-      if($this->multiple_support_active){
-        foreach($this->multiple_sambaUserWorkstations as $ws){
-          if($ws['UsedByAllUsers']){
-            $exclude.= "(cn=".$ws['Name']."$)";
-          }
-        }
-      }else{
-        foreach(split(',', $this->sambaUserWorkstations) as $ws){
-          $exclude.= "(cn=$ws$)";
-        }
-      }
-      if ($exclude != ""){
-        $exclude= "(!(|$exclude))";
-      }
-      $regex= $sambafilter['regex'];
-      $filter= "(&(objectClass=sambaSAMAccount)$exclude(uid=*$)(|(uid=$regex)(cn=$regex)))";
-      $res= get_list($filter, "winworkstation", $sambafilter['depselect'], array("uid"), GL_SUBSEARCH | GL_SIZELIMIT);
-        
-      $wslist= array();
-      foreach ($res as $attrs){
-        $wslist[]= preg_replace('/\$/', '', $attrs['uid'][0]);
-      }
-      asort($wslist);
-
-      $smarty->assign("search_image", get_template_path('images/search.png'));
-      $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
-      $smarty->assign("tree_image", get_template_path('images/tree.png'));
-      $smarty->assign("deplist", $this->config->idepartments);
-      $smarty->assign("alphabet", generate_alphabet());
-      foreach( array("depselect", "regex") as $type){
-        $smarty->assign("$type", $sambafilter[$type]);
-      }
-      $smarty->assign("hint", print_sizelimit_warning());
-      $smarty->assign("wslist", $wslist);
-      $smarty->assign("apply", apply_filter());
-      $display= $smarty->fetch (get_template_path('samba3_workstations.tpl', TRUE,
-                                dirname(__FILE__)));
-      return ($display);
+      // Build up blocklist
+      session::set('filterBlacklist', array('cn' => preg_split('/,/',$this->sambaUserWorkstations)));
+      return($this->trustSelect->execute());
     }
 
-    /* Fill calendar */
-    $days= array();
-    for($d= 1; $d<32; $d++){
-      $days[]= $d;
-    }
-    $years= array();
-    for($y= $date['year']-4; $y<$date['year']+4; $y++){
-      $years[]= $y;
-    }
-    $months= array(_("January"), _("February"), _("March"), _("April"),
-        _("May"), _("June"), _("July"), _("August"), _("September"),
-        _("October"), _("November"), _("December"));
-    $smarty->assign("day", $date["mday"]);
-    $smarty->assign("days", $days);
-    $smarty->assign("months", $months);
-    $smarty->assign("month", $date["mon"]-1);
-    $smarty->assign("years", $years);
-    $smarty->assign("year", $date["year"]);
-    
-    $sambaLogonTime_days= array();
-    for($d= 1; $d<32; $d++){
-      $sambaLogonTime_days[]= $d;
-    }
-    $sambaLogonTime_years= array();
-    for($y= $date['year']-4; $y<$date['year']+4; $y++){
-      $sambaLogonTime_years[]= $y;
-    }
-    $sambaLogonTime_months= array(_("January"), _("February"), _("March"), _("April"),
-        _("May"), _("June"), _("July"), _("August"), _("September"),
-        _("October"), _("November"), _("December"));
-    $smarty->assign("sambaLogonTime_day", $sambaLogonTime_date["mday"]);
-    $smarty->assign("sambaLogonTime_days", $sambaLogonTime_days);
-    $smarty->assign("sambaLogonTime_months", $sambaLogonTime_months);
-    $smarty->assign("sambaLogonTime_month", $sambaLogonTime_date["mon"]-1);
-    $smarty->assign("sambaLogonTime_years", $sambaLogonTime_years);
-    $smarty->assign("sambaLogonTime_year", $sambaLogonTime_date["year"]);
-    
-    $sambaLogoffTime_days= array();
-    for($d= 1; $d<32; $d++){
-      $sambaLogoffTime_days[]= $d;
-    }
-    $sambaLogoffTime_years= array();
-    for($y= $date['year']-4; $y<$date['year']+4; $y++){
-      $sambaLogoffTime_years[]= $y;
-    }
-    $sambaLogoffTime_months= array(_("January"), _("February"), _("March"), _("April"),
-        _("May"), _("June"), _("July"), _("August"), _("September"),
-        _("October"), _("November"), _("December"));
-    $smarty->assign("sambaLogoffTime_day", $sambaLogoffTime_date["mday"]);
-    $smarty->assign("sambaLogoffTime_days", $sambaLogoffTime_days);
-    $smarty->assign("sambaLogoffTime_months", $sambaLogoffTime_months);
-    $smarty->assign("sambaLogoffTime_month", $sambaLogoffTime_date["mon"]-1);
-    $smarty->assign("sambaLogoffTime_years", $sambaLogoffTime_years);
-    $smarty->assign("sambaLogoffTime_year", $sambaLogoffTime_date["year"]);
-    
-    $sambaKickoffTime_days= array();
-    for($d= 1; $d<32; $d++){
-      $sambaKickoffTime_days[]= $d;
-    }
-    $sambaKickoffTime_years= array();
-    for($y= $date['year']-4; $y<$date['year']+4; $y++){
-      $sambaKickoffTime_years[]= $y;
-    }
-    $sambaKickoffTime_months= array(_("January"), _("February"), _("March"), _("April"),
-        _("May"), _("June"), _("July"), _("August"), _("September"),
-        _("October"), _("November"), _("December"));
-    //$smarty->assign("sambaKickoffTime_day", $sambaKickoffTime_date["mday"]-1);
-    $smarty->assign("sambaKickoffTime_day", $sambaKickoffTime_date["mday"]); // hickert
-    $smarty->assign("sambaKickoffTime_days", $sambaKickoffTime_days);
-    $smarty->assign("sambaKickoffTime_months", $sambaKickoffTime_months);
-    $smarty->assign("sambaKickoffTime_month", $sambaKickoffTime_date["mon"]-1);
-    $smarty->assign("sambaKickoffTime_years", $sambaKickoffTime_years);
-    $smarty->assign("sambaKickoffTime_year", $sambaKickoffTime_date["year"]);
-     
     /* Fill boxes */
-    if ($this->samba3){
-      $domains= array();
-      foreach($this->config->data['SERVERS']['SAMBA'] as $name => $content){
-        $domains[]= $name;
-      }
-      $smarty->assign("domains", $domains);
+    $domains= array();
+    foreach($this->config->data['SERVERS']['SAMBA'] as $name => $content){
+      $domains[]= $name;
     }
-    $letters= array();
+    $smarty->assign("domains", $domains);
+    $letters= array("");
     for ($i= 68; $i<91; $i++){
       $letters[]= chr($i).":";
     }
     $smarty->assign("drives", $letters);
 
     /* Fill terminal server settings */
-    if ($this->samba3){
-      foreach ($this->ctxattributes as $attr){
-        /* Fill common attributes */
-        if (isset($this->mungedObject->ctx[$attr])){
-          $smarty->assign("$attr", $this->mungedObject->ctx[$attr]);
-          // Set field  to blank if value is 0
-          if(in_array($attr, array("CtxMaxConnectionTime", "CtxMaxDisconnectionTime", "CtxMaxIdleTime"))) {
-            if($this->mungedObject->ctx[$attr] == 0) {
-              $smarty->assign("$attr", "");
-            }
+    foreach ($this->ctxattributes as $attr){
+      /* Fill common attributes */
+      if (isset($this->mungedObject->ctx[$attr])){
+        $smarty->assign("$attr", $this->mungedObject->ctx[$attr]);
+        // Set field  to blank if value is 0
+        if(in_array($attr, array("CtxMaxConnectionTime", "CtxMaxDisconnectionTime", "CtxMaxIdleTime"))) {
+          if($this->mungedObject->ctx[$attr] == 0) {
+            $smarty->assign("$attr", "");
           }
-        } else {
-          $smarty->assign("$attr", "");
         }
+      } else {
+        $smarty->assign("$attr", "");
       }
+    }
 
-      /* Assign enum values for preset items */
-      $shadowModeVals= array( "0" => _("disabled"),
-          "1" => _("input on, notify on"),
-          "2" => _("input on, notify off"),
-          "3" => _("input off, notify on"),
-          "4" => _("input off, nofify off"));
+    /* Assign enum values for preset items */
+    $shadowModeVals= array( "0" => _("disabled"),
+        "1" => _("input on, notify on"),
+        "2" => _("input on, notify off"),
+        "3" => _("input off, notify on"),
+        "4" => _("input off, nofify off"));
 
-      $brokenConnModeVals= array(      "0" => _("disconnect"),
-          "1" => _("reset"));
+    $brokenConnModeVals= array(        "0" => _("disconnect"),
+        "1" => _("reset"));
 
-      $reConnModeVals= array( "0" => _("from any client"),
-          "1" => _("from previous client only"));
+    $reConnModeVals= array( "0" => _("from any client"),
+        "1" => _("from previous client only"));
 
-      /* Fill preset items */
-      $smarty->assign("shadow", $shadowModeVals);
-      $smarty->assign("brokenconn", $brokenConnModeVals);
-      $smarty->assign("reconn", $reConnModeVals);
+    /* Fill preset items */
+    $smarty->assign("shadow", $shadowModeVals);
+    $smarty->assign("brokenconn", $brokenConnModeVals);
+    $smarty->assign("reconn", $reConnModeVals);
 
-      /* Fill preset items with values */
-      $smarty->assign("shadowmode", $this->mungedObject->getShadow());
-      $smarty->assign("brokenconnmode", $this->mungedObject->getBrokenConn());
-      $smarty->assign("reconnmode", $this->mungedObject->getReConn());
+    /* Fill preset items with values */
+    $smarty->assign("shadowmode", $this->mungedObject->getShadow());
+    $smarty->assign("brokenconnmode", $this->mungedObject->getBrokenConn());
+    $smarty->assign("reconnmode", $this->mungedObject->getReConn());
 
-      if(session::get('js')){
-        /* Set form elements to disabled/enable state */
-        $smarty->assign("tsloginstate", $this->mungedObject->getTsLogin()?"":"disabled");
+    if(session::get('js')){
+      /* Set form elements to disabled/enable state */
+      $smarty->assign("tsloginstate", $this->mungedObject->getTsLogin()?"":"disabled");
 
-        $smarty->assign("inheritstate", "");
-        if($this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)){
-          $smarty->assign("inheritstate", $this->mungedObject->getInheritMode()?"disabled":"");
-        }
-      }else{
-        $smarty->assign("tsloginstate", "");
-        $smarty->assign("inheritstate", "");
-      }      
-
-      /* Set checkboxes to checked or unchecked state */
-      $smarty->assign("tslogin", $this->mungedObject->getTsLogin()?"checked":"");
-      $smarty->assign("inherit", $this->mungedObject->getInheritMode()?"checked":"");
-      $smarty->assign("connectclientdrives",
-                      $this->mungedObject->getConnectClientDrives()?"checked":"");
-      $smarty->assign("connectclientprinters",
-                      $this->mungedObject->getConnectClientPrinters()?"checked":"");
-      $smarty->assign("defaultprinter",
-                      $this->mungedObject->getDefaultPrinter()?"checked":"");
-      $smarty->assign("CtxMaxConnectionTimeF",
-                      $this->mungedObject->getCtxMaxConnectionTimeF()?"checked":"");
-      $smarty->assign("CtxMaxDisconnectionTimeF",
-                      $this->mungedObject->getCtxMaxDisconnectionTimeF()?"checked":"");
-      $smarty->assign("CtxMaxIdleTimeF",
-                      $this->mungedObject->getCtxMaxIdleTimeF()?"checked":"");
+      $smarty->assign("inheritstate", "");
+      if($this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)){
+        $smarty->assign("inheritstate", $this->mungedObject->getInheritMode()?"disabled":"");
+      }
+    }else{
+      $smarty->assign("tsloginstate", "");
+      $smarty->assign("inheritstate", "");
+    }      
 
-      
-      /* Fill sambaUserWorkstations */
-      $ws= split(",", $this->sambaUserWorkstations);
-      sort($ws);
-      
-      /* Tidy checks for empty option, and smarty will produce one if array[0]="" */
-      if(($ws[0]=="")&&(count($ws)==1)) $ws=array();
+    /* Set checkboxes to checked or unchecked state */
+    $smarty->assign("tslogin", $this->mungedObject->getTsLogin()?"checked":"");
+    $smarty->assign("inherit", $this->mungedObject->getInheritMode()?"checked":"");
+    $smarty->assign("connectclientdrives",
+                    $this->mungedObject->getConnectClientDrives()?"checked":"");
+    $smarty->assign("connectclientprinters",
+                    $this->mungedObject->getConnectClientPrinters()?"checked":"");
+    $smarty->assign("defaultprinter",
+                    $this->mungedObject->getDefaultPrinter()?"checked":"");
+    $smarty->assign("CtxMaxConnectionTimeF",
+                    $this->mungedObject->getCtxMaxConnectionTimeF()?"checked":"");
+    $smarty->assign("CtxMaxDisconnectionTimeF",
+                    $this->mungedObject->getCtxMaxDisconnectionTimeF()?"checked":"");
+    $smarty->assign("CtxMaxIdleTimeF",
+                    $this->mungedObject->getCtxMaxIdleTimeF()?"checked":"");
 
-      if($this->multiple_support_active){
-        $smarty->assign("multiple_workstations",$this->multiple_sambaUserWorkstations);
-      }  
+    
+    /* Fill sambaUserWorkstations */
+    $ws= explode(",", $this->sambaUserWorkstations);
+    sort($ws);
+    
+    /* Tidy checks for empty option, and smarty will produce one if array[0]="" */
+    if(($ws[0]=="")&&(count($ws)==1)) $ws=array();
 
-      $smarty->assign("workstations", $ws);
-    }
+    if($this->multiple_support_active){
+      $smarty->assign("multiple_workstations",$this->multiple_sambaUserWorkstations);
+    }  
+
+    $smarty->assign("workstations", $ws);
+    
 
     /* Variables */
     foreach($this->attributes as $val){
@@ -621,18 +472,17 @@ class sambaAccount extends plugin
         $smarty->assign("flagsN", "");
     }
 
-    if($this->samba3){
-      if ($this->sambaPwdCanChange=="1"){
-        $smarty->assign("flagsP", "checked");
-      } else {
-        $smarty->assign("flagsP", "");
-      }
-    }else{
-      if ($this->pwdCanChange=="1"){
-        $smarty->assign("flagsP", "checked");
-      } else {
-        $smarty->assign("flagsP", "");
-      }
+    // check if password never expires
+    if (is_integer(strpos($this->sambaAcctFlags, "X"))) {
+        $smarty->assign("flagsX", "checked");
+    } else {
+        $smarty->assign("flagsX", "");
+    }
+
+    if ($this->sambaPwdCanChange=="1"){
+      $smarty->assign("flagsP", "checked");
+    } else {
+      $smarty->assign("flagsP", "");
     }
 
     if ($this->password_expires=="1"){
@@ -658,10 +508,8 @@ class sambaAccount extends plugin
    
 
     /* In case of javascript, disable some fields on demand */
-    if ($this->samba3){
-      foreach($this->mungedObject->getOnDemandFlags() as $key => $value) {
-        $smarty->assign("$key", "$value");
-      }
+    foreach($this->mungedObject->getOnDemandFlags() as $key => $value) {
+      $smarty->assign("$key", "$value");
     }
 
 
@@ -676,7 +524,7 @@ class sambaAccount extends plugin
           "inherit","CtxWorkDirectory","CtxInitialProgram","CtxMaxConnectionTimeF","CtxMaxConnectionTime","CtxMaxDisconnectionTimeF",
           "CtxMaxDisconnectionTime","CtxMaxIdleTimeF","CtxMaxIdleTime","connectclientdrives",
           "onnectclientprinters","defaultprinter","shadow","brokenconn",
-          "reconn","allow_pwchange","connectclientprinters","no_password_required","temporary_disable", 
+          "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){
       if(in_array($attr,$this->multi_boxes)){
@@ -690,17 +538,324 @@ 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_PwdMustChange = "";
+
+    /* Calculate effective max Password Age 
+        This can only be calculated if sambaPwdLastSet ist set. 
+     */
+    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(_("The password is outdated since %s, by domain policy."),
+              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(_("The password is valid till %s, by user policy."),
+                date("d.m.Y H:i:s",  $this->sambaPwdMustChange));
+          }else{
+             $additional_info_PwdMustChange = sprintf(_("The password is valid till %s, by domain policy."),
+                date("d.m.Y H:i:s",  ($last + $sid['sambaMaxPwdAge'][0])));
+          }
+        }
+      }
+    }
+    $smarty->assign("additional_info_PwdMustChange",$additional_info_PwdMustChange);
+    $smarty->assign("no_expiry",$this->no_expiry);
+
     /* Show main page */
     $smarty->assign("multiple_support",$this->multiple_support_active);
-    if ($this->samba3){
-      $display.= $smarty->fetch (get_template_path('samba3.tpl', TRUE, dirname(__FILE__)));
+    $display.= $smarty->fetch (get_template_path('samba3.tpl', TRUE, dirname(__FILE__)));
+
+    return ($display);
+  }
+
+
+  /*! \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()
+  {
+
+    /* Defaults 
+     */
+    $sambaMinPwdLength = "unset";
+    $sambaPwdHistoryLength = "unset";
+    $sambaLogonToChgPwd = "unset";
+    $sambaMaxPwdAge = "unset";
+    $sambaMinPwdAge = "unset";
+    $sambaLockoutDuration = "unset";
+    $sambaLockoutThreshold = "unset";
+    $sambaForceLogoff = "unset";
+    $sambaRefuseMachinePwdChange = "unset";
+    $sambaPwdLastSet = "unset";
+    $sambaLogonTime = "unset";
+    $sambaLogoffTime = "unset";
+
+    $sambaKickoffTime = "unset"; 
+    $sambaPwdCanChange = "unset";
+    $sambaPwdMustChange = "unset";
+    $sambaBadPasswordCount = "unset";
+    $sambaBadPasswordTime = "unset";
+
+    /* Domain attributes 
+     */
+    $domain_attributes = array("sambaMinPwdLength","sambaPwdHistoryLength","sambaMaxPwdAge",
+        "sambaMinPwdAge","sambaLockoutDuration","sambaRefuseMachinePwdChange",
+        "sambaLogonToChgPwd","sambaLockoutThreshold","sambaForceLogoff");
+
+    /* User attributes 
+     */
+    $user_attributes = array("sambaBadPasswordTime","sambaPwdLastSet","sambaLogonTime","sambaLogoffTime",
+        "sambaKickoffTime","sambaPwdCanChange","sambaPwdMustChange","sambaBadPasswordCount", "sambaSID");
+
+    /* Get samba SID object and parse settings.
+     */  
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+    if(!empty($this->sambaDomainName) && isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName])){
+      $attrs = $this->get_domain_info();
+      foreach($domain_attributes as $attr){
+        if(isset($attrs[$attr])){
+          $$attr = $attrs[$attr][0];
+        }
+      }
+    }
+  
+    /* Get user infos
+     */
+    foreach($user_attributes as $attr){
+      if(isset($this->attrs[$attr])){
+        $$attr = $this->attrs[$attr][0];
+      }
+    }
+    if($this->password_expires){
+      $sambaPwdMustChange = $this->sambaPwdMustChange;
     } else {
-      $display.= $smarty->fetch (get_template_path('samba2.tpl', TRUE, dirname(__FILE__)));
+      if (is_numeric($sambaPwdMustChange)) {
+        $sambaPwdMustChange= date('d.m.Y', $sambaPwdMustChange);
+      }
     }
+    if($this->kickoff_time_set){
+      $sambaKickoffTime = $this->sambaKickoffTime;
+    } else {
+      if (is_numeric($sambaKickoffTime)) {
+        $sambaKickoffTime= date('d.m.Y', $sambaKickoffTime);
+      }
+    }
+    $sambaPwdCanChange = $this->sambaPwdCanChange;
 
-    return ($display);
+
+    /* DOMAIN Attributes 
+     */
+
+    /* sambaMinPwdLength: Password length has a default of 5 
+     */
+    if($sambaMinPwdLength == "unset" || $sambaMinPwdLength == 5){
+      $sambaMinPwdLength  = "5 <i>("._("default").")</i>";
+    }
+
+    /* sambaPwdHistoryLength: Length of Password History Entries (default: 0 => off)
+     */
+    if($sambaPwdHistoryLength == "unset" || $sambaPwdHistoryLength == 0){
+      $sambaPwdHistoryLength = _("Off")." <i>("._("default").")</i>";
+    }
+
+    /* sambaLogonToChgPwd: Force Users to logon for password change (default: 0 => off, 2 => on) 
+     */
+    if($sambaLogonToChgPwd == "unset" || $sambaLogonToChgPwd == 0){
+      $sambaLogonToChgPwd = _("Off")." <i>("._("default").")</i>";
+    }else{
+      $sambaLogonToChgPwd = _("On");
+    }
+    
+    /* sambaMaxPwdAge: Maximum password age, in seconds (default: -1 => never expire passwords)'
+     */
+    if($sambaMaxPwdAge == "unset" || $sambaMaxPwdAge == "-1"){
+      $sambaMaxPwdAge = _("disabled")." <i>("._("default").")</i>";
+    }else{
+      $sambaMaxPwdAge .= " "._("seconds"); 
+    }
+
+    /* sambaMinPwdAge: Minimum password age, in seconds (default: 0 => allow immediate password change
+     */
+    if($sambaMinPwdAge == "unset" || $sambaMinPwdAge == 0){
+      $sambaMinPwdAge = _("disabled")." <i>("._("default").")</i>";
+    }else{
+      $sambaMinPwdAge .= " "._("seconds"); 
+    }
+
+    /* sambaLockoutDuration: Lockout duration in minutes (default: 30, -1 => forever)
+     */
+    if($sambaLockoutDuration == "unset" || $sambaLockoutDuration == 30){
+      $sambaLockoutDuration = "30 "._("minutes")." <i>("._("default").")</i>";
+    }elseif($sambaLockoutDuration == -1){
+      $sambaLockoutDuration = _("forever");
+    }else{
+      $sambaLockoutDuration .= " "._("minutes");
+    }
+
+    /* sambaLockoutThreshold: Lockout users after bad logon attempts (default: 0 => off
+     */
+    if($sambaLockoutThreshold == "unset" || $sambaLockoutThreshold == 0){
+      $sambaLockoutThreshold = _("disabled")." <i>("._("default").")</i>";
+    }
+
+    /* sambaForceLogoff: Disconnect Users outside logon hours (default: -1 => off, 0 => on 
+     */
+    if($sambaForceLogoff == "unset" || $sambaForceLogoff == -1){
+      $sambaForceLogoff = _("off")." <i>("._("default").")</i>";
+    }else{
+      $sambaForceLogoff = _("on");
+    }
+
+    /* sambaRefuseMachinePwdChange: Allow Machine Password changes (default: 0 => off
+     */
+    if($sambaRefuseMachinePwdChange == "none" || $sambaRefuseMachinePwdChange == 0){
+      $sambaRefuseMachinePwdChange = _("off")." <i>("._("default").")</i>";
+    }else{
+      $sambaRefuseMachinePwdChange = _("on");
+    }
+   
+    /* USER Attributes 
+     */
+    /* sambaBadPasswordTime: Time of the last bad password attempt
+     */
+    if($sambaBadPasswordTime == "unset" || empty($sambaBadPasswordTime)){
+      $sambaBadPasswordTime = "<i>("._("unset").")</i>";
+    }else{
+      $sambaBadPasswordTime = date("d.m.Y H:i:s",$sambaBadPasswordTime);
+    }
+
+    /* sambaBadPasswordCount: Bad password attempt count 
+     */
+    if($sambaBadPasswordCount == "unset" || empty($sambaBadPasswordCount)){
+      $sambaBadPasswordCount = "<i>("._("unset").")</i>";
+    }else{
+      $sambaBadPasswordCount = date("d.m.Y H:i:s",$sambaBadPasswordCount);
+    }
+
+    /* sambaPwdLastSet: Timestamp of the last password update
+     */
+    if($sambaPwdLastSet == "unset" || empty($sambaPwdLastSet)){
+      $sambaPwdLastSet = "<i>("._("unset").")</i>";
+    }else{
+      $sambaPwdLastSet = date("d.m.Y H:i:s",$sambaPwdLastSet);
+    }
+
+    /* sambaLogonTime: Timestamp of last logon
+     */
+    if($sambaLogonTime == "unset" || empty($sambaLogonTime)){
+      $sambaLogonTime = "<i>("._("unset").")</i>";
+    }else{
+      $sambaLogonTime = date("d.m.Y H:i:s",$sambaLogonTime);
+    }
+
+    /* sambaLogoffTime: Timestamp of last logoff
+     */
+    if($sambaLogoffTime == "unset" || empty($sambaLogoffTime)){
+      $sambaLogoffTime = "<i>("._("unset").")</i>";
+    }else{
+      $sambaLogoffTime = date("d.m.Y H:i:s",$sambaLogoffTime);
+    }
+   
+    /* sambaKickoffTime: Timestamp of when the user will be logged off automatically
+     */
+    if($sambaKickoffTime == "unset" || empty($sambaKickoffTime)){
+      $sambaKickoffTime = "<i>("._("unset").")</i>";
+    }
+
+    /* sambaPwdMustChange: Timestamp of when the password will expire
+     */
+    if($sambaPwdMustChange == "unset" || empty($sambaPwdMustChange)){
+      $sambaPwdMustChange = "<i>("._("unset").")</i>";
+    }
+
+    /* sambaPwdCanChange: Timestamp of when the user is allowed to update the password
+     */
+    if($sambaPwdCanChange == "unset" || empty($sambaPwdCanChange)){
+      $sambaPwdCanChange = "<i>("._("unset").")</i>";
+    }elseif($sambaPwdCanChange != "unset" && time() > $sambaPwdCanChange){
+      $sambaPwdCanChange = _("immediately") ;
+    }else{
+      $days     = floor((($sambaPwdCanChange - time()) / 60 / 60 / 24)) ;
+      $hours    = floor((($sambaPwdCanChange - time()) / 60 / 60) % 24) ;
+      $minutes  = floor((($sambaPwdCanChange - time()) / 60 ) % 60) ;
+    
+      $sambaPwdCanChange = " ".$days." "._("days");
+      $sambaPwdCanChange.= " ".$hours." "._("hours");
+      $sambaPwdCanChange.= " ".$minutes." "._("minutes");
+    }
+
+    $str =
+      "\n<div style='height:200px; overflow: auto;'>".
+      "\n<table style='width:100%;'>".
+      "\n<tr><td><b>"._("Domain attributes")."</b></td></tr>". 
+      "\n<tr><td>"._("Min password length").":           </td><td>".$sambaMinPwdLength."</td></tr>". 
+      "\n<tr><td>"._("Min password length").":           </td><td>".$sambaMinPwdLength."</td></tr>". 
+      "\n<tr><td>"._("Password history").":              </td><td>".$sambaPwdHistoryLength."</td></tr>".
+      "\n<tr><td>"._("Force password change").":         </td><td>".$sambaLogonToChgPwd."</td></tr>".
+      "\n<tr><td>"._("Maximum password age").":          </td><td>".$sambaMaxPwdAge."</td></tr>".
+      "\n<tr><td>"._("Minimum password age").":          </td><td>".$sambaMinPwdAge."</td></tr>".
+      "\n<tr><td>"._("Lockout duration").":              </td><td>".$sambaLockoutDuration."</td></tr>".
+      "\n<tr><td>"._("Bad lockout attempt").":           </td><td>".$sambaLockoutThreshold."</td></tr>".
+      "\n<tr><td>"._("Disconnect time").":               </td><td>".$sambaForceLogoff."</td></tr>".
+      "\n<tr><td>"._("Refuse machine password change").":</td><td>".$sambaRefuseMachinePwdChange."</td></tr>".
+      "\n<tr><td>&nbsp;</td></tr>". 
+      "\n<tr><td><b>"._("User attributes")."</b></td></tr>". 
+      "\n<tr><td>"._("SID").":                           </td><td>".$sambaSID."</td></tr>".
+      "\n<tr><td>"._("Last failed login").":             </td><td>".$sambaBadPasswordTime."</td></tr>".
+      "\n<tr><td>"._("Logon attempts").":                </td><td>".$sambaBadPasswordCount."</td></tr>".
+      "\n<tr><td>"._("Last password update").":          </td><td>".$sambaPwdLastSet."</td></tr>".
+      "\n<tr><td>"._("Last logon").":                    </td><td>".$sambaLogonTime."</td></tr>".
+      "\n<tr><td>"._("Last logoff").":                   </td><td>".$sambaLogoffTime."</td></tr>".
+      "\n<tr><td>"._("Automatic logoff").":              </td><td>".$sambaKickoffTime."</td></tr>";
+
+      if($this->no_expiry){
+        $str .= "\n<tr><td>"._("Password expires").":              </td><td>"._("No")."</td></tr>";
+        $str .= "\n<tr><td colspan='2'><font color='gray'>".
+          sprintf(_("The password would expire on %s, but the password expiry is disabled."),$sambaPwdMustChange).
+          "</font></td></tr>";
+      }else{
+        $str .= "\n<tr><td>"._("Password expires").":              </td><td>".$sambaPwdMustChange."</td></tr>";
+      }
+    
+      $str .= "\n<tr><td>"._("Password change available").":     </td><td>".$sambaPwdCanChange."</td></tr>".
+      "\n</table>";
+      "\n</div>";
+    return($str);
   }
 
+
   function remove_from_parent()
   {
     /* Cancel if there's nothing to do here */
@@ -735,7 +890,9 @@ class sambaAccount extends plugin
 
     new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
 
-    show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/samba account with dn '%s' failed."),$this->dn));
+    if (!$ldap->success()){
+      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
+    }
 
     /* Optionally execute a command after we're done */
     $this->handle_post_events("remove", array("uid" => $this->uid));
@@ -748,30 +905,43 @@ class sambaAccount extends plugin
     /* Call common method to give check the hook */
     $message= plugin::check();
 
-    if ($this->samba3){
+    /* sambaHomePath requires sambaHomeDrive and vice versa */
+    if(!empty($this->sambaHomePath) && empty($this->sambaHomeDrive)){
+      $message[]= msgPool::required(_("Home drive"));
+    }
+    if(!empty($this->sambaHomeDrive) && empty($this->sambaHomePath)){
+      $message[]= msgPool::required(_("Home path"));
+    }
 
-      /* Strings */
-      foreach (array( "sambaHomePath" => _("Home directory"),
-            "sambaProfilePath" => _("Profile path")) as $key => $val){
-        if (!$this->mungedObject->is_samba_path($this->$key)){
-          $message[]= sprintf(_("The value specified as '%s' contains invalid characters!"), $val);
-        }
+    /* Strings */
+    foreach (array( "sambaHomePath" => _("Home directory"),
+          "sambaProfilePath" => _("Profile path")) as $key => $val){
+      if (!$this->mungedObject->is_samba_path($this->$key)){
+        $message[]= msgPool::invalid($val);
       }
+    }
 
-      /* Numeric values */
-      foreach (array(  "CtxMaxConnectionTime" => _("Connection"),
-            "CtxMaxDisconnectionTime" => _("Disconnection"),
-            "CtxMaxIdleTime" => _("IDLE")) as $key => $val){
+    /* Numeric values */
+    foreach (array(    "CtxMaxConnectionTime" => _("Connection"),
+          "CtxMaxDisconnectionTime" => _("Disconnection"),
+          "CtxMaxIdleTime" => _("IDLE")) as $key => $val){
 
-        if (isset($this->mungedObject->ctx[$key]) && !tests::is_id($this->mungedObject->ctx[$key]) && $val != 0){
-          $message[]= sprintf(_("The timeout property '%s' is checked and contains invalid or no characters!"), $val);
-        }
+      if (isset($this->mungedObject->ctx[$key]) && !tests::is_id($this->mungedObject->ctx[$key]) && $val != 0){
+        $message[]= msgPool::invalid($val);
       }
+    }
 
-      /* Too many workstations? Windows usrmgr only supports eight */
-      if (substr_count($this->sambaUserWorkstations, ",") >= 8){
-        $message[]= _("The windows user manager only allows eight clients. You've specified more than eight.");
-      }
+    /* Check dates */
+    if (!tests::is_date($this->sambaKickoffTime)){
+      $message[]= msgPool::invalid(_("Account expires after"), $this->sambaKickoffTime,"" ,"23.02.2009");
+    }
+    if (!tests::is_date($this->sambaPwdMustChange)){
+      $message[]= msgPool::invalid(_("Password expires on"), $this->sambaPwdMustChange,"" ,"23.02.2009");
+    }
+
+    /* Too many workstations? Windows usrmgr only supports eight */
+    if (substr_count($this->sambaUserWorkstations, ",") >= 8){
+      $message[]= _("The windows usermanager allows eight clients at maximum!");
     }
 
     return ($message);
@@ -788,13 +958,15 @@ class sambaAccount extends plugin
     if (isset($_POST['sambaTab'])){
       plugin::save_object();
 
+      if(isset($_POST['display_information'])){
+        msg_dialog::display(_("Information"), 
+          $this->get_samba_information(),
+          INFO_DIALOG);
+      }
+
       /* Take care about access options */
       if ($this->acl_is_writeable("sambaAcctFlagsL",$SkipWrite) || ($this->acl_is_writeable("sambaAcctFlagsN",$SkipWrite))){
-        if ($this->samba3){
-          $attrname= "sambaPwdCanChange";
-        } else {
-          $attrname= "pwdCanChange";
-        }
+        $attrname= "sambaPwdCanChange";
         if (isset($_POST["allow_pwchange"]) && $_POST["allow_pwchange"] == 1){
           $tmp= 1;
         } else {
@@ -803,10 +975,18 @@ class sambaAccount extends plugin
         if ($this->$attrname != $tmp){
           $this->is_modified= TRUE;
         }
-        $this->pwdCanChange= $tmp;
         $this->sambaPwdCanChange= $tmp;
       }
-      $tmp= "UX";
+      $tmp= "U";
+
+      $this->no_expiry = FALSE;
+      if (isset($_POST["no_expiry"])){
+        if ($_POST["no_expiry"] == 1){
+          $tmp.= "X";
+          $this->no_expiry = TRUE;
+        }
+      }
+
       $this->no_password_required = FALSE;
       if (isset($_POST["no_password_required"])){
         if ($_POST["no_password_required"] == 1){
@@ -863,11 +1043,7 @@ class sambaAccount extends plugin
 
       /* Only save if acl's are set */
       if ($this->acl_is_writeable("sambaAcctFlagsL",$SkipWrite) || ($this->acl_is_writeable("sambaAcctFlagsN",$SkipWrite))){
-        if ($this->samba3){
-          $attrname= "sambaAcctFlags";
-        } else {
-          $attrname= "acctFlags";
-        }
+        $attrname= "sambaAcctFlags";
         if ($this->$attrname != $tmp){
           $this->is_modified= TRUE;
         }
@@ -875,62 +1051,60 @@ class sambaAccount extends plugin
       }
 
       /* Save sambaDomain attribute */
-      if ($this->acl_is_writeable("sambaDomainName",$SkipWrite) && $this->samba3 && isset ($_POST['sambaDomainName'],$SkipWrite)){
+      if ($this->acl_is_writeable("sambaDomainName",$SkipWrite) && isset ($_POST['sambaDomainName'],$SkipWrite)){
         $this->sambaDomainName= validate($_POST['sambaDomainName']);
       }
 
       /* Save CTX values */
-      if ($this->samba3){
-
-        /* Save obvious values */
-        foreach($this->ctxattributes as $val){
-          if (isset($_POST[$val]) && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)){
-            if (get_magic_quotes_gpc()) {
-              $this->mungedObject->ctx[$val]= stripcslashes(validate($_POST[$val]));
-            } else {
-              $this->mungedObject->ctx[$val]= validate($_POST[$val]);
-            }
+      /* Save obvious values */
+      foreach($this->ctxattributes as $val){
+        if (isset($_POST[$val]) && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)){
+          if (get_magic_quotes_gpc()) {
+            $this->mungedObject->ctx[$val]= stripcslashes(validate($_POST[$val]));
+          } else {
+            $this->mungedObject->ctx[$val]= validate($_POST[$val]);
           }
         }
+      }
 
-        /* Save checkbox states. */
-        $this->mungedObject->setTsLogin(!isset($_POST['tslogin'])
-                        && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
-        // Need to do some index checking to avoid messages like "index ... not found"
-        if(isset($_POST['brokenconn'])) {
-          $this->mungedObject->setBrokenConn($_POST['brokenconn'] == '1'
-                        && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
-        }
-        if(isset($_POST['reconn'])) {
-          $this->mungedObject->setReConn($_POST['reconn'] == '1'
-                        && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
-        }
-        $this->mungedObject->setInheritMode(isset($_POST['inherit'])
-                        && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
-        $this->mungedObject->setCtxMaxConnectionTimeF(!isset($_POST['CtxMaxConnectionTimeF'])
-                        && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
-        $this->mungedObject->setCtxMaxDisconnectionTimeF(
-                        !isset($_POST['CtxMaxDisconnectionTimeF']) 
-                        && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
-        $this->mungedObject->setCtxMaxIdleTimeF(!isset($_POST['CtxMaxIdleTimeF'])
-                        && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
-        $this->mungedObject->setConnectClientDrives(isset($_POST['connectclientdrives'])
-                        && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
-        $this->mungedObject->setConnectClientPrinters(isset($_POST['connectclientprinters'])  
-                        && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
-        $this->mungedObject->setDefaultPrinter(isset($_POST['defaultprinter'])
-                        && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
-
-        /* Save combo boxes. Takes two values */
-        if(isset($_POST['reconn'])) {
-          $this->mungedObject->setShadow(isset($_POST['shadow']) && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite),$_POST['shadow']);
-        }
-
-        /* Check for changes */
-        if ($this->sambaMungedDial != $this->mungedObject->getMunged()){
-          $this->is_modified= TRUE;
-        }
+      /* Save checkbox states. */
+      $this->mungedObject->setTsLogin(!isset($_POST['tslogin'])
+                      && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
+      // Need to do some index checking to avoid messages like "index ... not found"
+      if(isset($_POST['brokenconn'])) {
+        $this->mungedObject->setBrokenConn($_POST['brokenconn'] == '1'
+                      && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
+      }
+      if(isset($_POST['reconn'])) {
+        $this->mungedObject->setReConn($_POST['reconn'] == '1'
+                      && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
+      }
+      $this->mungedObject->setInheritMode(isset($_POST['inherit'])
+                      && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
+      $this->mungedObject->setCtxMaxConnectionTimeF(!isset($_POST['CtxMaxConnectionTimeF'])
+                      && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
+      $this->mungedObject->setCtxMaxDisconnectionTimeF(
+                      !isset($_POST['CtxMaxDisconnectionTimeF']) 
+                      && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
+      $this->mungedObject->setCtxMaxIdleTimeF(!isset($_POST['CtxMaxIdleTimeF'])
+                      && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
+      $this->mungedObject->setConnectClientDrives(isset($_POST['connectclientdrives'])
+                      && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
+      $this->mungedObject->setConnectClientPrinters(isset($_POST['connectclientprinters'])  
+                      && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
+      $this->mungedObject->setDefaultPrinter(isset($_POST['defaultprinter'])
+                      && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
+
+      /* Save combo boxes. Takes two values */
+      if(isset($_POST['reconn'])) {
+        $this->mungedObject->setShadow(isset($_POST['shadow']) && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite),$_POST['shadow']);
+      }
+
+      /* Check for changes */
+      if ($this->sambaMungedDial != $this->mungedObject->getMunged()){
+        $this->is_modified= TRUE;
       }
+      
     }
   }
 
@@ -957,129 +1131,99 @@ class sambaAccount extends plugin
     $this->attrs['objectClass']= $tmp;
 
     /* Generate rid / primaryGroupId */
-    if ($this->samba3){
-      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);
-      } else {
-        $this->SID= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'];
-        $this->ridBase= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['RIDBASE'];
-      }
-
-      /* Need to generate a new uniqe uid/gid combination? */
-      if ($this->sambaSID == "" || $this->orig_sambaDomainName != $this->sambaDomainName){
-        $uidNumber= $this->uidNumber;
-        while(TRUE){
-          $sid= $this->SID."-".($uidNumber*2 + $this->ridBase);
-          $ldap->cd($this->config->current['BASE']);
-          $ldap->search("(sambaSID=$sid)", array("sambaSID"));
-          if ($ldap->count() == 0){
-            break;
-          }
-          $uidNumber++;
-        }
-        $this->attrs['sambaSID']= $sid;
+    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);
+    } else {
+      $this->SID= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'];
+      $this->ridBase= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['RIDBASE'];
+    }
 
-        /* Check for users primary group */
+    /* Need to generate a new uniqe uid/gid combination? */
+    if ($this->sambaSID == "" || $this->orig_sambaDomainName != $this->sambaDomainName){
+      $uidNumber= $this->uidNumber;
+      while(TRUE){
+        $sid= $this->SID."-".($uidNumber*2 + $this->ridBase);
         $ldap->cd($this->config->current['BASE']);
-        $ldap->search("(&(objectClass=posixGroup)(gidNumber=".$this->gidNumber."))", array("cn"));
-        if ($ldap->count() != 1){
-          msg_dialog::display(_("Warning"), _("Cannot convert primary group to samba group: group cannot be identified!"), WARNING_DIALOG);
-        } else {
-          $attrs= $ldap->fetch();
-          $g= new group($this->config, $ldap->getDN());
-          if ($g->sambaSID == ""){
-            $g->sambaDomainName= $this->sambaDomainName;
-            $g->smbgroup= TRUE;
-            $g->save ();
-          }
-          $this->attrs['sambaPrimaryGroupSID']= $g->sambaSID;
+        $ldap->search("(sambaSID=$sid)", array("sambaSID"));
+        if ($ldap->count() == 0){
+          break;
         }
+        $uidNumber++;
       }
+      $this->attrs['sambaSID']= $sid;
 
-      if ($this->sambaHomeDrive == ""){
-        $this->attrs["sambaHomeDrive"]= array();
+      /* Check for users primary group */
+      $ldap->cd($this->config->current['BASE']);
+      $ldap->search("(&(objectClass=posixGroup)(gidNumber=".$this->gidNumber."))", array("cn"));
+      if ($ldap->count() != 1){
+        msg_dialog::display(_("Warning"), _("Cannot convert primary group to samba group: group cannot be identified!"), WARNING_DIALOG);
+      } else {
+        $attrs= $ldap->fetch();
+        $g= new group($this->config, $ldap->getDN());
+        if ($g->sambaSID == ""){
+          $g->sambaDomainName= $this->sambaDomainName;
+          $g->smbgroup= TRUE;
+          $g->save ();
+        }
+        $this->attrs['sambaPrimaryGroupSID']= $g->sambaSID;
       }
+    }
 
-      /* Generate munged dial value */
-      $this->attrs["sambaMungedDial"]= $this->mungedObject->getMunged();
-
-      /* User wants me to fake the idMappings? This is useful for
-         making winbind resolve the user names in a reasonable amount
-         of time in combination with larger databases. */
-      if (isset($this->config->current['SAMBAIDMAPPING']) &&
-          preg_match('/true/i', $this->config->current['SAMBAIDMAPPING'])){
-        $this->attrs['objectClass'][]= "sambaIdmapEntry";
-      }
+    if ($this->sambaHomeDrive == ""){
+      $this->attrs["sambaHomeDrive"]= array();
+    }
 
+    /* Generate munged dial value */
+    $this->attrs["sambaMungedDial"]= $this->mungedObject->getMunged();
 
-      /* Password expiery */
-      if ($this->password_expires == "1"){
-        $this->attrs['sambaPwdMustChange']= $this->sambaPwdMustChange;
-      } 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;
-      } else {
-        $this->attrs['sambaLogonTime']= array();
-      }
-      if ($this->logoff_time_set == "1"){
-        $this->attrs['sambaLogoffTime']= $this->sambaLogoffTime;
-      } else {
-        $this->attrs['sambaLogoffTime']= array();
-      }
-      if ($this->kickoff_time_set == "1"){
-        # Add one day in unixtime format to be compatible with usrmgr
-        //$this->attrs['sambaKickoffTime']= $this->sambaKickoffTime + 86400; 
-        $this->attrs['sambaKickoffTime']= $this->sambaKickoffTime; //hickert 
-      } else {
-        $this->attrs['sambaKickoffTime']= array();
-      }
-    } else {
-    /* Not samba3 */
-      $this->attrs['rid']= $this->uidNumber*2 + 1000;
-      $this->attrs['primaryGroupID']= $this->gidNumber*2 +1001;
+    /* User wants me to fake the idMappings? This is useful for
+       making winbind resolve the user names in a reasonable amount
+       of time in combination with larger databases. */
+    if ($this->config->get_cfg_value("sambaidmapping") == "true"){
+      $this->attrs['objectClass'][]= "sambaIdmapEntry";
+    }
 
-      if ($this->homeDrive == ""){
-        $this->attrs["homeDrive"]= array();
-      }
 
-      /* Password expiery */
-      if ($this->password_expires == "1"){
-        $this->attrs['pwdMustChange']= $this->pwdMustChange;
-      } else {
-        $this->attrs['pwdMustChange']= 2147483647;
-      }
-      /* Make sure not to save zero in pwdLastset */
-      if ($this->pwdLastSet != "0"){
-        $this->attrs['pwdLastSet']= $this->pwdLastSet;
-      } else {
-        $this->attrs['pwdLastSet']= array();
-      }
-      /* Account expiery */
-      if ($this->logon_time_set == "1"){
-        $this->attrs['logonTime']= $this->logonTime;
-      } else {
-        $this->attrs['logonTime']= array();
-      }
-      if ($this->logoff_time_set == "1"){
-        $this->attrs['logoffTime']= $this->logoffTime;
+    /* Password expiery */
+    if ($this->password_expires == "1"){
+      #TODO: check for date format
+      if ($this->attrs['sambaPwdMustChange'] == ""){
+        $this->attrs['sambaPwdMustChange']= 0;
       } else {
-        $this->attrs['logoffTime']= array();
+        list($day, $month, $year)= explode('.', $this->sambaPwdMustChange);
+        $this->attrs['sambaPwdMustChange']= mktime(0,0,0,$month, $day, $year);
       }
-      if ($this->kickoff_time_set == "1"){
-        # Add one day in unixtime format to be compatible with usrmgr
-        $this->attrs['kickoffTime']= $this->kickoffTime + 86400;
+    } 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;
+    } else {
+      $this->attrs['sambaLogonTime']= array();
+    }
+    if ($this->logoff_time_set == "1"){
+      $this->attrs['sambaLogoffTime']= $this->sambaLogoffTime;
+    } else {
+      $this->attrs['sambaLogoffTime']= array();
+    }
+    if ($this->kickoff_time_set == "1"){
+      /* Adapt values to be timestamps */
+      #TODO: check for date format
+      if ($this->attrs['sambaKickoffTime'] == ""){
+        $this->attrs['sambaKickoffTime']= 2147483647;
       } else {
-        $this->attrs['kickoffTime']= array();
+        list($day, $month, $year)= explode('.', $this->sambaKickoffTime);
+        $this->attrs['sambaKickoffTime']= mktime(0,0,0,$month, $day, $year);
       }
+    } else {
+      $this->attrs['sambaKickoffTime']= array();
     }
 
     /* Write back to ldap */
@@ -1093,7 +1237,9 @@ class sambaAccount extends plugin
       new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
     }
 
-    show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/samba account with dn '%s' failed."),$this->dn));
+    if (!$ldap->success()){
+      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
+    }
 
     /* Optionally execute a command after we're done */
     if ($this->initially_was_account == $this->is_account){
@@ -1121,33 +1267,48 @@ class sambaAccount extends plugin
   }
 
 
-  function adapt_from_template($dn)
+  function adapt_from_template($dn, $skip= array())
   {
-    plugin::adapt_from_template($dn);
+    plugin::adapt_from_template($dn, $skip);
+
+
     $this->sambaSID= "";
     $this->sambaPrimaryGroupSID= "";
 
-      /* Fill mungedDial field */
-    if ($this->samba3 && isset($this->attrs['sambaMungedDial'])){
+    /* Fill mungedDial field */
+    if (isset($this->attrs['sambaMungedDial']) && !in_array('sambaMungedDial', $skip)){
       $this->mungedObject->load($this->sambaMungedDial);
     }
 
+    /* Adapt munged attributes */
+    foreach($this->ctxattributes as $attr){
+      if(isset($this->mungedObject->ctx[$attr]))
+        $val = $this->mungedObject->ctx[$attr];
+
+      foreach (array("sn", "givenName", "uid") as $repl){
+        if (preg_match("/%$repl/i", $val)){
+          $val= preg_replace ("/%$repl/i", $this->parent->$repl, $val);
+        }
+      }
+      $this->mungedObject->ctx[$attr] = $val;
+    }
+
     /* Password expiery */
     if(isset($this->attrs['sambaPwdMustChange']) &&
-        $this->attrs['sambaPwdMustChange'][0] != 0){
+        $this->attrs['sambaPwdMustChange'][0] != 0 && !in_array('sambaPwdMustChange', $skip)){
       $this->password_expires= 1;
     }
 
     if(isset($this->attrs['sambaLogonTime']) && ! (
         $this->attrs['sambaLogonTime'][0] == 0 ||
         $this->attrs['sambaLogonTime'][0] == 2147483647
-      )){
+      ) && !in_array('sambaLogonTime', $skip)){
       $this->logon_time_set= 1;
     }
     if(isset($this->attrs['sambaLogoffTime']) && ! (
         $this->attrs['sambaLogoffTime'][0] == 0 ||
         $this->attrs['sambaLogoffTime'][0] == 2147483647
-      )){
+      ) && !in_array('sambaLogonTime', $skip)){
       $this->logoff_time_set= 1;
     }
 
@@ -1155,7 +1316,7 @@ class sambaAccount extends plugin
     if(isset($this->attrs['sambaKickoffTime']) && ! (
         $this->attrs['sambaKickoffTime'][0] == 0 ||
         $this->attrs['sambaKickoffTime'][0] == 2147483647
-      )){
+      ) && !in_array('sambaKickoffTime', $skip)){
       $this->kickoff_time_set= 1;
     }
 
@@ -1182,38 +1343,31 @@ class sambaAccount extends plugin
           "plOptions"       => array(),
 
           "plProvidedAcls"  => array(
+
+            "sambaHomePath"               => _("Generic home directory") ,
+            "sambaHomeDrive"              => _("Generic samba home drive") ,
+            "sambaDomainName"             => _("Domain") ,
+            "sambaLogonScript"            => _("Generic script path") ,
+            "sambaProfilePath"            => _("Generic profile path") ,
             "AllowLoginOnTerminalServer"  => _("Allow login on terminal server"),
             "InheritClientConfig"         => _("Inherit client config"),
-
-            "sambaPwdCanChange"     => _("Allow user to change password") ,
-            "sambaAcctFlagsN"            => _("Login from windows client requires no password"),
-            "sambaAcctFlagsL"            => _("Lock samba account"),
-
-
-            "sambaKickoffTime"      => _("Account expires") ,
-            "sambaPwdMustChange"    => _("Password expires") ,
-
-            "sambaLogonTime"        => _("Limit Logon Time") ,
-            "sambaLogoffTime"       => _("Limit Logoff Time") ,
-            "sambaLogonHours"       => _("Logon hours") ,
-
-            "sambaHomePath"         => _("Generic home directory") ,
-            "sambaHomeDrive"        => _("Generic samba home drive") ,
-            "sambaLogonScript"      => _("Generic script path") ,
-            "sambaProfilePath"      => _("Generic profile path") ,
-            "sambaDomainName"       => _("Domain") ,
-            "sambaUserWorkstations" => _("Allow connection from")))
-              );
+            "sambaPwdCanChange"           => _("Allow user to change password") ,
+            "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") ,
+            "sambaLogonHours"             => _("Logon hours") ,
+            "sambaUserWorkstations"       => _("Allow connection from"))
+          ));
   }    
 
   function enable_multiple_support()
   {
     plugin::enable_multiple_support();
-    if($this->samba3){
-      $this->multiple_support_active = TRUE;
-    }else{
-      $this->multiple_support_active = FALSE;
-    }
+    $this->multiple_support_active = TRUE;
   } 
 
   function multiple_save_object()
@@ -1225,7 +1379,7 @@ class sambaAccount extends plugin
             "inherit","CtxWorkDirectory","CtxInitialProgram","CtxMaxConnectionTimeF","CtxMaxConnectionTime","CtxMaxDisconnectionTimeF",
             "CtxMaxDisconnectionTime","CtxMaxIdleTimeF","CtxMaxIdleTime","connectclientdrives",
             "onnectclientprinters","defaultprinter","shadow","brokenconn",
-            "reconn","allow_pwchange","connectclientprinters","no_password_required","temporary_disable",
+            "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){
         if(isset($_POST["use_".$attr])){
@@ -1244,7 +1398,7 @@ class sambaAccount extends plugin
     foreach (array( "sambaHomePath" => _("Home directory"),
           "sambaProfilePath" => _("Profile path")) as $key => $val){
       if (in_array($key,$this->multi_boxes) && !$this->mungedObject->is_samba_path($this->$key)){
-        $message[]= sprintf(_("The value specified as '%s' contains invalid characters!"), $val);
+        $message[]= msgPool::invalid($val);
       }
     }
 
@@ -1255,7 +1409,7 @@ class sambaAccount extends plugin
       if (in_array($key,$this->multi_boxes) && 
           isset($this->mungedObject->ctx[$key]) && 
           !tests::is_id($this->mungedObject->ctx[$key]) && $val != 0){
-        $message[]= sprintf(_("The timeout property '%s' is checked and contains invalid or no characters!"), $val);
+        $message[]=msgPool::invalid($val);
       }
     }
 
@@ -1276,7 +1430,7 @@ class sambaAccount extends plugin
      *  Those workstations will be displayed in light grey.
      */
     $tmp2 = array("count" => 0);
-    $tmp = split(",", $this->sambaUserWorkstations);
+    $tmp = explode(",", $this->sambaUserWorkstations);
     foreach($tmp as $station){
       $station = trim($station);
       if(!empty($station)){
@@ -1387,7 +1541,6 @@ class sambaAccount extends plugin
     /* Flags */
     if(in_array("allow_pwchange",$this->multi_boxes)){
       $ret['sambaPwdCanChange'] = $this->sambaPwdCanChange;
-      $ret['pwdCanChange']      = $this->pwdCanChange;
     }
   
     if(in_array("password_expires",$this->multi_boxes)){
@@ -1411,6 +1564,10 @@ class sambaAccount extends plugin
       $ret['no_password_required'] = $this->no_password_required;
     }
 
+    if(in_array("no_expiry",$this->multi_boxes)){
+      $ret['no_expiry'] = $this->no_expiry;
+    }
+
     if(in_array("temporary_disable",$this->multi_boxes)){
       $ret['temporary_disable'] = $this->temporary_disable;
     }
@@ -1438,7 +1595,7 @@ class sambaAccount extends plugin
 
       /* Prepare current settings to be merged */
       if(isset($this->sambaUserWorkstations)){
-        $ttmp = split(",",$this->sambaUserWorkstations);
+        $ttmp = explode(",",$this->sambaUserWorkstations);
         foreach($ttmp as $station){
           $station = trim($station);
           if(!empty($station)){
@@ -1497,7 +1654,6 @@ class sambaAccount extends plugin
 
   
     if(isset($values['sambaPwdCanChange']))  $this->sambaPwdCanChange  = $values['sambaPwdCanChange'];
-    if(isset($values['pwdCanChange']))       $this->pwdCanChange       = $values['pwdCanChange'];
 
     
     
@@ -1529,6 +1685,16 @@ class sambaAccount extends plugin
       }
     }      
 
+    if(isset($values['no_expiry'])){
+      if($values['no_expiry']){
+        if(!preg_match("/N/",$this->sambaAcctFlags)) {
+          $this->sambaAcctFlags = preg_replace("/ /","N",$this->sambaAcctFlags,1);
+        }
+      }else{
+        $this->sambaAcctFlags = preg_replace("/N/"," ",$this->sambaAcctFlags,1);
+      }
+    }      
+
     if(isset($values['temporary_disable'])){
       if($values['temporary_disable']){
         if(preg_match("/L/",$this->sambaAcctFlags)) {
@@ -1549,7 +1715,6 @@ class sambaAccount extends plugin
 
     /* Set a new SID */
     $this->sambaSID = "";
-    print "Eloha : ".($this->gidNumber);
   }
 
 }