Get all members of the given group

@param string  Group DN
@param boolean Count only
@param array   Group entries (if called recursively)
@return array  Accumulated group members
324208
function list_group_members($dn, $count = false, $entries = null)
    {
        $group_members = array();

        // fetch group object
        if (empty($entries)) {
            $attribs = array_merge(array('dn','objectClass','memberURL'), array_values($this->group_types));
            $entries = $this->ldap->read_entries($dn, '(objectClass=*)', $attribs);
            if ($entries === false) {
                return $group_members;
            }
        }

        for ($i=0; $i < $entries['count']; $i++) {
            $entry = $entries[$i];
            $attrs = array();

            foreach ((array)$entry['objectclass'] as $objectclass) {
                if (($member_attr = $this->get_group_member_attr(array($objectclass), ''))
                    && ($member_attr = strtolower($member_attr)) && !in_array($member_attr, $attrs)
                ) {
                    $members       = $this->_list_group_members($dn, $entry, $member_attr, $count);
                    $group_members = array_merge($group_members, $members);
                    $attrs[]       = $member_attr;
                }
                else if (!empty($entry['memberurl'])) {
                    $members       = $this->_list_group_memberurl($dn, $entry, $count);
                    $group_members = array_merge($group_members, $members);
                }

                if ($this->prop['sizelimit'] && count($group_members) > $this->prop['sizelimit']) {
                    break 2;
                }
            }
        }

        return array_filter($group_members);
    }
631750
function user_all_groups($username, $groups_filtering = '') {
        if ($username==NULL){ return (false); }
        if (!$this->_bind){ return (false); }
        $filter = "(&(objectCategory=group)(member:1.2.840.113556.1.4.1941:=".$username.")".$groups_filtering.")";
        // $fields = array($this->_group_cn_identifier,$this->_group_attribute,"distinguishedname");
        $fields = array("cn");
        $sr = ldap_search($this->_conn,$this->_base_dn,$filter, $fields);
        $group_entries = $this->rCountRemover(ldap_get_entries($this->_conn, $sr));

//echo "DEBUG: info group_entries\n";
//print_r($group_entries);
        
        $group_array = array();
        foreach ($group_entries as $group_entry) {
            $group_array[] = $group_entry['cn'][0];
        }
//echo "DEBUG: group_array\n";
//print_r($group_array);

        return ($group_array);
    }
777107
public function getGroup($group)
    {
        $timeStamp = time();
        if ($group instanceof BundleEntity\MemberGroup) {
            return new ModelResponse($group, 1, 0, null, false, 'S:D:002', 'Entries successfully fetched from database.', $timeStamp, time());
        }
        $result = null;
        switch ($group) {
            case is_numeric($group):
                $result = $this->em->getRepository($this->entity['mg']['name'])->findOneBy(array('id' => $group));
                break;
            case is_string($group):
                $result = $this->em->getRepository($this->entity['mg']['name'])->findOneBy(array('code' => $group));
                break;
        }
        if (is_null($result)) {
            return new ModelResponse($result, 0, 0, null, true, 'E:D:002', 'Unable to find request entry in database.', $timeStamp, time());
        }

        return new ModelResponse($result, 1, 0, null, false, 'S:D:002', 'Entries successfully fetched from database.', $timeStamp, time());
    }
993812
public function getAllUsers($count=1000, $offset=0, $searchToken=null) {
        global $logger;
        $path    = 'users';
        $request = $this->_remoteServer->get($path);
        if(!empty($searchToken)) {
            $request->getQuery()->set('searchToken', $searchToken);
        }
        $request->getQuery()->set('numUsers', $count);
        $request->getQuery()->set('offset', $offset);
        try {
            $response = $request->send();
        } catch(\Guzzle\Http\Exception\BadResponseException $e) {
            $logger->info($e->getResponse()->getBody('true'), array());
            return false;
        }

        return $response->json();
    }
172799
protected function getGroupsCount() {
    // There is no unpublished option for groups.
    $query = $this->connection->select('groups', 'g');
    $query->addExpression('COUNT(*)');
    return $query->execute()->fetchField();
  }
969118
protected function getGroupByKey( $group, $key, $value )
    {
        if ( !is_string( $group ) && is_callable( $group ) )
        {
            return $group( $value, $key );
        }

        return Util::dataGet( $value, $group );
    }
236977
def group_members(self, group, limit=99999):
        
        url = 'rest/api/1.0/admin/groups/more-members'
        params = {}
        if limit:
            params['limit'] = limit
        if group:
            params['context'] = group
        return (self.get(url, params=params) or {}).get('values')
1050472
function getGroup(name, done) {
  return getModels(function(m) {
    return m.collections.group.findOne({ name })
      .populate("members").populate("leaders").exec(done);
  });
}
987503
public static function getClientCountByGroup($group = '')
    {
        $gateway_data             = GatewayProtocol::$empty;
        $gateway_data['cmd']      = GatewayProtocol::CMD_GET_CLIENT_COUNT_BY_GROUP;
        $gateway_data['ext_data'] = $group;
        $total_count              = 0;
        $all_buffer_array         = self::getBufferFromAllGateway($gateway_data);
        foreach ($all_buffer_array as $local_ip => $buffer_array) {
            foreach ($buffer_array as $local_port => $count) {
                if ($count) {
                    $total_count += $count;
                }
            }
        }
        return $total_count;
    }
47758
private Collection<Membership> findMembershipsByGroup(Session session, Group group) throws Exception
   {
      Node groupNode;
      NodeIterator refUsers;
      try
      {
         groupNode = utils.getGroupNode(session, group);
         refUsers = groupNode.getNode(JCROrganizationServiceImpl.JOS_MEMBERSHIP).getNodes();
      }
      catch (PathNotFoundException e)
      {
         return new ArrayList<Membership>();
      }

      List<Membership> memberships = new ArrayList<Membership>();
      while (refUsers.hasNext())
      {
         Node refUserNode = refUsers.nextNode();
         memberships.addAll(findMembershipsByUserAndGroup(session, refUserNode, groupNode));
      }

      return memberships;
   }
691717
public function isMemberOf($group)
    {
        if ($group == 'everyone') {
            return true;
        }

        return GroupMember::where('group', $group)
            ->where('user_id', $this->id())
            ->count() == 1;
    }
1363200
public function addGroup($group)
    {
        if (is_string($group)) {
            // If the group is a string, we'll assume the dev is passing
            // in a DN string of the group. We'll try to locate it.
            $group = $this->query->newInstance()->findByDn($group);
        }

        if ($group instanceof Group) {
            // If the group is Group model instance, we can
            // add the current models DN to the group.
            return $group->addMember($this->getDn());
        }

        return false;
    }
283482
protected function checkGroup($userdn, $groupdn) 
	{	
		$members = $this->getMembers($userdn);

		if ($members == NULL) 
			return FALSE;

		for ($i = 0; $i < $members['count']; $i++) 
		{
			if ($groupdn == $members[$i])
				return TRUE;
			elseif ($this->checkGroup($members[$i], $groupdn)) 
				return TRUE; 
		}

		return FALSE;
	}
100498
private Collection<Group> findGroups(Session session, Group parent, boolean recursive) throws Exception
   {
      List<Group> groups = new ArrayList<Group>();
      String parentId = parent == null ? "" : parent.getId();

      NodeIterator childNodes = utils.getGroupNode(session, parentId).getNodes();

      while (childNodes.hasNext())
      {
         Node groupNode = childNodes.nextNode();
         if (!groupNode.getName().startsWith(JCROrganizationServiceImpl.JOS_MEMBERSHIP))
         {
            Group group = readGroup(groupNode);
            groups.add(group);

            if (recursive)
            {
               groups.addAll(findGroups(session, group, recursive));
            }
         }
      }

      return groups;
   }
1084505
function group_add_group($parent,$child){

        //find the parent group's dn
        $parent_group=$this->group_info($parent,array("cn"));
        if ($parent_group[0]["dn"]==NULL){ return (false); }
        $parent_dn=$parent_group[0]["dn"];
        
        //find the child group's dn
        $child_group=$this->group_info($child,array("cn"));
        if ($child_group[0]["dn"]==NULL){ return (false); }
        $child_dn=$child_group[0]["dn"];
                
        $add=array();
        $add["member"] = $child_dn;
        
        $result=@ldap_mod_add($this->_conn,$parent_dn,$add);
        if ($result==false){ return (false); }
        return (true);
    }
84214
protected function findAccountsForGroupUsingAccountAttribute(Entity\GroupNode $group)
    {
        $findValue = $group->getDn();

        switch ($this->getConfiguration()->getAccountMembershipAttribute()) {
            case Enum\AccountMembershipMappingType::NAME:
                $findValue = $group->getName();
                break;
        }

        return $this->searchNodes(
            $this->buildFilter(
                new Filter\StringFilter($this->getConfiguration()->getAccountMembershipAttribute() . '=' . Filter\AbstractFilter::escapeValue($findValue))
            )
        );
    }
14671
public function count_teams($activitygroup = 0) {

        $count = 0;

        $participants = $this->list_participants($activitygroup, true);

        // If a team submission grouping id is provided all good as all returned groups
        // are the submission teams, but if no team submission grouping was specified
        // $groups will contain all participants groups.
        if ($this->get_instance()->teamsubmissiongroupingid) {

            // We restrict the users to the selected group ones.
            $groups = groups_get_all_groups($this->get_course()->id,
                                            array_keys($participants),
                                            $this->get_instance()->teamsubmissiongroupingid,
                                            'DISTINCT g.id, g.name');

            $count = count($groups);

            // When a specific group is selected we don't count the default group users.
            if ($activitygroup == 0) {
                if (empty($this->get_instance()->preventsubmissionnotingroup)) {
                    // See if there are any users in the default group.
                    $defaultusers = $this->get_submission_group_members(0, true);
                    if (count($defaultusers) > 0) {
                        $count += 1;
                    }
                }
            } else if ($activitygroup != 0 && empty($groups)) {
                // Set count to 1 if $groups returns empty.
                // It means the group is not part of $this->get_instance()->teamsubmissiongroupingid.
                $count = 1;
            }
        } else {
            // It is faster to loop around participants if no grouping was specified.
            $groups = array();
            foreach ($participants as $participant) {
                if ($group = $this->get_submission_group($participant->id)) {
                    $groups[$group->id] = true;
                } else if (empty($this->get_instance()->preventsubmissionnotingroup)) {
                    $groups[0] = true;
                }
            }

            $count = count($groups);
        }

        return $count;
    }