cache OUs

This commit is contained in:
Roland Gruber 2010-11-21 14:32:54 +00:00
parent 839d57f71c
commit 3c42706a5f
1 changed files with 20 additions and 2 deletions

View File

@ -1030,8 +1030,12 @@ class accountContainer {
/** True if this is a newly created account */
public $isNewAccount;
/** name of last loaded account profile */
private $lastLoadedProfile = '';
/** cache for existing OUs */
private $cachedOUs = null;
/**
* Returns the account module with the given class name
*
@ -1573,14 +1577,14 @@ class accountContainer {
echo "<select class=\"rightToLeftText\" name=\"accountContainerSuffix\" size=1>\n";
// loop through all suffixes
$rootsuffix = $_SESSION['config']->get_Suffix($this->type);
foreach ($_SESSION['ldap']->search_units($rootsuffix) as $suffix) {
foreach ($this->getOUs() as $suffix) {
echo '<option value="' . $suffix . '" ';
if ($this->dn == $suffix) {
echo 'selected';
}
echo ">" . getAbstractDN($suffix) . "</option>\n";
}
if (!($this->dn == '') && !in_array($this->dn, $_SESSION['ldap']->search_units($rootsuffix))) {
if (!($this->dn == '') && !in_array($this->dn, $this->getOUs())) {
echo '<option value="' . $this->dn . '" selected>' . getAbstractDN($this->dn) . "</option>\n";;
}
echo "</select>\n";
@ -2137,6 +2141,20 @@ class accountContainer {
return $parent;
}
/**
* Returns a list of OUs that exist for this account type.
*
* @return array OU list
*/
private function getOUs() {
if ($this->cachedOUs != null) {
return $this->cachedOUs;
}
$rootsuffix = $_SESSION['config']->get_Suffix($this->type);
$this->cachedOUs = $_SESSION['ldap']->search_units($rootsuffix);
return $this->cachedOUs;
}
/**
* Encrypts sensitive data before storing in session.
*