fixed search_units() if no OUs are in the suffix
This commit is contained in:
parent
9f84b6b225
commit
733240f369
|
@ -134,6 +134,7 @@ class Ldap{
|
|||
|
||||
// returns an array with all organizational units under the given suffix
|
||||
function search_units($suffix) {
|
||||
$units = array();
|
||||
$sr = @ldap_search($_SESSION["ldap"]->server(), $suffix, "objectClass=organizationalunit", array("DN"));
|
||||
if ($sr) {
|
||||
$units = ldap_get_entries($_SESSION["ldap"]->server, $sr);
|
||||
|
@ -141,11 +142,11 @@ class Ldap{
|
|||
array_shift($units);
|
||||
// remove sub arrays
|
||||
for ($i = 0; $i < sizeof($units); $i++) $units[$i] = $units[$i]['dn'];
|
||||
}
|
||||
// add root suffix if needed
|
||||
if (!in_array($suffix, $units)) {
|
||||
array_push($units, $suffix);
|
||||
}
|
||||
}
|
||||
return $units;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue