You are here

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

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/Entity/Server.php, line 2030

Class

Server
Defines the Server entity.

Namespace

Drupal\ldap_servers\Entity

Code

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

    // If attributes weren't returned, don't give false  empty group.
    if (empty($group_entry['cn'])) {
      return FALSE;
    }
    if (empty($group_entry[$this
      ->groupMembershipsAttr()])) {

      // If no attribute returned, no members.
      return [];
    }
    $members = $group_entry[$this
      ->groupMembershipsAttr()];
    if (isset($members['count'])) {
      unset($members['count']);
    }
    return $members;
  }
}