From b70b319b6240f80265b447f11016601c861e56e6 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 15 Jan 2008 18:50:40 +0000 Subject: [PATCH] fixed domain changing --- lam/lib/modules/sambaSamAccount.inc | 32 ++++++++--------------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/lam/lib/modules/sambaSamAccount.inc b/lam/lib/modules/sambaSamAccount.inc index 07fc2001..0e6fb920 100644 --- a/lam/lib/modules/sambaSamAccount.inc +++ b/lam/lib/modules/sambaSamAccount.inc @@ -571,27 +571,7 @@ class sambaSamAccount extends baseModule { if (!in_array('sambaSamAccount', $this->attributes['objectClass'])) { return array(); } - /* Create sambaSID. Can't create it while loading attributes because - * it's psssible uidNumber has changed - */ - // Get Domain SID from name - $sambaDomains = search_domains(); - for ($i=0; $iattributes['sambaDomainName'][0] == $sambaDomains[$i]->name) { - $SID = $sambaDomains[$i]->SID; - $RIDbase = $sambaDomains[$i]->RIDbase; - } - } - $special = false; - if ($this->attributes['sambaSID'][0] == $SID."-500") $special = true; - if ($this->attributes['sambaSID'][0] == $SID."-501") $special = true; - if (!$special) { - $attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes(); - $this->attributes['sambaSID'][0] = $SID."-".($attrs['uidNumber'][0]*2+$RIDbase); - } - $return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig); - return $return; } @@ -613,11 +593,13 @@ class sambaSamAccount extends baseModule { // Save attributes $this->attributes['sambaDomainName'][0] = $_POST['sambaDomainName']; // Get Domain SID from name - for ($i=0; $iattributes['sambaDomainName'][0] == $sambaDomains[$i]->name) { $SID = $sambaDomains[$i]->SID; $RIDbase = $sambaDomains[$i]->RIDbase; - } + break; + } + } $flag = "["; if (isset($_POST['sambaAcctFlagsD'])) { $flag .= "D"; @@ -731,8 +713,10 @@ class sambaSamAccount extends baseModule { // standard RID else if ($_POST['sambaSID'] == "-") { $rid = substr($this->attributes['sambaSID'][0], strrpos($this->attributes['sambaSID'][0], '-') + 1, strlen($this->attributes['sambaSID'][0])); - // change only if not yet set or previously set to special SID - if (!$this->attributes['sambaSID'][0] || in_array($rid, $this->rids)) { + // change only if not yet set, previously set to special SID or domain changed + if (!isset($this->attributes['sambaSID'][0]) + || in_array($rid, $this->rids) + || (strpos($this->attributes['sambaSID'][0], $SID) === false)) { $attrs = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes(); $this->attributes['sambaSID'][0] = $SID."-". (($attrs['uidNumber'][0]*2)+$RIDbase); }