added fix for broken DNs
This commit is contained in:
parent
03116183d0
commit
4a7f81986e
|
@ -134,21 +134,20 @@ 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();
|
$ret = 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);
|
||||||
// delete first array entry which is "count"
|
// extract Dns
|
||||||
array_shift($units);
|
for ($i = 0; $i < sizeof($units); $i++) {
|
||||||
// remove sub arrays
|
if ($units[$i]['dn']) $ret[] = $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, $ret)) {
|
||||||
if (sizeof($units) > 0) array_push($units, $suffix);
|
$ret[] = $suffix;
|
||||||
else $units[0] = $suffix;
|
|
||||||
}
|
}
|
||||||
return $units;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns the LDAP connection handle
|
// returns the LDAP connection handle
|
||||||
|
|
Loading…
Reference in New Issue