Get a list of groups associated to a user.

        :param user_name:  name of user to list groups
        :returns: list of groups
        :raises: HTTPResponseError in case an HTTP error status was returned
168460
def get_user_groups(self, user_name):
        

        res = self._make_ocs_request(
            'GET',
            self.OCS_SERVICE_CLOUD,
            'users/' + user_name + '/groups',
        )

        if res.status_code == 200:
            tree = ET.fromstring(res.content)
            self._check_ocs_status(tree, [100])
            return [group.text for group in tree.find('data/groups')]

        raise HTTPResponseError(res)
407795
def list_users(self, user=None):
    '''
    ''' 
    from expfactory.database.models import Participant
    participants = Participant.query.all()
    users = []
    for user in participants:
        users.append(self.print_user(user))
    return users
1322115
def get_groups(self, username):
        """"""
        username = ldap.filter.escape_filter_chars(self._byte_p2(username))
        userdn = self._get_user(username, NO_ATTR)

        searchfilter = self.group_filter_tmpl % {
            'userdn': userdn,
            'username': username
        }

        groups = self._search(searchfilter, NO_ATTR, self.groupdn)
        ret = []
        for entry in groups:
            ret.append(self._uni(entry[0]))
        return ret
64995
def _get_roles(self, username):
        
        groups = self._get_groups(username)
        user_roles = self.roles.get_roles(groups)
        cherrypy.log.error(
            msg="user '" + username + "' roles: " + str(user_roles),
            severity=logging.DEBUG,
        )
        return user_roles
366039
def group_members(self, group):
        
        if self._version < (6, 0, 0):
            raise NotImplementedError(
                "Group members is not implemented in JIRA before version 6.0, upgrade the instance, if possible.")

        params = {'groupname': group, 'expand': "users"}
        r = self._get_json('group', params=params)
        size = r['users']['size']
        end_index = r['users']['end-index']

        while end_index < size - 1:
            params = {'groupname': group, 'expand': "users[%s:%s]" % (
                end_index + 1, end_index + 50)}
            r2 = self._get_json('group', params=params)
            for user in r2['users']['items']:
                r['users']['items'].append(user)
            end_index = r2['users']['end-index']
            size = r['users']['size']

        result = {}
        for user in r['users']['items']:
            result[user['key']] = {'name': user['name'],
                                   'fullname': user['displayName'],
                                   'email': user.get('emailAddress', 'hidden'),
                                   'active': user['active']}
        return OrderedDict(sorted(result.items(), key=lambda t: t[0]))
715157
def get_mentions(status_dict, exclude=[]):
    
    # Canonicalise the exclusion dictionary by lowercasing all names and
    # removing leading @'s
    for i, user in enumerate(exclude):
        user = user.casefold()
        if user[0] == "@":
            user = user[1:]

        exclude[i] = user

    users = [user["username"] for user in status_dict["mentions"]
             if user["username"].casefold() not in exclude]
    return users
1271044
def user_names_like(cls, user_name, db_session=None):
        
        db_session = get_db_session(db_session)
        query = db_session.query(cls.model)
        query = query.filter(
            sa.func.lower(cls.model.user_name).like((user_name or "").lower())
        )
        query = query.order_by(cls.model.user_name)
        # q = q.options(sa.orm.eagerload('groups'))
        return query
686605
def searchusers(self, pattern):
        
        return [User(self, **rawuser) for rawuser in
                self._getusers(match=pattern).get('users', [])]
120120
def add_user_to_group(self, user_name, group_name):
        

        res = self._make_ocs_request(
            'POST',
            self.OCS_SERVICE_CLOUD,
            'users/' + user_name + '/groups',
            data={'groupid': group_name}
        )

        if res.status_code == 200:
            tree = ET.fromstring(res.content)
            self._check_ocs_status(tree, [100])
            return True

        raise HTTPResponseError(res)
348338
def get_groups(user=None):
    
    portal_groups = get_tool("portal_groups")
    user = get_user(user)
    if user is None:
        return []
    return portal_groups.getGroupsForPrincipal(user)
816181
def usergroups_users_list(self, *, usergroup: str, **kwargs) -> SlackResponse:
        
        self._validate_xoxp_token()
        kwargs.update({"usergroup": usergroup})
        return self.api_call("usergroups.users.list", http_verb="GET", params=kwargs)
1184398
def list_groups(region=None, key=None, keyid=None, profile=None):
    '''
    

    '''
    return [a.name for a in get_all_groups(region=region, key=key, keyid=keyid, profile=profile)]
673654
def get_group_members(group_name, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    try:
        marker = None
        truncated = True
        users = []
        while truncated:
            info = conn.get_group(group_name, marker=marker, max_items=1000)
            if not info:
                return False
            truncated = bool(info['get_group_response']['get_group_result']['is_truncated'])
            if truncated and 'marker' in info['get_group_response']['get_group_result']:
                marker = info['get_group_response']['get_group_result']['marker']
            else:
                marker = None
                truncated = False
            users += info['get_group_response']['get_group_result']['users']
        return users
    except boto.exception.BotoServerError as e:
        log.debug(e)
        log.error('Failed to get members for IAM group %s.', group_name)
        return False
1236970
def get_members_of_group(self, gname):
        
        contactgroup = self.find_by_name(gname)
        if contactgroup:
            return contactgroup.get_contacts()
        return []
922860
def add_user_to_group(self, username, group_name):
        
        url = 'rest/api/2/group/user'
        params = {'groupname': group_name}
        data = {'name': username}

        return self.post(url, params=params, data=data)
303719
def get_group(self, name, default=NoGroupError):
        '''
        
        '''

        if name in self.groups:
            return self.groups[name]

        if default is NoGroupError:
            raise NoGroupError('No such group: {0}'.format(name))

        return default
240102
def get_members_of_group(self, gname):
        
        hostgroup = self.find_by_name(gname)
        if hostgroup:
            return hostgroup.get_services()
        return []