From 92cdeeea2144ac6fdca2d9310d8627f2da577bc3 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 13 Jan 2009 08:57:33 +0000 Subject: [PATCH] Updated samba tab -Added first samba Info version. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13342 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../personal/samba/class_sambaAccount.inc | 148 ++++++++++++++++++ gosa-plugins/samba/personal/samba/samba3.tpl | 17 ++ 2 files changed, 165 insertions(+) diff --git a/gosa-plugins/samba/personal/samba/class_sambaAccount.inc b/gosa-plugins/samba/personal/samba/class_sambaAccount.inc index 9b32cd88b..919d4581f 100644 --- a/gosa-plugins/samba/personal/samba/class_sambaAccount.inc +++ b/gosa-plugins/samba/personal/samba/class_sambaAccount.inc @@ -30,6 +30,9 @@ class sambaAccount extends plugin var $uidNumber= 65535; var $gidNumber= 65535; + /* Samba 3 infos */ + var $display_informations = FALSE; + /* Samba 2 attributes */ var $pwdLastSet= "0"; var $logonTime= "0"; @@ -691,6 +694,13 @@ class sambaAccount extends plugin /* Show main page */ $smarty->assign("multiple_support",$this->multiple_support_active); if ($this->samba3){ + + $smarty->assign("samba_informations",""); + $smarty->assign("display_informations",$this->display_informations); + if($this->display_informations){ + $smarty->assign("samba_informations",$this->get_samba_informations()); + } + $display.= $smarty->fetch (get_template_path('samba3.tpl', TRUE, dirname(__FILE__))); } else { $display.= $smarty->fetch (get_template_path('samba2.tpl', TRUE, dirname(__FILE__))); @@ -699,6 +709,140 @@ class sambaAccount extends plugin return ($display); } + + function get_samba_informations() + { + + /* Defaults + */ + $sambaMinPwdLength = "unset"; + $sambaPwdHistoryLength = "unset"; + $sambaLogonToChgPwd = "unset"; + $sambaMaxPwdAge = "unset"; + $sambaMinPwdAge = "unset"; + $sambaLockoutDuration = "unset"; + $sambaBadPasswordTime = "unset"; + $sambaLockoutThreshold = "unset"; + $sambaForceLogoff = "unset"; + $sambaRefuseMachinePwdChange = "unset"; + + + /* 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])){ + $cfg = $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]; + $ldap->search("(&(objectClass=sambaDomain)(sambaSID=".$cfg['SID']."))",array("*")); + if($ldap->count() >= 1){ + $attrs = $ldap->fetch(); + $attributes = array("sambaMinPwdLength","sambaPwdHistoryLength","sambaMaxPwdAge","sambaMinPwdAge","sambaLockoutDuration","sambaRefuseMachinePwdChange","sambaLogonToChgPwd","sambaBadPasswordTime","sambaLockoutThreshold","sambaForceLogoff"); + foreach($attributes as $attr){ + if(isset($this->$attr) && $this->$attr != ""){ + $$attr = $this->$attr; + }elseif(isset($this->attrs[$attr])){ + $$attr = $this->attrs[$attr][0]; + }elseif(isset($attrs[$attr])){ + $$attr = $attrs[$attr][0]; + } + } + } + } + + /* Password length has a default of 5 + */ + if($sambaMinPwdLength == "unset" || $sambaMinPwdLength == 5){ + $sambaMinPwdLength = "5 ("._("default").")"; + } + + /* Length of Password History Entries (default: 0 => off) + */ + if($sambaPwdHistoryLength == "unset" || $sambaPwdHistoryLength == 0){ + $sambaPwdHistoryLength = _("Off")." ("._("default").")"; + } + + /* Force Users to logon for password change (default: 0 => off, 2 => on) + */ + if($sambaLogonToChgPwd == "unset" || $sambaLogonToChgPwd == 0){ + $sambaLogonToChgPwd = _("Off")." ("._("default").")"; + }else{ + $sambaLogonToChgPwd = _("On"); + } + + /* Maximum password age, in seconds (default: -1 => never expire passwords)' + */ + if($sambaMaxPwdAge == "unset" || $sambaMaxPwdAge == "-1"){ + $sambaMaxPwdAge = _("disabled")." ("._("default").")"; + }else{ + $sambaMaxPwdAge .= " "._("seconds"); + } + + /* Minimum password age, in seconds (default: 0 => allow immediate password change + */ + if($sambaMinPwdAge == "unset" || $sambaMinPwdAge == 0){ + $sambaMinPwdAge = _("disabled")." ("._("default").")"; + }else{ + $sambaMinPwdAge .= " "._("seconds"); + } + + /* Lockout duration in minutes (default: 30, -1 => forever) + */ + if($sambaLockoutDuration == "unset" || $sambaLockoutDuration == 30){ + $sambaLockoutDuration = "30 "._("minutes")." ("._("default").")"; + }elseif($sambaLockoutDuration == -1){ + $sambaLockoutDuration = _("forever"); + }else{ + $sambaLockoutDuration .= _("minutes"); + } + + /* Time of the last bad password attempt + */ + if($sambaBadPasswordTime == "none" || empty($sambaBadPasswordTime)){ + $sambaBadPasswordTime = "("._("unset").")"; + }else{ + $sambaBadPasswordTime = date("d.m.Y H:i:s",$sambaBadPasswordTime); + } + + /* Lockout users after bad logon attempts (default: 0 => off + */ + if($sambaLockoutThreshold == "unset" || $sambaLockoutThreshold == 0){ + $sambaLockoutThreshold = _("disabled")." ("._("default").")"; + } + + /* Disconnect Users outside logon hours (default: -1 => off, 0 => on + */ + if($sambaForceLogoff == "unset" || $sambaForceLogoff == -1){ + $sambaForceLogoff = _("off")." ("._("default").")"; + }else{ + $sambaForceLogoff = _("on"); + } + + /* Allow Machine Password changes (default: 0 => off + */ + if($sambaRefuseMachinePwdChange == "none" || $sambaRefuseMachinePwdChange == 0){ + $sambaRefuseMachinePwdChange = _("off")." ("._("default").")"; + }else{ + $sambaRefuseMachinePwdChange = _("on"); + } + + + $str = + "\n". + "\n". + "\n". + "\n". + "\n". + "\n". + "\n". + "\n". + "\n". + "\n". + "\n". + "\n
"._("Min password length").": ".$sambaMinPwdLength."
"._("Password history").": ".$sambaPwdHistoryLength."
"._("Force password change").": ".$sambaLogonToChgPwd."
"._("Maximum password age").": ".$sambaMaxPwdAge."
"._("Minimum password age").": ".$sambaMinPwdAge."
"._("Lockout duration").": ".$sambaLockoutDuration."
"._("Reset count minutes").": ".$sambaBadPasswordTime."
"._("Bad lockout attempt").": ".$sambaLockoutThreshold."
"._("Disconnect time").": ".$sambaForceLogoff."
"._("Refuse machine password change").":".$sambaRefuseMachinePwdChange."
"; + return($str); + } + + function remove_from_parent() { /* Cancel if there's nothing to do here */ @@ -796,6 +940,10 @@ class sambaAccount extends plugin if (isset($_POST['sambaTab'])){ plugin::save_object(); + if(isset($_POST['display_informations'])){ + $this->display_informations = !$this->display_informations; + } + /* Take care about access options */ if ($this->acl_is_writeable("sambaAcctFlagsL",$SkipWrite) || ($this->acl_is_writeable("sambaAcctFlagsN",$SkipWrite))){ if ($this->samba3){ diff --git a/gosa-plugins/samba/personal/samba/samba3.tpl b/gosa-plugins/samba/personal/samba/samba3.tpl index aecc65815..2ae4d66e2 100644 --- a/gosa-plugins/samba/personal/samba/samba3.tpl +++ b/gosa-plugins/samba/personal/samba/samba3.tpl @@ -32,6 +32,23 @@ {/render} + + {t}Informations{/t} + + {if $display_informations} + + {else} + + {/if} + + + + + {if $display_informations} + {$samba_informations} + {/if} + + -- 2.30.2