You are here

public function LdapServer::deriveFromAttrGroups in Lightweight Directory Access Protocol (LDAP) 7

return by reference groups/authorizations when groups are defined from user attributes (such as memberOf)

Parameters

array $derive_from_attribute_name. e.g. memberOf: @param array $user_ldap_entry as returned by ldap php extension @param boolean $nested if groups should be recursed or not.

@return array of groups specified in the derive from attribute

File

ldap_servers/LdapServer.class.php, line 642
Defines server classes and related functions.

Class

LdapServer
LDAP Server Class

Code

public function deriveFromAttrGroups($derive_from_attribute_name, $user_ldap_entry, $nested) {
  $all_groups = array();
  $groups_by_level = array();
  $level = 0;
  foreach ($user_ldap_entry['attr'] as $user_attr_name => $user_attr_values) {
    if (strcasecmp($derive_from_attribute_name, $user_attr_name) != 0) {
      continue;
    }

    // patch 1050944
    for ($i = 0; $i < $user_attr_values['count']; $i++) {
      $all_groups[] = (string) $user_attr_values[$i];
      $groups_by_level[$derive_from_attribute_name][$level][] = (string) $user_attr_values[$i];
    }
    if ($nested) {
      $this
        ->deriveFromAttrGroupsResursive($all_groups, $groups_by_level, $level, $derive_from_attribute_name, 10);

      // LDAP_SERVER_GROUPS_RECURSE_DEPTH
    }
  }
  return array_unique($all_groups);
}