From 5dd452350eb91aa82cb9ccac71bbb684ca3cd4d0 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 7 Nov 2023 20:55:02 +0100 Subject: [PATCH] refactoring --- lam/lib/modules/posixAccount.inc | 16 +++++++--------- lam/lib/modules/posixGroup.inc | 10 ++++------ lam/lib/modules/windowsUser.inc | 17 ++++++----------- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index 1562a2595..f2ff9fafc 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -1223,7 +1223,7 @@ class posixAccount extends baseModule implements passwordService,AccountStatusPr $maxID = intval($this->moduleSettings['posixAccount_' . $typeId . '_maxMachine'][0]); } $uids = $this->getUIDs($typeId); - if ($this->attributes['uidNumber'][0]=='') { + if ($this->attributes['uidNumber'][0] == '') { // No id-number given if (!isset($this->orig['uidNumber'][0]) || ($this->orig['uidNumber'][0] == '')) { // new account -> we have to find a free id-number @@ -3177,17 +3177,17 @@ class posixAccount extends baseModule implements passwordService,AccountStatusPr function getNextUIDs($count, &$errors, $typeId) { // check if UIDs should be taken from Samba pool entry if (($this->get_scope() == 'user') && isset($this->moduleSettings['posixAccount_' . $typeId . '_uidGeneratorUsers']) && ($this->moduleSettings['posixAccount_' . $typeId . '_uidGeneratorUsers'][0] == 'sambaPool')) { - return $this->getNextSambaPoolUIDs($count, $errors, $typeId); + return $this->getNextSambaPoolUIDs($count, $typeId); } if (($this->get_scope() == 'host') && isset($this->moduleSettings['posixAccount_' . $typeId . '_uidGeneratorHosts']) && ($this->moduleSettings['posixAccount_' . $typeId . '_uidGeneratorHosts'][0] == 'sambaPool')) { - return $this->getNextSambaPoolUIDs($count, $errors, $typeId); + return $this->getNextSambaPoolUIDs($count, $typeId); } // check if UIDs should be taken from domain info pool entry if (($this->get_scope() == 'user') && isset($this->moduleSettings['posixAccount_' . $typeId . '_uidGeneratorUsers']) && ($this->moduleSettings['posixAccount_' . $typeId . '_uidGeneratorUsers'][0] == 'windowsDomain')) { - return $this->getNextDomainInfoUIDs($count, $errors, $typeId); + return $this->getNextDomainInfoUIDs($count, $typeId); } if (($this->get_scope() == 'host') && isset($this->moduleSettings['posixAccount_' . $typeId . '_uidGeneratorHosts']) && ($this->moduleSettings['posixAccount_' . $typeId . '_uidGeneratorHosts'][0] == 'windowsDomain')) { - return $this->getNextDomainInfoUIDs($count, $errors, $typeId); + return $this->getNextDomainInfoUIDs($count, $typeId); } // check if a magic number should be used if (($this->get_scope() == 'user') && isset($this->moduleSettings['posixAccount_' . $typeId . '_uidGeneratorUsers']) && ($this->moduleSettings['posixAccount_' . $typeId . '_uidGeneratorUsers'][0] == 'magicNumber')) { @@ -3260,11 +3260,10 @@ class posixAccount extends baseModule implements passwordService,AccountStatusPr * Gets the free UID numbers from an Samba pool entry in LDAP. * * @param integer $count number of needed free UIDs. - * @param array $errors list of error messages where errors can be added * @param string $typeId type id (e.g. user) * @return mixed null if no UIDs are free else an array of free UIDs */ - private function getNextSambaPoolUIDs($count, &$errors, $typeId) { + private function getNextSambaPoolUIDs($count, $typeId) { if ($this->get_scope() == 'user') { $dn = $this->moduleSettings['posixAccount_' . $typeId . '_sambaIDPoolDNUsers'][0]; } @@ -3294,11 +3293,10 @@ class posixAccount extends baseModule implements passwordService,AccountStatusPr * Gets the free UID numbers from a domain info entry in LDAP. * * @param integer $count number of needed free UIDs. - * @param array $errors list of error messages where errors can be added * @param string $typeId type id (e.g. user) * @return mixed null if no UIDs are free else an array of free UIDs */ - private function getNextDomainInfoUIDs($count, &$errors, $typeId) { + private function getNextDomainInfoUIDs($count, $typeId) { if ($this->get_scope() == 'user') { $dn = $this->moduleSettings['posixAccount_' . $typeId . '_windowsIDPoolDNUsers'][0]; } diff --git a/lam/lib/modules/posixGroup.inc b/lam/lib/modules/posixGroup.inc index a5f7dc8a2..e0d0d22b3 100644 --- a/lam/lib/modules/posixGroup.inc +++ b/lam/lib/modules/posixGroup.inc @@ -1131,11 +1131,11 @@ class posixGroup extends baseModule implements passwordService { $typeId = $type->getId(); // check if UIDs should be taken from Samba pool entry if (isset($this->moduleSettings['posixGroup_' . $typeId . '_gidGenerator']) && ($this->moduleSettings['posixGroup_' . $typeId . '_gidGenerator'][0] == 'sambaPool')) { - return $this->getNextSambaPoolGIDs($count, $errors, $typeId); + return $this->getNextSambaPoolGIDs($count, $typeId); } // check if UIDs should be taken from domain info entry if (isset($this->moduleSettings['posixGroup_' . $typeId . '_gidGenerator']) && ($this->moduleSettings['posixGroup_' . $typeId . '_gidGenerator'][0] == 'windowsDomain')) { - return $this->getNextDomainInfoGIDs($count, $errors, $typeId); + return $this->getNextDomainInfoGIDs($count, $typeId); } // use magic number if (isset($this->moduleSettings['posixGroup_' . $typeId . '_gidGenerator']) && ($this->moduleSettings['posixGroup_' . $typeId . '_gidGenerator'][0] == 'magicNumber')) { @@ -1201,11 +1201,10 @@ class posixGroup extends baseModule implements passwordService { * Gets the free GID numbers from an Samba pool entry in LDAP. * * @param integer $count number of needed free GIDs. - * @param array $errors list of error messages where errors can be added * @param string $typeId account type id * @return mixed null if no GIDs are free else an array of free GIDs */ - private function getNextSambaPoolGIDs($count, &$errors, $typeId) { + private function getNextSambaPoolGIDs($count, $typeId) { $dn = $this->moduleSettings['posixGroup_' . $typeId . '_sambaIDPoolDN'][0]; $attrs = ldapGetDN($dn, array('gidNumber')); if (isset($attrs['gidnumber'][0]) && ($attrs['gidnumber'][0] != '')) { @@ -1230,11 +1229,10 @@ class posixGroup extends baseModule implements passwordService { * Gets the free GID numbers from an Windows domain info entry in LDAP. * * @param integer $count number of needed free GIDs. - * @param array $errors list of error messages where errors can be added * @param string $typeId account type id * @return mixed null if no GIDs are free else an array of free GIDs */ - private function getNextDomainInfoGIDs($count, &$errors, $typeId) { + private function getNextDomainInfoGIDs($count, $typeId) { $dn = $this->moduleSettings['posixGroup_' . $typeId . '_windowsIDPoolDN'][0]; $attrs = ldapGetDN($dn, array('msSFU30MaxGidNumber')); if (isset($attrs['mssfu30maxgidnumber'][0]) && ($attrs['mssfu30maxgidnumber'][0] != '')) { diff --git a/lam/lib/modules/windowsUser.inc b/lam/lib/modules/windowsUser.inc index 021d923e7..3eb951009 100644 --- a/lam/lib/modules/windowsUser.inc +++ b/lam/lib/modules/windowsUser.inc @@ -3559,7 +3559,7 @@ class windowsUser extends baseModule implements passwordService,AccountStatusPro } $pwdPolicyResult = checkPasswordStrength($_POST['windowsUser_unicodePwd'], $userName, $additionalAttrs); if ($pwdPolicyResult === true) { - $this->setSelfServicePassword($return, $attributes); + $this->setSelfServicePassword($return); $return['info']['userPasswordClearText'][0] = $_POST['windowsUser_unicodePwd']; } else { @@ -3594,9 +3594,8 @@ class windowsUser extends baseModule implements passwordService,AccountStatusPro * * Enter description here ... * @param array $return return value for checkSelfServiceOptions() (used to add message if any) - * @param array $attributes LDAP attributes */ - private function setSelfServicePassword(&$return, $attributes) { + private function setSelfServicePassword(&$return) { $newPasswordVal = self::pwdAttributeValue($_POST['windowsUser_unicodePwd']); $oldPassword = lamDecrypt($_SESSION['selfService_clientPassword'], 'SelfService'); $oldPasswordVal = self::pwdAttributeValue($oldPassword); @@ -3940,10 +3939,8 @@ class windowsUser extends baseModule implements passwordService,AccountStatusPro $typeManager = new TypeManager(); $typesUser = $typeManager->getConfiguredTypesForScope('user'); $suffixes = array(); - if (!empty($typesUser)) { - foreach ($typesUser as $type) { - $suffixes[] = $type->getSuffix(); - } + foreach ($typesUser as $type) { + $suffixes[] = $type->getSuffix(); } $suffixes = array_unique($suffixes); foreach ($suffixes as $suffix) { @@ -3970,10 +3967,8 @@ class windowsUser extends baseModule implements passwordService,AccountStatusPro $typeManager = new TypeManager(); $typesUser = $typeManager->getConfiguredTypesForScope('user'); $suffixes = array(); - if (!empty($typesUser)) { - foreach ($typesUser as $type) { - $suffixes[] = $type->getSuffix(); - } + foreach ($typesUser as $type) { + $suffixes[] = $type->getSuffix(); } $suffixes = array_unique($suffixes); foreach ($suffixes as $suffix) {