diff --git a/lam/docs/devel/upgrade.htm b/lam/docs/devel/upgrade.htm index 8e40fefe..199d5603 100644 --- a/lam/docs/devel/upgrade.htm +++ b/lam/docs/devel/upgrade.htm @@ -19,6 +19,7 @@ + @@ -54,8 +55,10 @@ This is a list of API changes for all LAM releases. Functions in lib/types.inc got namespace LAM/TYPES (e.g. getTypeAlias()).
  • New API to access configured account types: LAM\TYPES\TypeManager.
  • -
  • class baseType: new function getSuffixFilter()
    +
  • class baseType: new function getSuffixFilter()
  • +
  • moved getSuffixList() from baseType to ConfiguredType
  • + diff --git a/lam/lib/baseType.inc b/lam/lib/baseType.inc index b1d2a171..5833d189 100644 --- a/lam/lib/baseType.inc +++ b/lam/lib/baseType.inc @@ -138,47 +138,6 @@ class baseType { return "(|(objectClass=organizationalunit)(objectClass=country)(objectClass=organization)(objectClass=krbRealmContainer)(objectClass=container))"; } - /** - * Returns a list of LDAP suffixes for this type. - * - * @return array sorted list of possible suffixes for this type. - */ - public function getSuffixList() { - $suffix = $_SESSION["config"]->get_Suffix(get_class($this)); - $connection = $_SESSION["ldap"]->server(); - $ret = array(); - $filter = $this->getSuffixFilter(); - $sr = @ldap_search($connection, escapeDN($suffix),$filter , array('dn', 'objectClass'), 0, 0, 0, LDAP_DEREF_NEVER); - if ($sr) { - $units = ldap_get_entries($connection, $sr); - cleanLDAPResult($units); - // extract Dns - $count = sizeof($units); - for ($i = 0; $i < $count; $i++) { - if (in_array('container', $units[$i]['objectclass'])) { - // Active Directory fix, hide system containers - if (preg_match('/.*cn=system,dc=.+/i', $units[$i]['dn']) || preg_match('/.*CN=program data,dc=.+/i', $units[$i]['dn'])) { - continue; - } - } - $ret[] = $units[$i]['dn']; - } - } - // add root suffix if needed - $found = false; - for ($i = 0; $i < sizeof($ret); $i++) { // search suffix case-intensitive - if (strtolower($suffix) == strtolower($ret[$i])) { - $found = true; - break; - } - } - if (!$found) { - $ret[] = $suffix; - } - usort($ret, 'compareDN'); - return $ret; - } - /** * This function is called after the edit page is processed and before the page content is generated. * This can be used to run custom handlers after each page processing. diff --git a/lam/lib/lists.inc b/lam/lib/lists.inc index 49b7750a..bfd687a9 100644 --- a/lam/lib/lists.inc +++ b/lam/lib/lists.inc @@ -962,7 +962,7 @@ class lamList { call_user_func_array('StatusMessage', $lastError); } // generate list of possible suffixes - $this->possibleSuffixes = $this->type->getBaseType()->getSuffixList(); + $this->possibleSuffixes = $this->type->getSuffixList(); } /** diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 08ed0d4c..39de01e8 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -2146,8 +2146,7 @@ class accountContainer { if ($this->cachedOUs != null) { return $this->cachedOUs; } - $typeObj = $this->type->getBaseType(); - $this->cachedOUs = $typeObj->getSuffixList(); + $this->cachedOUs = $this->type->getSuffixList(); return $this->cachedOUs; } diff --git a/lam/lib/modules/nisMailAliasUser.inc b/lam/lib/modules/nisMailAliasUser.inc index a9b8a421..fad3ee73 100644 --- a/lam/lib/modules/nisMailAliasUser.inc +++ b/lam/lib/modules/nisMailAliasUser.inc @@ -361,7 +361,7 @@ class nisMailAliasUser extends baseModule { $mailAliasTypes = $typeManager->getConfiguredTypesForScope('mailAlias'); $ous = array(); foreach ($mailAliasTypes as $type) { - $ous = array_merge($ous, $type->getBaseType()->getSuffixList()); + $ous = array_merge($ous, $type->getSuffixList()); } $ous = array_unique($ous); usort($ous, 'compareDN'); diff --git a/lam/lib/types.inc b/lam/lib/types.inc index 955a8f29..7f22bb57 100644 --- a/lam/lib/types.inc +++ b/lam/lib/types.inc @@ -271,6 +271,46 @@ class ConfiguredType { return $this->baseType; } + /** + * Returns a list of LDAP suffixes for this type. + * + * @return array sorted list of possible suffixes for this type. + */ + public function getSuffixList() { + $connection = $_SESSION["ldap"]->server(); + $ret = array(); + $filter = $this->getBaseType()->getSuffixFilter(); + $sr = @ldap_search($connection, escapeDN($this->suffix), $filter, array('dn', 'objectClass'), 0, 0, 0, LDAP_DEREF_NEVER); + if ($sr) { + $units = ldap_get_entries($connection, $sr); + cleanLDAPResult($units); + // extract Dns + $count = sizeof($units); + for ($i = 0; $i < $count; $i++) { + if (in_array('container', $units[$i]['objectclass'])) { + // Active Directory fix, hide system containers + if (preg_match('/.*cn=system,dc=.+/i', $units[$i]['dn']) || preg_match('/.*CN=program data,dc=.+/i', $units[$i]['dn'])) { + continue; + } + } + $ret[] = $units[$i]['dn']; + } + } + // add root suffix if needed + $found = false; + for ($i = 0; $i < sizeof($ret); $i++) { // search suffix case-intensitive + if (strtolower($this->suffix) == strtolower($ret[$i])) { + $found = true; + break; + } + } + if (!$found) { + $ret[] = $this->suffix; + } + usort($ret, 'compareDN'); + return $ret; + } + } /** diff --git a/lam/lib/types/asteriskExt.inc b/lam/lib/types/asteriskExt.inc index 617a41ed..319d271d 100644 --- a/lam/lib/types/asteriskExt.inc +++ b/lam/lib/types/asteriskExt.inc @@ -180,7 +180,7 @@ class lamAsteriskExtList extends lamList { $entries = $this->normalizeLdapOutput($entries); $this->entries = $entries; // generate list of possible suffixes - $this->possibleSuffixes = $this->type->getBaseType()->getSuffixList(); + $this->possibleSuffixes = $this->type->getSuffixList(); } /** diff --git a/lam/templates/profedit/profilepage.php b/lam/templates/profedit/profilepage.php index 07866e25..1e0aef15 100644 --- a/lam/templates/profedit/profilepage.php +++ b/lam/templates/profedit/profilepage.php @@ -207,8 +207,7 @@ $dnContent->addElement(new htmlSpacer(null, '10px'), true); $rootsuffix = $type->getSuffix(); // get subsuffixes $suffixes = array('-' => '-'); -$typeObj = $type->getBaseType(); -$possibleSuffixes = $typeObj->getSuffixList(); +$possibleSuffixes = $type->getSuffixList(); foreach ($possibleSuffixes as $suffix) { $suffixes[getAbstractDN($suffix)] = $suffix; }