From 112a3205558c5610cdd11a4a64ffc37a09272a73 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 26 Nov 2009 13:32:14 +0000 Subject: [PATCH] do not use in_cache --- lam/lib/modules/posixAccount.inc | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index ce182a43..fa4f838a 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -527,7 +527,7 @@ class posixAccount extends baseModule implements passwordService { // Add new memberships if (is_array($this->groups)) { foreach ($this->groups as $group) { - $dn = $_SESSION['cache']->in_cache($group, 'cn', 'group'); + $dn = $this->getGroupDN($group); $return[$dn]['add']['memberUid'][0] = $this->attributes['uid'][0]; } } @@ -808,11 +808,11 @@ class posixAccount extends baseModule implements passwordService { // Create automatic useraccount with number if original user already exists // Reset name to original name if new name is in use // Set username back to original name if new username is in use - if ($_SESSION['cache']->in_cache($this->attributes['uid'][0],'uid', array('user', 'host')) && ($this->orig['uid'][0]!='')) + if ((sizeof(searchLDAPByAttribute('uid', $this->attributes['uid'][0], 'posixAccount', array('uid'), array('user', 'host'))) > 0) && ($this->orig['uid'][0]!='')) $this->attributes['uid'][0] = $this->orig['uid'][0]; // Change uid to a new uid until a free uid is found else - while ($_SESSION['cache']->in_cache($this->attributes['uid'][0], 'uid', array('user', 'host'))) { + while (sizeof(searchLDAPByAttribute('uid', $this->attributes['uid'][0], 'posixAccount', array('uid'), array('user', 'host'))) > 0) { if ($this->get_scope()=='host') $this->attributes['uid'][0] = substr($this->attributes['uid'][0], 0, -1); // get last character of username $lastchar = substr($this->attributes['uid'][0], strlen($this->attributes['uid'][0])-1, 1); @@ -1772,7 +1772,7 @@ class posixAccount extends baseModule implements passwordService { } /** - * Returns the group ID of the given group + * Returns the group ID of the given group. * * @param String $groupname group name * @return String GID @@ -1799,6 +1799,20 @@ class posixAccount extends baseModule implements passwordService { return null; } + /** + * Returns the group DN of the given group. + * + * @param String $groupname group name + * @return String DN + */ + private function getGroupDN($groupname) { + $results = searchLDAPByAttribute('cn', $groupname, 'posixGroup', array('dn'), array('group')); + if ((sizeof($results) > 0) && isset($results[0]['dn'][0])) { + return $results[0]['dn']; + } + return null; + } + /** * Finds all existing LDAP groups. *