From 55acc04483264d9f2c33f7f0f1dda15afcc1f244 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 26 Jul 2014 12:44:32 +0000 Subject: [PATCH] always set sAMAccountName --- lam/lib/modules/windowsUser.inc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lam/lib/modules/windowsUser.inc b/lam/lib/modules/windowsUser.inc index 96f8fdfc..16d17281 100644 --- a/lam/lib/modules/windowsUser.inc +++ b/lam/lib/modules/windowsUser.inc @@ -765,7 +765,7 @@ class windowsUser extends baseModule implements passwordService { } $containerLeft->addElement(new htmlTableExtendedSelect('homeDrive', $drives, $selected, _('Home drive'), 'homeDrive'), true); // home directory - $this->addSimpleInputTextField($containerLeft, 'homeDirectory', _('Home directory'), true); + $this->addSimpleInputTextField($containerLeft, 'homeDirectory', _('Home directory')); // NIS attributes if (!$this->isBooleanConfigOptionSet('windowsUser_hidemsSFU30Name', true) || !$this->isBooleanConfigOptionSet('windowsUser_hidemsSFU30NisDomain', true)) { @@ -854,6 +854,10 @@ class windowsUser extends baseModule implements passwordService { $return[] = $this->messages['sAMAccountName'][0]; } } + elseif ($this->getAccountContainer()->isNewAccount && !empty($_POST['userPrincipalName'])) { + // set sAMAccountName to user name if attribute input field is not visible (W2012 requires this attribute) + $this->attributes['sAMAccountName'][0] = $_POST['userPrincipalName']; + } // description $this->attributes['description'][0] = $_POST['description']; // display name @@ -1253,6 +1257,10 @@ class windowsUser extends baseModule implements passwordService { $partialAccounts[$i]['sAMAccountName'] = $samUser[0]; } } + else { + // set sAMAccountName to user name if not managed (W2012 requires it) + $partialAccounts[$i]['sAMAccountName'] = $replacements['$user']; + } // password if (($rawAccounts[$i][$ids['windowsUser_password']] != "") && (get_preg($rawAccounts[$i][$ids['windowsUser_password']], 'password'))) { $partialAccounts[$i]['unicodePwd'] = self::pwdAttributeValue($rawAccounts[$i][$ids['windowsUser_password']]);