public function LdapGroupManager::groupMembershipsFromUser in Lightweight Directory Access Protocol (LDAP) 8.4
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.
Parameters
string $username: A Drupal user entity.
Return value
array Array of group dns in mixed case or FALSE on error.
1 call to LdapGroupManager::groupMembershipsFromUser()
- LdapGroupManager::groupIsMember in ldap_servers/
src/ LdapGroupManager.php - Is a user a member of group?
File
- ldap_servers/
src/ LdapGroupManager.php, line 476
Class
- LdapGroupManager
- LDAP Group Manager.
Namespace
Drupal\ldap_serversCode
public function groupMembershipsFromUser(string $username) : array {
$group_dns = [];
if (!$this
->checkAvailability()) {
return $group_dns;
}
$user_ldap_entry = $this
->matchUsernameToExistingLdapEntry($username);
if (!$user_ldap_entry || $this->server
->get('grp_unused')) {
return $group_dns;
}
// Preferred method.
if ($this->server
->isGroupUserMembershipAttributeInUse() && $this->server
->getGroupUserMembershipAttribute()) {
$group_dns = $this
->groupUserMembershipsFromUserAttr($user_ldap_entry);
}
elseif ($this
->groupGroupEntryMembershipsConfigured()) {
$group_dns = $this
->groupUserMembershipsFromEntry($user_ldap_entry);
}
return $group_dns;
}