From fcfbdec26ae99662dde10845854a8a12e85ec7c6 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 13 Oct 2005 16:03:51 +0000 Subject: [PATCH] loading of domain setting from profile did not work --- lam/HISTORY | 1 + lam/lib/modules/sambaSamAccount.inc | 38 ++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/lam/HISTORY b/lam/HISTORY index 6bf98cd8..6890e460 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -6,6 +6,7 @@ -> inetOrgPerson: fixed mobile number -> Samba 2/3: passwords fixed for file uploads (1311561) -> Samba 3: fixed logon hours (patch 1311915) + -> Samba 3: loading of domain setting from profile did not work -> Quota: profile settings fixed diff --git a/lam/lib/modules/sambaSamAccount.inc b/lam/lib/modules/sambaSamAccount.inc index 2327ac9f..ab175e95 100644 --- a/lam/lib/modules/sambaSamAccount.inc +++ b/lam/lib/modules/sambaSamAccount.inc @@ -746,13 +746,22 @@ class sambaSamAccount extends baseModule { StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), ''); return; } - if ($this->attributes['sambaSID'][0]!='') + if ($this->attributes['sambaSID'][0]!='') { $domainSID = substr($this->attributes['sambaSID'][0], 0, strrpos($this->attributes['sambaSID'][0], "-")); + } for ($i=0; $iname; - if ($domainSID == $sambaDomains[$i]->SID) { - $SID = $domainSID; - $sel_domain = $sambaDomains[$i]->name; + if (isset($domainSID)) { + if ($domainSID == $sambaDomains[$i]->SID) { + $SID = $domainSID; + $sel_domain = $sambaDomains[$i]->name; + } + } + elseif ($this->attributes['sambaDomainName'][0]!='') { + if ($this->attributes['sambaDomainName'][0] == $sambaDomains[$i]->name) { + $SID = $domainSID; + $sel_domain = $sambaDomains[$i]->name; + } } } $canchangedate = getdate($this->attributes['sambaPwdCanChange'][0]); @@ -1149,6 +1158,27 @@ class sambaSamAccount extends baseModule { $profile['sambaSamAccount_expire_day'][0], $profile['sambaSamAccount_expire_yea'][0]); $this->attributes['sambaKickoffTime'][0] = $date; } + // domain -> change SID + if ($this->attributes['sambaSID'][0]) { + if (isset($profile['sambaSamAccount_sambaDomainName'][0]) && ($profile['sambaSamAccount_sambaDomainName'][0] != "")) { + $domains = search_domains($_SESSION['config']->get_Suffix('domain')); + $domSID = ''; + // find domain SID + for ($i = 0; $i < sizeof($domains); $i++) { + if ($domains[$i]->name == $profile['sambaSamAccount_sambaDomainName'][0]) { + $domSID = $domains[$i]->SID; + break; + } + } + // replace domain part of SID + if ($domSID != '') { + $SID = $this->attributes['sambaSID'][0]; + $rid = substr($SID, strrpos($SID, '-') + 1); + $SID = $domSID . '-' . $rid; + $this->attributes['sambaSID'][0] = $SID; + } + } + } } /**