Commit 17fb8efc authored by Johan Cwiklinski's avatar Johan Cwiklinski

Revert "Check is array; fixes #3780"

This reverts commit f72d87e0.
parent 33e99561
......@@ -1355,57 +1355,55 @@ class User extends CommonDBTM {
$sr = @ ldap_read($ldap_connection, $userdn, "objectClass=*", $group_fields);
$v = AuthLDAP::get_entries_clean($ldap_connection, $sr);
if (is_array($v['count'])) {
for ($i=0; $i<count($v['count']); $i++) {
//Try to find is DN in present and needed: if yes, then extract only the OU from it
if ((($ldap_method["group_field"] == 'dn') || in_array('ou', $group_fields))
&& isset($v[$i]['dn'])) {
$v[$i]['ou'] = [];
for ($tmp=$v[$i]['dn']; count($tmptab = explode(',', $tmp, 2))==2; $tmp=$tmptab[1]) {
$v[$i]['ou'][] = $tmptab[1];
}
for ($i=0; $i<count($v['count']); $i++) {
//Try to find is DN in present and needed: if yes, then extract only the OU from it
if ((($ldap_method["group_field"] == 'dn') || in_array('ou', $group_fields))
&& isset($v[$i]['dn'])) {
$v[$i]['ou'] = [];
for ($tmp=$v[$i]['dn']; count($tmptab = explode(',', $tmp, 2))==2; $tmp=$tmptab[1]) {
$v[$i]['ou'][] = $tmptab[1];
}
// Search in DB for group with ldap_group_dn
if (($ldap_method["group_field"] == 'dn')
&& (count($v[$i]['ou']) > 0)) {
$query = "SELECT `id`
FROM `glpi_groups`
WHERE `ldap_group_dn`
IN ('".implode("', '",
Toolbox::addslashes_deep($v[$i]['ou']))."')";
foreach ($DB->request($query) as $group) {
$this->fields["_groups"][] = $group['id'];
}
// Search in DB for group with ldap_group_dn
if (($ldap_method["group_field"] == 'dn')
&& (count($v[$i]['ou']) > 0)) {
$query = "SELECT `id`
FROM `glpi_groups`
WHERE `ldap_group_dn`
IN ('".implode("', '",
Toolbox::addslashes_deep($v[$i]['ou']))."')";
foreach ($DB->request($query) as $group) {
$this->fields["_groups"][] = $group['id'];
}
// searching with ldap_field='OU' and ldap_value is also possible
$v[$i]['ou']['count'] = count($v[$i]['ou']);
}
// For each attribute retrieve from LDAP, search in the DB
foreach ($group_fields as $field) {
if (isset($v[$i][$field])
&& isset($v[$i][$field]['count'])
&& ($v[$i][$field]['count'] > 0)) {
// searching with ldap_field='OU' and ldap_value is also possible
$v[$i]['ou']['count'] = count($v[$i]['ou']);
}
// For each attribute retrieve from LDAP, search in the DB
foreach ($group_fields as $field) {
if (isset($v[$i][$field])
&& isset($v[$i][$field]['count'])
&& ($v[$i][$field]['count'] > 0)) {
unset($v[$i][$field]['count']);
foreach (Toolbox::addslashes_deep($v[$i][$field]) as $lgroup) {
$lgroups[] = "('".$lgroup."' LIKE `ldap_value`)";
}
$query = "SELECT `id`
FROM `glpi_groups`
WHERE `ldap_field` = '$field'
AND (".implode(" OR ", $lgroups).")";
unset($v[$i][$field]['count']);
foreach (Toolbox::addslashes_deep($v[$i][$field]) as $lgroup) {
$lgroups[] = "('".$lgroup."' LIKE `ldap_value`)";
}
$query = "SELECT `id`
FROM `glpi_groups`
WHERE `ldap_field` = '$field'
AND (".implode(" OR ", $lgroups).")";
foreach ($DB->request($query) as $group) {
$this->fields["_groups"][] = $group['id'];
}
foreach ($DB->request($query) as $group) {
$this->fields["_groups"][] = $group['id'];
}
}
} // for each ldapresult
} //if countable
}
} // for each ldapresult
} // count($group_fields)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment