From 8b9d668f38841aa3c6babcf1c554ffd44f976781 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 19 Dec 2009 16:28:16 +0000 Subject: [PATCH] use cleanLDAPResult() --- lam/lib/ldap.inc | 2 +- lam/lib/lists.inc | 10 +--------- lam/templates/delete.php | 6 ++++-- lam/templates/login.php | 5 +++-- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/lam/lib/ldap.inc b/lam/lib/ldap.inc index a3ff6b76..34075ee6 100644 --- a/lam/lib/ldap.inc +++ b/lam/lib/ldap.inc @@ -138,7 +138,7 @@ class Ldap{ $sr = @ldap_search($this->server(), escapeDN($suffix), "objectClass=organizationalunit", array("DN"), 0, 0, 0, LDAP_DEREF_NEVER); if ($sr) { $units = ldap_get_entries($this->server, $sr); - unset($units['count']); + $units = cleanLDAPResult($units); // extract Dns for ($i = 0; $i < sizeof($units); $i++) { if ($units[$i]['dn']) $ret[] = $units[$i]['dn']; diff --git a/lam/lib/lists.inc b/lam/lib/lists.inc index 4836222b..50271d49 100644 --- a/lam/lib/lists.inc +++ b/lam/lib/lists.inc @@ -481,8 +481,6 @@ class lamList { protected function listPrintTableCellContent(&$entry, &$attribute) { // print all attribute entries seperated by "; " if (isset($entry[$attribute]) && sizeof($entry[$attribute]) > 0) { - // delete "count" entry - unset($entry[$attribute]['count']); if (is_array($entry[$attribute])) { // sort array sort($entry[$attribute]); @@ -832,14 +830,8 @@ class lamList { } if ($sr) { $info = ldap_get_entries($_SESSION["ldap"]->server(), $sr); + $info = cleanLDAPResult($info); ldap_free_result($sr); - // delete first array entry which is "count" - unset($info['count']); - // save position in original $info - $infoCount = sizeof($info); - for ($i = 0; $i < $infoCount; $i++) { - if (isset($info[$i]['count'])) unset($info[$i]['count']); - } // save results $this->entries = $info; } diff --git a/lam/templates/delete.php b/lam/templates/delete.php index b9b62ac5..1066c233 100644 --- a/lam/templates/delete.php +++ b/lam/templates/delete.php @@ -257,7 +257,8 @@ function getChildCount($dn) { $sr = @ldap_search($_SESSION['ldap']->server(), escapeDN($dn), 'objectClass=*', array('dn'), 0, 0, 0, LDAP_DEREF_NEVER); if ($sr) { $entries = ldap_get_entries($_SESSION['ldap']->server(), $sr); - $return = $entries['count'] - 1; + $entries = cleanLDAPResult($entries); + $return = sizeof($entries) - 1; } return $return; } @@ -273,7 +274,8 @@ function deleteDN($dn) { $sr = @ldap_list($_SESSION['ldap']->server(), $dn, 'objectClass=*', array('dn'), 0); if ($sr) { $entries = ldap_get_entries($_SESSION['ldap']->server(), $sr); - for ($i = 0; $i < $entries['count']; $i++) { + $entries = cleanLDAPResult($entries); + for ($i = 0; $i < sizeof($entries); $i++) { // delete recursively $subErrors = deleteDN($entries[$i]['dn']); for ($e = 0; $e < sizeof($subErrors); $e++) $errors[] = $subErrors[$e]; diff --git a/lam/templates/login.php b/lam/templates/login.php index 291497e8..8a079ea2 100644 --- a/lam/templates/login.php +++ b/lam/templates/login.php @@ -446,11 +446,12 @@ if(!empty($_POST['checklogin'])) { if ($searchResult) { $searchInfo = @ldap_get_entries($searchLDAP->server(), $searchResult); if ($searchInfo) { - if ($searchInfo['count'] == 0) { + $searchInfo = cleanLDAPResult($searchInfo); + if (sizeof($searchInfo) == 0) { $searchSuccess = false; $searchError = _('Wrong password/user name combination. Please try again.'); } - elseif ($searchInfo['count'] > 1) { + elseif (sizeof($searchInfo) > 1) { $searchSuccess = false; $searchError = _('The given user name matches multiple LDAP entries.'); }