This will get all explicitly assigned users for a project, as well as all users who are assigned to groups that are explicitly assigned to a project.
967339
public Set<UserView> getAllActiveUsersForProject(ProjectView projectView) throws IntegrationException {
        Set<UserView> users = new HashSet<>();

        List<AssignedUserGroupView> assignedGroups = getAssignedGroupsToProject(projectView);
        for (AssignedUserGroupView assignedUserGroupView : assignedGroups) {
            if (assignedUserGroupView.getActive()) {
                UserGroupView userGroupView = blackDuckService.getResponse(assignedUserGroupView.getGroup(), UserGroupView.class);
                if (userGroupView.getActive()) {
                    List<UserView> groupUsers = blackDuckService.getAllResponses(userGroupView, UserGroupView.USERS_LINK_RESPONSE);
                    users.addAll(groupUsers);
                }
            }
        }

        List<AssignedUserView> assignedUsers = getAssignedUsersToProject(projectView);
        for (AssignedUserView assignedUser : assignedUsers) {
            UserView userView = blackDuckService.getResponse(assignedUser.getUser(), UserView.class);
            users.add(userView);
        }

        return users
                       .stream()
                       .filter(userView -> userView.getActive())
                       .collect(Collectors.toSet());
    }
628189
def get_users_from_project_hours(self, project_hours):
        
        name = ('user__first_name', 'user__last_name')
        users = project_hours.values_list('user__id', *name).distinct()\
                             .order_by(*name)
        return users
932437
def group_memberships_assignable(self, group_id, **kwargs):
        ""
        api_path = "/api/v2/groups/{group_id}/memberships/assignable.json"
        api_path = api_path.format(group_id=group_id)
        return self.call(api_path, **kwargs)
1358778
def get_project_ids(self):
        
        user = self.request.user
        projects = Project.objects.accessible_to(user).values('id')
        return [p['id'] for p in projects]
363994
def _gather_group_members(group, groups, users):
    '''
    
    '''
    _group = __salt__['group.info'](group)

    if not _group:
        log.warning('Group %s does not exist, ignoring.', group)
        return

    for member in _group['members']:
        if member not in users:
            users[member] = groups[group]
943624
def user_in_any_group(user, groups):
    """"""
    return user_is_superuser(user) or any(user_in_group(user, group) for group in groups)
1307271
def all_project_administrators(self):
        
        for project in self.project_list():
            log.info('Processing project: {0} - {1}'.format(project.get('key'), project.get('name')))
            yield {
                'project_key': project.get('key'),
                'project_name': project.get('name'),
                'project_administrators': [{'email': x['emailAddress'], 'name': x['displayName']}
                                           for x in self.project_users_with_administrator_permissions(project['key'])]}
182616
def users(self):
        
        existing_users = self.existing_users()
        existing_user_ids = [x['id'] for x in existing_users]

        # Only add search results that are not already members
        sharing = getMultiAdapter((self.my_workspace(), self.request),
                                  name='sharing')
        search_results = sharing.user_search_results()
        users = existing_users + [x for x in search_results
                                  if x['id'] not in existing_user_ids]

        users.sort(key=lambda x: safe_unicode(x["title"]))
        return users
92802
def fetchAllUsers(self, rawResults = False) :
        """"""
        r = self.connection.session.get(self.URL)
        if r.status_code == 200 :
            data = r.json()
            if rawResults :
                return data["result"]
            else :
                res = []
                for resu in data["result"] :
                    u = User(self, resu)
                    res.append(u)
                return res
        else :
            raise ConnectionError("Unable to get user list", r.url, r.status_code)
913550
def get_users(self, fetch=True):
        """"""
        return Users(self.resource.users, self.client, populate=fetch)
390806
public function getGroups()
	{
		if ( ! $this->userGroups)
		{
			$this->userGroups = $this->groups->find_all();
		}

		return $this->userGroups;
	}
1088463
private function get_groups_all() {
        if (is_null($this->groups)) {
            // NOTE: Performance could be improved here. The system caches user groups
            // in $USER->groupmember[$courseid] => array of groupid=>groupid. Unfortunately this
            // structure does not include grouping information. It probably could be changed to
            // do so, without a significant performance hit on login, thus saving this one query
            // each request.
            $this->groups = groups_get_user_groups($this->course->id, $this->userid);
        }
        return $this->groups;
    }
647576
def groupfinder(userid, request):
    
    if userid and hasattr(request, "user") and request.user:
        groups = ["group:%s" % g.id for g in request.user.groups]
        return groups
    return []
334726
protected function assignGroupsToAssignment()
    {
        $assignment = fp_env('ACACHA_FORGE_ASSIGNMENT');
        foreach ( $this->groups as $group) {
            $uri = str_replace('{assignment}', $assignment, config('forge-publish.assign_group_to_assignment_uri'));
            $uri = str_replace('{group}', $group, $uri);
            $url = config('forge-publish.url') . $uri;
            try {
                $response = $this->http->post($url, [
                    'headers' => [
                        'X-Requested-With' => 'XMLHttpRequest',
                        'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN')
                    ]
                ]);
            } catch (\Exception $e) {
                if ($e->getResponse()->getStatusCode() == 422) {
                    $this->error('The group is already assigned');
                    return;
                }
                $this->error('And error occurs connecting to the api url: ' . $url);
                $this->error('Status code: ' . $e->getResponse()->getStatusCode() . ' | Reason : ' . $e->getResponse()->getReasonPhrase());
                return [];
            }
        }
    }
497146
def assignees(self):
        """"""
        if 'assignees' in self._json_data and self._json_data.get('assignees_ids') == list():
            return []
        elif 'assignees' in self._json_data and self._json_data.get('assignees_ids'):
            assignees_ids_str = ','.join([str(id) for id in self._json_data.get('assignees_ids')])
            return self._client.users(id__in=assignees_ids_str, is_hidden=False)
        return None
425566
def users(self):
        
        if not self.__users:
            self.__users = Users(self.__connection)
        return self.__users
732921
def api_get_project_members(request, key=None, hproPk=True):
    """"""

    if not check_api_key(request, key, hproPk):
        return HttpResponseForbidden

    if settings.PIAPI_STANDALONE:
        if not settings.PIAPI_REALUSERS:
            users = [generate_user(pk="-1"), generate_user(pk="-2"), generate_user(pk="-3")]
        else:
            users = DUser.object.all()
    else:

        (_, _, hproject) = getPlugItObject(hproPk)

        users = []

        for u in hproject.getMembers():
            u.ebuio_member = True
            u.ebuio_admin = hproject.isMemberWrite(u)
            u.subscription_labels = _get_subscription_labels(u, hproject)
            users.append(u)

    liste = []

    for u in users:

        retour = {}

        for prop in settings.PIAPI_USERDATA:
            if hasattr(u, prop):
                retour[prop] = getattr(u, prop)

        retour['id'] = str(retour['pk'])

        liste.append(retour)

    return HttpResponse(json.dumps({'members': liste}), content_type="application/json")