You are here

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

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

@todo: NOT IMPLEMENTED: nested groups

get all members of a group

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 1400
Defines server classes and related functions.

Class

LdapServer
LDAP Server Class

Code

public function groupAllMembers($group_dn) {

  // debug("groupAllMembers $group_dn, this->groupMembershipsAttr=". $this->groupMembershipsAttr . 'this->groupGroupEntryMembershipsConfigured=' . $this->groupGroupEntryMembershipsConfigured);
  if (!$this->groupGroupEntryMembershipsConfigured) {
    return FALSE;
  }
  $attributes = array(
    $this->groupMembershipsAttr,
    'cn',
  );
  $group_entry = $this
    ->dnExists($group_dn, 'ldap_entry', $attributes);
  if (!$group_entry) {
    return FALSE;
  }
  else {
    if (empty($group_entry['cn'])) {

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

      // if no attribute returned, no members
    }
    $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;
}