Projet

Général

Profil

Révision dd54aff9

Ajouté par Assos Assos il y a plus de 10 ans

Weekly update of contrib modules

Voir les différences:

htmltest/sites/all/modules/ldap/ldap_servers/LdapServer.class.php
6 6
 *
7 7
 */
8 8

  
9
/**
10
 * TODO check if this already exists or find a better place for this function
11
 *
12
 * Formats a ldap-entry ready to be printed on console.
13
 * TODO describe preconditions for ldap_entry
14
 */
15
function pretty_print_ldap_entry($ldap_entry) {
16
  $m=array();
17
  for ($i=0; $i < $ldap_entry['count']; $i++) {
18
    $k=$ldap_entry[$i];
19
    $v=$ldap_entry[$k];
20
    if(is_array($v)) {
21
      $m2=array();
22
      $max=$v['count']>3 ? 3 : $v['count'];
23
      for ($j=0; $j < $max; $j++) {
24
	$m2[] = $v[$j];
25
      }
26
      $v="(".join(", ", $m2).")";
27
    }
28
    $m[] = $k . ": " . $v;
29
  }
30
  return join(", ", $m);
31
}
32

  
9 33
/**
10 34
 * LDAP Server Class
11 35
 *
......
1743 1767
      }
1744 1768
      else {// maybe cn, uid, etc is held
1745 1769
        $member_id = ldap_servers_get_first_rdn_value_from_dn($group_entry['dn'], $this->groupMembershipsAttrMatchingUserAttr);
1770
	if(!$member_id) {
1771
	  if ($this->detailed_watchdog_log) {
1772
	     watchdog('ldap_server', 'group_entry: %ge', array('%ge'=>pretty_print_ldap_entry($group_entry)));
1773
	  }
1774
	  // group not identified by simple checks yet!
1775

  
1776
	  // examine the entry and see if it matches the configured groupObjectClass
1777
	  $goc=$group_entry['objectclass']; // TODO do we need to ensure such entry is there?
1778
	  if(is_array($goc)) {              // TODO is it always an array?
1779
	    foreach($goc as $g) {
1780
	      $g=drupal_strtolower($g);
1781
	      if($g == $this->groupObjectClass) {
1782
		// found a group, current user must be member in it - so:
1783
		if ($this->detailed_watchdog_log) {
1784
		  watchdog('ldap_server', 'adding %mi', array('%mi'=>$member_id));
1785
		}
1786
		$member_id=$group_entry['dn'];
1787
		break;
1788
	      }
1789
	    }
1790
	  }
1791
	}
1746 1792
      }
1747 1793

  
1748 1794
      if ($member_id && !in_array($member_id, $tested_group_ids)) {

Formats disponibles : Unified diff