Skip to content
Snippets Groups Projects
Commit 6a681c9e authored by git's avatar git Committed by John Barclay
Browse files

Issue #1965160 attempt2.patch

parent 5d34287b
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,30 @@
*
*/
/**
* TODO check if this already exists or find a better place for this function
*
* Formats a ldap-entry ready to be printed on console.
* TODO describe preconditions for ldap_entry
*/
function pretty_print_ldap_entry($ldap_entry) {
$m=array();
for ($i=0; $i < $ldap_entry['count']; $i++) {
$k=$ldap_entry[$i];
$v=$ldap_entry[$k];
if(is_array($v)) {
$m2=array();
$max=$v['count']>3 ? 3 : $v['count'];
for ($j=0; $j < $max; $j++) {
$m2[] = $v[$j];
}
$v="(".join(", ", $m2).")";
}
$m[] = $k . ": " . $v;
}
return join(", ", $m);
}
/**
* LDAP Server Class
*
......@@ -1743,6 +1767,28 @@ class LdapServer {
}
else {// maybe cn, uid, etc is held
$member_id = ldap_servers_get_first_rdn_value_from_dn($group_entry['dn'], $this->groupMembershipsAttrMatchingUserAttr);
if(!$member_id) {
if ($this->detailed_watchdog_log) {
watchdog('ldap_server', 'group_entry: %ge', array('%ge'=>pretty_print_ldap_entry($group_entry)));
}
// group not identified by simple checks yet!
// examine the entry and see if it matches the configured groupObjectClass
$goc=$group_entry['objectclass']; // TODO do we need to ensure such entry is there?
if(is_array($goc)) { // TODO is it always an array?
foreach($goc as $g) {
$g=drupal_strtolower($g);
if($g == $this->groupObjectClass) {
// found a group, current user must be member in it - so:
if ($this->detailed_watchdog_log) {
watchdog('ldap_server', 'adding %mi', array('%mi'=>$member_id));
}
$member_id=$group_entry['dn'];
break;
}
}
}
}
}
if ($member_id && !in_array($member_id, $tested_group_ids)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment