Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberroland committed Nov 7, 2023
1 parent da1ab3a commit 5dd4523
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 26 deletions.
16 changes: 7 additions & 9 deletions lam/lib/modules/posixAccount.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')) {
Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -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];
}
Expand Down
10 changes: 4 additions & 6 deletions lam/lib/modules/posixGroup.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down Expand Up @@ -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] != '')) {
Expand All @@ -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] != '')) {
Expand Down
17 changes: 6 additions & 11 deletions lam/lib/modules/windowsUser.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 5dd4523

Please sign in to comment.