Active Directory support

This commit is contained in:
Roland Gruber 2013-04-24 18:28:23 +00:00
parent bd3e80596f
commit b8b0e2ab20
1 changed files with 11 additions and 3 deletions

View File

@ -137,13 +137,21 @@ class baseType {
public function getSuffixList() {
$suffix = $_SESSION["config"]->get_Suffix(get_class($this));
$ret = array();
$sr = @ldap_search($_SESSION["ldap"]->server(), escapeDN($suffix), "(|(objectClass=organizationalunit)(objectClass=country)(objectClass=organization)(objectClass=krbRealmContainer))", array("DN"), 0, 0, 0, LDAP_DEREF_NEVER);
$filter = "(|(objectClass=organizationalunit)(objectClass=country)(objectClass=organization)(objectClass=krbRealmContainer)(objectClass=container))";
$sr = @ldap_search($_SESSION["ldap"]->server(), escapeDN($suffix),$filter , array('dn', 'objectClass'), 0, 0, 0, LDAP_DEREF_NEVER);
if ($sr) {
$units = ldap_get_entries($_SESSION["ldap"]->server(), $sr);
cleanLDAPResult($units);
// extract Dns
for ($i = 0; $i < sizeof($units); $i++) {
if ($units[$i]['dn']) $ret[] = $units[$i]['dn'];
$count = sizeof($units);
for ($i = 0; $i < $count; $i++) {
if (in_array('container', $units[$i]['objectclass'])) {
// Active Directory fix, hide system containers
if (preg_match('/.*cn=system,dc=.+/i', $units[$i]['dn']) || preg_match('/.*CN=program data,dc=.+/i', $units[$i]['dn'])) {
continue;
}
}
$ret[] = $units[$i]['dn'];
}
}
// add root suffix if needed