Get a user's groups

        :param username: 'key' attribute of the user
        :type username: string
        :rtype: list of groups
322235
def get_groups(self, username):
        
        try:
            return self.users[username]['groups']
        except Exception as e:
            raise UserDoesntExist(username, self.backend_name)
599995
def list_group_members(self, name):
        
        return self.service.list_group_members(
            name, self.url_prefix, self.auth, self.session,
            self.session_send_opts)
265524
def get_groups(self, load):
        '''
        
        '''
        if 'eauth' not in load:
            return False
        fstr = '{0}.groups'.format(load['eauth'])
        if fstr not in self.auth:
            return False
        fcall = salt.utils.args.format_call(
            self.auth[fstr],
            load,
            expected_extra_kws=AUTH_INTERNAL_KEYWORDS)
        try:
            return self.auth[fstr](*fcall['args'], **fcall['kwargs'])
        except IndexError:
            return False
        except Exception:
            return None
402846
def get_groups_by_userid(cls, userid, request):
        
        try:
            cache_request_user(cls, request, userid)
        except Exception as ex:
            log.error(str(ex))
            forget(request)
        else:
            if request._user:
                return ['g:%s' % g for g in request._user.groups]
625675
def get_user_by_username(self, username):
        
        results = self.get_users(filter='username eq "%s"' % (username))
        if results['totalResults'] == 0:
            logging.warning("Found no matches for given username.")
            return
        elif results['totalResults'] > 1:
            logging.warning("Found %s matches for username %s" %
                (results['totalResults'], username))

        return results['resources'][0]
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)
565965
def _get_user(self, username):
        
        if username is None:
            return {}
        ret = {}
        for b in self.backends:
            try:
                tmp = self.backends[b].get_user(username)
            except UserDoesntExist as e:
                self._handle_exception(e)
                tmp = {}
            self._merge_user_attrs(tmp, ret, b)

        cherrypy.log.error(
            msg="user '" + username + "' attributes " + str(ret),
            severity=logging.DEBUG
        )
        return ret
669805
def get_usernames_like(username,**kwargs):
    
    checkname = "%%%s%%"%username
    rs = db.DBSession.query(User.username).filter(User.username.like(checkname)).all()
    return [r.username for r in rs]
1342931
def _get_user_groups(session, user_id, filter):
        
        return session.fetch_items('groups.get', Group.from_json, count=1000, user_id=user_id, filter=filter, extended=1, fields=",".join(Group.GROUP_FIELDS))
71752
def _get_groups(self):
        
        if self._groups is None:
            self._groups = _LDAPUserGroups(self)

        return self._groups
1119936
def check_membership(self, groups):
        '''  '''
        if not groups or groups == ['']:
            return True
        if self.request.user.is_superuser:
            return True
        user_groups = self.request.user.groups.values_list("name", flat=True)
        return set(groups).intersection(set(user_groups))
495416
def usergroups_list(self, **kwargs) -> SlackResponse:
        """"""
        self._validate_xoxp_token()
        return self.api_call("usergroups.list", http_verb="GET", params=kwargs)
657626
private function getGroups($username)
    {
        if (!$this->entityManager) {
            return [];
        }

        $db = $this->entityManager->getConnection();
        $queryBuilder = $db->createQueryBuilder();

        $rows = $queryBuilder
            ->select('g.gName', 'u.uID')->from($db->getDatabasePlatform()->quoteSingleIdentifier('Groups'), 'g')
            ->leftJoin('g', 'UserGroups', 'ug', 'ug.gID=g.gID')
            ->innerJoin('ug', 'Users', 'u', 'ug.uID=u.uID AND (u.uName=? OR u.uEmail=?)')
            ->setParameters([$username, $username])
            ->execute();

        $groups = [];
        $uID = 0;
        foreach ($rows as $row) {
            $uID = (int) $row['uID'];
            $groups[] = $row['gName'];
        }

        if ($uID == USER_SUPER_ID) {
            $groups[] = 'SUPER';
        }

        return $groups;
    }
32258
def get_user_group_list(self, steamID, format=None):
        
        parameters = {'steamid' : steamID}
        if format is not None:
            parameters['format'] = format
        url = self.create_request_url(self.interface, 'GetUserGroupList', 1,
            parameters)
        data = self.retrieve_request(url)
        return self.return_data(data, format=format)
167533
def get_user(self, username):
        
        User = get_user_model()  # noqa
        try:
            user = User.objects.get(**{
                User.USERNAME_FIELD: username,
                'is_active': False
            })
            return user
        except User.DoesNotExist:
            return None
619835
def get_user(self, username):
        

        response = self._get(self.rest_url + "/user",
                             params={"username": username,
                                     "expand": "attributes"})

        if not response.ok:
            return None

        return response.json()
283059
def get_groupnames(self, hostgroups):
        
        group_names = []
        for hostgroup_id in self.hostgroups:
            hostgroup = hostgroups[hostgroup_id]
            group_names.append(hostgroup.get_name())
        return ','.join(sorted(group_names))