You are here

public function LdapGroupManager::groupMembers in Lightweight Directory Access Protocol (LDAP) 8.4

Get direct members of a group.

Currently not in use.

@todo Split return functionality or throw an error.

Parameters

string $group_dn: Group DN as LDAP DN.

Return value

bool|array FALSE on error, otherwise array of group members (could be users or groups).

File

ldap_servers/src/LdapGroupManager.php, line 308

Class

LdapGroupManager
LDAP Group Manager.

Namespace

Drupal\ldap_servers

Code

public function groupMembers(string $group_dn) {
  if (!$this
    ->checkAvailability()) {
    return FALSE;
  }
  if (!$this
    ->groupGroupEntryMembershipsConfigured()) {
    return FALSE;
  }
  $attributes = [
    $this->server
      ->get('grp_memb_attr'),
    'cn',
    'objectclass',
  ];
  $group_entry = $this
    ->checkDnExistsIncludeData($group_dn, $attributes);
  if (!$group_entry) {
    return FALSE;
  }

  // If attributes weren't returned, don't give false, give empty group.
  if (!$group_entry
    ->hasAttribute('cn', FALSE)) {
    return FALSE;
  }
  if (!$group_entry
    ->hasAttribute($this->server
    ->get('grp_memb_attr'), FALSE)) {

    // If no attribute returned, no members.
    return [];
  }
  return $group_entry
    ->getAttribute($this->server
    ->get('grp_memb_attr'), FALSE);
}