From 855c05d39859ca96d3fc48a1a92797bc2bd800a0 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 2 Nov 2023 17:30:27 +0100 Subject: [PATCH] refactoring --- lam/lib/modules/asteriskExtension.inc | 8 +- lam/lib/modules/courierMailAlias.inc | 2 +- lam/lib/modules/ddns.inc | 6 +- lam/lib/modules/fixed_ip.inc | 6 +- lam/lib/modules/freeRadius.inc | 12 +- lam/lib/modules/imapAccess.inc | 10 +- lam/lib/modules/inetOrgPerson.inc | 22 ++-- lam/lib/modules/kolabGroup.inc | 2 +- lam/lib/modules/ldapPublicKey.inc | 1 - lam/lib/modules/nisMailAlias.inc | 7 +- lam/lib/modules/nisMailAliasUser.inc | 14 +-- lam/lib/modules/nisNetGroupUser.inc | 7 +- lam/lib/modules/nisnetgroup.inc | 9 +- lam/lib/modules/posixAccount.inc | 109 +++--------------- .../sambaSamAccount/sambaMungedDial.inc | 3 - 15 files changed, 56 insertions(+), 162 deletions(-) diff --git a/lam/lib/modules/asteriskExtension.inc b/lam/lib/modules/asteriskExtension.inc index 1b818bb1d..5b8921a00 100644 --- a/lam/lib/modules/asteriskExtension.inc +++ b/lam/lib/modules/asteriskExtension.inc @@ -8,7 +8,7 @@ use LAM\TYPES\ConfiguredType; This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam) Copyright (C) 2009 - 2012 Pavel Pozdniak - 2009 - 2022 Roland Gruber + 2009 - 2023 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -834,11 +834,10 @@ class asteriskExtension extends baseModule { $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskExtension_AstExtension', 'AstExtension'); $extensionName = $partialAccounts[$i]['AstExtension']; - $astPriorityTmp = 0; - if(isset ($extensionNamePriorityMap[$extensionName])){ + if (isset($extensionNamePriorityMap[$extensionName])){ $astPriorityTmp = $extensionNamePriorityMap[$extensionName] + 1; $extensionNamePriorityMap[$extensionName] = $astPriorityTmp; - }else{ + } else { $astPriorityTmp = 1; $extensionNamePriorityMap[$extensionName] = $astPriorityTmp; } @@ -870,7 +869,6 @@ class asteriskExtension extends baseModule { if ($this->isMoveToNewSuffix()) { $oldDN = "cn=" . $rowOrig["cn"][0] . "," . extractDNSuffix($this->getAccountContainer()->dn_orig); $newRDN = "cn=" . $rowOrig["cn"][0]; - $is_rename_success = false; $is_rename_success = @ldap_rename($_SESSION['ldap']->server(), $oldDN, $newRDN, $this->getAccountContainer()->dnSuffix, true); if (!$is_rename_success) { $errors[] = array('ERROR', sprintf(_('Was unable to rename DN: %s.'), $this->getAccountContainer()->dn_orig), getDefaultLDAPErrorString($_SESSION['ldap']->server())); diff --git a/lam/lib/modules/courierMailAlias.inc b/lam/lib/modules/courierMailAlias.inc index 4b1b5d8dd..e1a8a0d1c 100644 --- a/lam/lib/modules/courierMailAlias.inc +++ b/lam/lib/modules/courierMailAlias.inc @@ -2,7 +2,7 @@ /* * This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) * Copyright (C) 2017 Lars Althof - * 2017 - 2022 Roland Gruber + * 2017 - 2023 Roland Gruber * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/lam/lib/modules/ddns.inc b/lam/lib/modules/ddns.inc index 1cd7115fa..6c9d23fb9 100644 --- a/lam/lib/modules/ddns.inc +++ b/lam/lib/modules/ddns.inc @@ -3,7 +3,7 @@ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2008 Thomas Manninger - 2008 - 2022 Roland Gruber + 2008 - 2023 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -234,8 +234,6 @@ class ddns extends baseModule { * @return array list of info/error messages */ public function process_attributes() { - $errors = array(); - // Main Settings and Account have to different processes. if ($this->isRootNode()) { // main settings: @@ -246,10 +244,8 @@ class ddns extends baseModule { if (!$this->check_if_ddns_is_enable()) { return array(); } - $errors = $this->process_attributes_account(); } - return $errors; } diff --git a/lam/lib/modules/fixed_ip.inc b/lam/lib/modules/fixed_ip.inc index 2a289102e..e6ddedb27 100644 --- a/lam/lib/modules/fixed_ip.inc +++ b/lam/lib/modules/fixed_ip.inc @@ -8,7 +8,7 @@ use LAM\TYPES\ConfiguredType; This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2008 Thomas Manninger - 2008 - 2022 Roland Gruber + 2008 - 2023 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -60,10 +60,10 @@ class fixed_ip extends baseModule { public $attributes; /** cached host entries (list of array('cn' => ..., 'iphostnumber' => ..., 'macaddress' => ...)) */ - private $hostCache = null; + private $hostCache; /** cache for existing host entries */ - private $existingDhcpHostsCache = null; + private $existingDhcpHostsCache; /** * Returns true if this module can manage accounts of the current type, otherwise false. diff --git a/lam/lib/modules/freeRadius.inc b/lam/lib/modules/freeRadius.inc index e1f8c0bb2..ce061be64 100644 --- a/lam/lib/modules/freeRadius.inc +++ b/lam/lib/modules/freeRadius.inc @@ -46,7 +46,7 @@ class freeRadius extends baseModule { ); /** cache for profile DNs */ - private $profileCache = null; + private $profileCache; /** @@ -187,13 +187,11 @@ class freeRadius extends baseModule { $profileElements[] = $profileSelect; $return['profile_mappings']['freeRadius_radiusProfileDn'] = 'radiusProfileDn'; } - if (sizeof($profileElements) > 0) { - $profileContainer = new htmlResponsiveRow(); - for ($i = 0; $i < sizeof($profileElements); $i++) { - $profileContainer->add($profileElements[$i], 12); - } - $return['profile_options'] = $profileContainer; + $profileContainer = new htmlResponsiveRow(); + for ($i = 0; $i < sizeof($profileElements); $i++) { + $profileContainer->add($profileElements[$i], 12); } + $return['profile_options'] = $profileContainer; // upload fields $return['upload_columns'] = array(); if (!$this->isBooleanConfigOptionSet('freeRadius_hideRadiusRealm')) { diff --git a/lam/lib/modules/imapAccess.inc b/lam/lib/modules/imapAccess.inc index 53a9314d7..390c3f308 100644 --- a/lam/lib/modules/imapAccess.inc +++ b/lam/lib/modules/imapAccess.inc @@ -3,7 +3,7 @@ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2010 - 2011 Pavel Pozdniak - 2010 - 2020 Roland Gruber + 2010 - 2023 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -43,7 +43,7 @@ class imapAccess extends baseModule { const QUOTA_LIMIT = 'limit'; /** quota limit from profile */ - private $profileQuotaLimit = null; + private $profileQuotaLimit; /** user name */ private $user; @@ -867,9 +867,9 @@ class imapAccess extends baseModule { $attributes[$name] = array($value); } } - $extractErrors = $this->extractUserAndEmail($attributes); - if (!empty($extractErrors)) { - $errors = array_merge($errors, $extractErrors); + $extractError = $this->extractUserAndEmail($attributes); + if ($extractError !== null) { + $errors[] = $extractError; } $temp['users'][] = array( 'uid' => $this->user, diff --git a/lam/lib/modules/inetOrgPerson.inc b/lam/lib/modules/inetOrgPerson.inc index 975410f9c..b9336adad 100644 --- a/lam/lib/modules/inetOrgPerson.inc +++ b/lam/lib/modules/inetOrgPerson.inc @@ -47,21 +47,19 @@ class inetOrgPerson extends baseModule implements passwordService,AccountStatusP const STATUS_PASSWORD_LOCKED = "INETORG_PERSON_PASSWORD_LOCKED"; /** clear text password */ - private $clearTextPassword = null; + private $clearTextPassword; /** cache for departments */ - private $departmentCache = null; + private $departmentCache; /** organization cache */ - private $oCache = null; + private $oCache; /** organizational unit cache */ - private $ouCache = null; + private $ouCache; /** title cache */ - private $titleCache = null; + private $titleCache; /** employee type cache */ - private $employeeTypeCache = null; + private $employeeTypeCache; /** business category cache */ - private $businessCategoryCache = null; - /** cache for email duplication checks */ - private $emailCheckCache = array(); + private $businessCategoryCache; /** session variable for existing user certificates in self service */ const SESS_CERTIFICATES_LIST = 'inetOrgPerson_certificatesList'; @@ -3353,7 +3351,7 @@ class inetOrgPerson extends baseModule implements passwordService,AccountStatusP $jsonReturn = $this->ajaxDeleteSelfServiceUserCertificate($jsonInput); } elseif ($jsonInput['action'] == 'deletePhoto') { - $jsonReturn = $this->ajaxDeleteSelfServicePhoto($jsonInput); + $jsonReturn = $this->ajaxDeleteSelfServicePhoto(); } } echo json_encode($jsonReturn); @@ -3437,10 +3435,8 @@ class inetOrgPerson extends baseModule implements passwordService,AccountStatusP /** * Manages the deletion of a photo. - * - * @param array $data JSON data */ - private function ajaxDeleteSelfServicePhoto($data) { + private function ajaxDeleteSelfServicePhoto() { $_SESSION[self::SESS_PHOTO] = null; ob_start(); $contentElement = $this->getSelfServicePhoto(false, false); diff --git a/lam/lib/modules/kolabGroup.inc b/lam/lib/modules/kolabGroup.inc index 59bb0231b..858f10f7b 100644 --- a/lam/lib/modules/kolabGroup.inc +++ b/lam/lib/modules/kolabGroup.inc @@ -35,7 +35,7 @@ use LAM\TYPES\TypeManager; class kolabGroup extends baseModule { /** cache for mail attribute */ - private $mailCache = null; + private $mailCache; /** * Creates a new kolabGroup object. diff --git a/lam/lib/modules/ldapPublicKey.inc b/lam/lib/modules/ldapPublicKey.inc index 86f9408ad..6e5b773d8 100644 --- a/lam/lib/modules/ldapPublicKey.inc +++ b/lam/lib/modules/ldapPublicKey.inc @@ -394,7 +394,6 @@ class ldapPublicKey extends baseModule { * @return htmlJavaScript JS block */ private static function getSelfServiceKeysJSBlock() { - $keys = $_SESSION[self::SESS_KEY_LIST]; $content = ' function ldapPublicKeyDeleteKey(id) { var actionJSON = { diff --git a/lam/lib/modules/nisMailAlias.inc b/lam/lib/modules/nisMailAlias.inc index 6afe54039..7e945a972 100644 --- a/lam/lib/modules/nisMailAlias.inc +++ b/lam/lib/modules/nisMailAlias.inc @@ -2,7 +2,7 @@ /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2004 - 2022 Roland Gruber + Copyright (C) 2004 - 2023 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -36,9 +36,9 @@ use LAM\TYPES\ConfiguredType; class nisMailAlias extends baseModule { /** mail cache */ - private $cachedMailList = null; + private $cachedMailList; /** user cache */ - private $cachedUserList = null; + private $cachedUserList; /** display limit */ const DISPLAY_LIMIT = 50; @@ -343,7 +343,6 @@ class nisMailAlias extends baseModule { * @return htmlElement meta HTML code */ function display_html_select($isMail) { - $options = array(); if ($isMail) { $regex = 'email'; $options = $this->getMailList(); diff --git a/lam/lib/modules/nisMailAliasUser.inc b/lam/lib/modules/nisMailAliasUser.inc index 54ff3235b..e8ec241af 100644 --- a/lam/lib/modules/nisMailAliasUser.inc +++ b/lam/lib/modules/nisMailAliasUser.inc @@ -3,7 +3,7 @@ use \LAM\TYPES\TypeManager; /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2014 - 2022 Roland Gruber + Copyright (C) 2014 - 2023 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -35,7 +35,7 @@ use \LAM\TYPES\TypeManager; class nisMailAliasUser extends baseModule { /** alias cache */ - private $cachedAliasList = null; + private $cachedAliasList; /** recipient entries to delete (list of arrays: dn => attributes) */ private $recipientsToDelete = array(); @@ -76,18 +76,10 @@ class nisMailAliasUser extends baseModule { "Headline" => _("Alias names with user name"), "Text" => _('Sets the alias names linked to the current user name.') ), - 'aliasUserList' => array( - "Headline" => _("Alias names with user name"), - "Text" => _('Sets the alias names linked to the current user name.') . ' ' . _("Multiple values are separated by semicolon.") - ), 'aliasMail' => array( "Headline" => _("Alias names with email address"), "Text" => _('Sets the alias names linked to the user\'s email address.') ), - 'aliasUserList' => array( - "Headline" => _("Alias names with email address"), - "Text" => _('Sets the alias names linked to the user\'s email address.') . ' ' . _("Multiple values are separated by semicolon.") - ), 'suffix' => array( "Headline" => _("Suffix"), "Text" => _("Location where new alias is stored.") @@ -277,7 +269,7 @@ class nisMailAliasUser extends baseModule { } else { $this->aliasesToAdd[$dn]['rfc822mailmember'] = array_values(array_delete(array($recipient), $this->aliasesToAdd[$dn]['rfc822mailmember'])); - foreach ($this->cachedAliasList as $index => &$attrs) { + foreach ($this->cachedAliasList as &$attrs) { if ($dn == $attrs['dn']) { $attrs['rfc822mailmember'] = array_values(array_delete(array($recipient), $attrs['rfc822mailmember'])); } diff --git a/lam/lib/modules/nisNetGroupUser.inc b/lam/lib/modules/nisNetGroupUser.inc index 273a89906..c491e3146 100644 --- a/lam/lib/modules/nisNetGroupUser.inc +++ b/lam/lib/modules/nisNetGroupUser.inc @@ -6,7 +6,7 @@ use \LAM\TYPES\TypeManager; /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2015 - 2019 Roland Gruber + Copyright (C) 2015 - 2023 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -43,9 +43,9 @@ class nisNetGroupUser extends baseModule { /** list of NIS netgroups the user was memberOf (array(array(name => '', dn => '', host => '', domain => ''))) */ protected $groupsOrig = array(); /** group cache (array(array(cn => '', dn => '', nisnetgrouptriple => array()))) */ - protected $groupCache = null; + protected $groupCache; /** original uid */ - protected $uidOrig = null; + protected $uidOrig; /** * Returns true if this module can manage accounts of the current type, otherwise false. @@ -284,7 +284,6 @@ class nisNetGroupUser extends baseModule { * @return String user ID */ protected function getUid() { - $moduleAttributes = array(); if ($this->getAccountContainer()->getAccountModule('posixAccount') != null) { $moduleAttributes = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes(); } diff --git a/lam/lib/modules/nisnetgroup.inc b/lam/lib/modules/nisnetgroup.inc index bebb115e3..a8b79b859 100644 --- a/lam/lib/modules/nisnetgroup.inc +++ b/lam/lib/modules/nisnetgroup.inc @@ -7,7 +7,7 @@ use LAM\TYPES\ConfiguredType; /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2009 - 2022 Roland Gruber + Copyright (C) 2009 - 2023 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,11 +41,11 @@ class nisnetgroup extends baseModule { /* caches to reduce LDAP queries */ /** user cache */ - private $cachedUserList = null; + private $cachedUserList; /** host cache */ - private $cachedHostList = null; + private $cachedHostList; /** group cache */ - private $cachedGroupList = null; + private $cachedGroupList; /** * Returns true if this module can manage accounts of the current type, otherwise false. @@ -459,7 +459,6 @@ class nisnetgroup extends baseModule { break; } } - $options = array(); if ($selectHost) { // load list with all hosts $options = $this->getHostList(); diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index 3025c85b9..462fcf7b4 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -78,15 +78,15 @@ class posixAccount extends baseModule implements passwordService,AccountStatusPr /** lamdaemon servers */ private $lamdaemonServers = array(); /** cache for group objects */ - private $groupCache = null; + private $groupCache; /** cache for group of names objects */ - private $gonCache = null; + private $gonCache; /** clear text password */ private $clearTextPassword; /** caches the list of known UIDs */ - private $cachedUIDList = null; + private $cachedUIDList; /** caches the list of known user names */ - private $cachedUserNameList = null; + private $cachedUserNameList; /** replacements for common umlauts */ private $umlautReplacements = array( @@ -634,8 +634,7 @@ class posixAccount extends baseModule implements passwordService,AccountStatusPr for ($i = 0; $i < sizeof($gonList); $i++) { $userGoNs[] = $gonList[$i]['dn']; } - $userGoNs = array_values(array_unique($userGoNs)); - return $userGoNs; + return array_values(array_unique($userGoNs)); } /** @@ -1065,10 +1064,8 @@ class posixAccount extends baseModule implements passwordService,AccountStatusPr // lamdaemon results if (!empty($result)) { $singleresult = explode(",", $result); - if (is_array($singleresult)) { - if (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO')) { - $return[] = $singleresult; - } + if (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO')) { + $return[] = $singleresult; } } } @@ -1299,12 +1296,8 @@ class posixAccount extends baseModule implements passwordService,AccountStatusPr if (!get_preg($this->attributes['uid'][0], 'hostname')) { $errors[] = $this->messages['uid'][4]; } - if (!isset($this->attributes[$homedirAttrName][0])) { - $this->attributes[$homedirAttrName][0] = '/dev/null'; - } - if (!isset($this->attributes['loginShell'][0])) { - $this->attributes['loginShell'][0] = '/bin/false'; - } + $this->attributes[$homedirAttrName][0] = '/dev/null'; + $this->attributes['loginShell'][0] = '/bin/false'; } $attributeList = array($homedirAttrName); if (!$this->isBooleanConfigOptionSet('posixAccount_' . $typeId . '_hidegecos')) { @@ -1656,11 +1649,9 @@ class posixAccount extends baseModule implements passwordService,AccountStatusPr // lamdaemon results if (!empty($result)) { $singleresult = explode(",", $result); - if (is_array($singleresult)) { - if (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO')) { + if (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO')) { $return[] = $singleresult; } - } } } elseif (isset($_POST['form_subpage_' . get_class($this) . '_homedir_delete_' . $i])) { @@ -1687,11 +1678,9 @@ class posixAccount extends baseModule implements passwordService,AccountStatusPr // lamdaemon results if (!empty($result)) { $singleresult = explode(",", $result); - if (is_array($singleresult)) { - if (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO')) { + if (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO')) { $return[] = $singleresult; } - } } } } @@ -3184,17 +3173,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')) { @@ -3263,74 +3252,6 @@ class posixAccount extends baseModule implements passwordService,AccountStatusPr return $ret; } - /** - * 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) { - if ($this->get_scope() == 'user') { - $dn = $this->moduleSettings['posixAccount_' . $typeId . '_sambaIDPoolDNUsers'][0]; - } - else { - $dn = $this->moduleSettings['posixAccount_' . $typeId . '_sambaIDPoolDNHosts'][0]; - } - $attrs = ldapGetDN($dn, array('uidNumber')); - if (isset($attrs['uidnumber'][0]) && ($attrs['uidnumber'][0] != '')) { - $newValue = $attrs['uidnumber'][0] + $count; - $ldapHandle = $_SESSION['ldap']->server(); - ldap_modify($ldapHandle, $dn, array('uidnumber' => array($newValue))); - logNewMessage(LOG_DEBUG, 'Updated Samba ID pool ' . $dn . ' with UID number ' . $newValue . ' and LDAP code ' . ldap_errno($ldapHandle)); - if (ldap_errno($ldapHandle) != 0) { - logNewMessage(LOG_NOTICE, 'Updating Samba ID pool ' . $dn . ' with UID number ' . $newValue . ' failed. ' . ldap_error($ldapHandle)); - return null; - } - $result = array(); - for ($i = 0; $i < $count; $i++) { - $result[] = $attrs['uidnumber'][0] + $i; - } - return $result; - } - return null; - } - - /** - * 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) { - if ($this->get_scope() == 'user') { - $dn = $this->moduleSettings['posixAccount_' . $typeId . '_windowsIDPoolDNUsers'][0]; - } - else { - $dn = $this->moduleSettings['posixAccount_' . $typeId . '_windowsIDPoolDNHosts'][0]; - } - $attrs = ldapGetDN($dn, array('msSFU30MaxUidNumber')); - if (!empty($attrs['mssfu30maxuidnumber'][0])) { - $newValue = $attrs['mssfu30maxuidnumber'][0] + $count; - $ldapHandle = $_SESSION['ldap']->server(); - ldap_modify($ldapHandle, $dn, array('mssfu30maxuidnumber' => array($newValue))); - logNewMessage(LOG_DEBUG, 'Updated domain info ' . $dn . ' with UID number ' . $newValue . ' and LDAP code ' . ldap_errno($ldapHandle)); - if (ldap_errno($ldapHandle) != 0) { - logNewMessage(LOG_NOTICE, 'Updating domain info ' . $dn . ' with UID number ' . $newValue . ' failed. ' . ldap_error($ldapHandle)); - return null; - } - $result = array(); - for ($i = 0; $i < $count; $i++) { - $result[] = $attrs['mssfu30maxuidnumber'][0] + $i; - } - return $result; - } - return null; - } - /** * Returns the meta HTML code for each input field. * format: array( => array(), ...) diff --git a/lam/lib/modules/sambaSamAccount/sambaMungedDial.inc b/lam/lib/modules/sambaSamAccount/sambaMungedDial.inc index 8d7928e5e..40cbfe4ae 100644 --- a/lam/lib/modules/sambaSamAccount/sambaMungedDial.inc +++ b/lam/lib/modules/sambaSamAccount/sambaMungedDial.inc @@ -263,7 +263,6 @@ class sambaMungedDial $this->old_behavior=true; } - $ctxField=""; if($this->old_behavior) { $ctxField= substr(base64_decode($munge), (strlen(SAMBA_MUNGEDDIAL_FILEHEADER_OLD)) / 2); } else { @@ -609,5 +608,3 @@ class sambaMungedDial } } } - -?>