You are here

public function LdapServer::groupAllMembers in Lightweight Directory Access Protocol (LDAP) 7.2

Same name and namespace in other branches
  1. 8.2 ldap_servers/LdapServer.class.php \LdapServer::groupAllMembers()

Get all members of a group.

@todo: NOT IMPLEMENTED: nested groups

Parameters

string $group_dn: as ldap dn.

Return value

false on error otherwise array of group members (could be users or groups)

1 call to LdapServer::groupAllMembers()
LdapServer::groupRemoveGroup in ldap_servers/LdapServer.class.php
NOT TESTED remove a group entry.

File

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

Class

LdapServer
LDAP Server Class.

Code

public function groupAllMembers($group_dn) {
  if (!$this->groupGroupEntryMembershipsConfigured) {
    return FALSE;
  }
  $attributes = [
    $this->groupMembershipsAttr,
    'cn',
  ];
  $group_entry = $this
    ->dnExists($group_dn, 'ldap_entry', $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;
  }
  $this
    ->groupMembersResursive($current_group_entries, $all_group_dns, $tested_group_ids, 0, $max_levels, $object_classes);
  return $all_group_dns;
}