You are here

public function Server::groupMembershipsFromUser in Lightweight Directory Access Protocol (LDAP) 8.3

Get list of all groups that a user is a member of.

If nesting is configured, the list will include all parent groups. For example, if the user is a member of the "programmer" group and the "programmer" group is a member of the "it" group, the user is a member of both the "programmer" and the "it" group. If $nested is FALSE, the list will only include groups which are directly assigned to the user.

@TODO: Make the user type argument consistent or split the function.

Parameters

mixed $user: A Drupal user entity, an LDAP entry array of a user or a username.

Return value

array|false Array of group dns in mixed case or FALSE on error.

1 call to Server::groupMembershipsFromUser()
Server::groupIsMember in ldap_servers/src/Entity/Server.php
Is a user a member of group?

File

ldap_servers/src/Entity/Server.php, line 1357

Class

Server
Defines the Server entity.

Namespace

Drupal\ldap_servers\Entity

Code

public function groupMembershipsFromUser($user) {
  $group_dns = FALSE;
  $user_ldap_entry = @$this
    ->userUserToExistingLdapEntry($user);
  if (!$user_ldap_entry || $this
    ->groupFunctionalityUnused()) {
    return FALSE;
  }

  // Preferred method.
  if ($this
    ->groupUserMembershipsFromAttributeConfigured()) {
    $group_dns = $this
      ->groupUserMembershipsFromUserAttr($user_ldap_entry);
  }
  elseif ($this
    ->groupGroupEntryMembershipsConfigured()) {
    $group_dns = $this
      ->groupUserMembershipsFromEntry($user_ldap_entry);
  }
  return $group_dns;
}