fixed search_units() if no OUs are in the suffix

This commit is contained in:
Roland Gruber 2003-06-28 08:05:58 +00:00
parent 9f84b6b225
commit 733240f369
1 changed files with 11 additions and 10 deletions

View File

@ -134,6 +134,7 @@ class Ldap{
// returns an array with all organizational units under the given suffix // returns an array with all organizational units under the given suffix
function search_units($suffix) { function search_units($suffix) {
$units = array();
$sr = @ldap_search($_SESSION["ldap"]->server(), $suffix, "objectClass=organizationalunit", array("DN")); $sr = @ldap_search($_SESSION["ldap"]->server(), $suffix, "objectClass=organizationalunit", array("DN"));
if ($sr) { if ($sr) {
$units = ldap_get_entries($_SESSION["ldap"]->server, $sr); $units = ldap_get_entries($_SESSION["ldap"]->server, $sr);
@ -141,11 +142,11 @@ class Ldap{
array_shift($units); array_shift($units);
// remove sub arrays // remove sub arrays
for ($i = 0; $i < sizeof($units); $i++) $units[$i] = $units[$i]['dn']; for ($i = 0; $i < sizeof($units); $i++) $units[$i] = $units[$i]['dn'];
}
// add root suffix if needed // add root suffix if needed
if (!in_array($suffix, $units)) { if (!in_array($suffix, $units)) {
array_push($units, $suffix); array_push($units, $suffix);
} }
}
return $units; return $units;
} }