Return the groups of the user

    :param user: A user id, memberdata object or None for the current user
    :returns: List of groups
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)
293311
def user_list(auth=None, **kwargs):
    '''
    
    '''
    cloud = get_openstack_cloud(auth)
    kwargs = _clean_kwargs(**kwargs)
    return cloud.list_users(**kwargs)
1011810
def get_groups(self, username):
        
        groups = []
        for group in grp.getgrall():
            if username in group.gr_mem:
                groups.append(group.gr_name)

        return groups
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)
975367
def get_members(self, sort='id_asc'):
        
        return self._session.fetch_items("groups.getMembers", User.from_json, 1000, group_id=self.id, sort=sort, fields=User.__slots__ + User.USER_FIELDS)
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]
633571
def get_user_group_perms(user_or_group, obj):
    
    user, group = get_identity(user_or_group)

    if user and not user.is_active:
        return [], []
    user_model = get_user_model()
    ctype = ContentType.objects.get_for_model(obj)

    group_model = get_group_obj_perms_model(obj)
    group_rel_name = group_model.permission.field.related_query_name()
    if user:
        user_rel_name = user_model.groups.field.related_query_name()
        group_filters = {user_rel_name: user}
    else:
        group_filters = {'pk': group.pk}
    if group_model.objects.is_generic():
        group_filters.update({
            '{}__content_type'.format(group_rel_name): ctype,
            '{}__object_pk'.format(group_rel_name): obj.pk,
        })
    else:
        group_filters['{}__content_object'.format(group_rel_name)] = obj

    user_perms, group_perms = [], []

    if user:
        perms_qs = Permission.objects.filter(content_type=ctype)
        if user.is_superuser:
            user_perms = list(chain(perms_qs.values_list("codename", flat=True)))
        else:
            model = get_user_obj_perms_model(obj)
            related_name = model.permission.field.related_query_name()
            user_filters = {'{}__user'.format(related_name): user}
            if model.objects.is_generic():
                user_filters.update({
                    '{}__content_type'.format(related_name): ctype,
                    '{}__object_pk'.format(related_name): obj.pk,
                })
            else:
                user_filters['{}__content_object'.format(related_name)] = obj

            user_perms_qs = perms_qs.filter(**user_filters)
            user_perms = list(chain(user_perms_qs.values_list("codename", flat=True)))

    group_perms_qs = Group.objects.filter(**group_filters)
    group_perms = list(chain(group_perms_qs.order_by("pk").values_list(
        "pk", "name", "{}__permission__codename".format(group_rel_name))))

    group_perms = _group_groups(group_perms)

    return user_perms, group_perms
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')
1250331
def groups(self, user, include=None):
        
        return self._query_zendesk(self.endpoint.groups, 'group', id=user, include=include)
91101
def user_groups(self, ldap_user, group_search):
        
        group_info_map = {}  # Maps group_dn to group_info of groups we've found
        member_dn_set = {ldap_user.dn}  # Member DNs to search with next
        handled_dn_set = set()  # Member DNs that we've already searched with

        while len(member_dn_set) > 0:
            group_infos = self.find_groups_with_any_member(
                member_dn_set, group_search, ldap_user.connection
            )
            new_group_info_map = {info[0]: info for info in group_infos}
            group_info_map.update(new_group_info_map)
            handled_dn_set.update(member_dn_set)

            # Get ready for the next iteration. To avoid cycles, we make sure
            # never to search with the same member DN twice.
            member_dn_set = set(new_group_info_map.keys()) - handled_dn_set

        return group_info_map.values()
418363
def get_group_dict(user=None, include_default=True):
    '''
    
    '''
    if HAS_GRP is False or HAS_PWD is False:
        return {}
    group_dict = {}
    group_names = get_group_list(user, include_default=include_default)
    for group in group_names:
        group_dict.update({group: grp.getgrnam(group).gr_gid})
    return group_dict
282218
def list_users(self, instance, limit=None, marker=None):
        """"""
        return instance.list_users(limit=limit, marker=marker)
702075
def Subgroups(self):
		

		return(Groups(alias=self.alias,groups_lst=self.data['groups'],session=self.session))
789272
def list_users(self):
        
        crypt = self._decrypt_file()

        self.logger.info(crypt.stderr)
        raw_userlist = crypt.stderr.split('\n')
        userlist = list()
        for index, line in enumerate(raw_userlist):
            if 'gpg: encrypted' in line:
                m = re.search('ID (\w+)', line)
                keyid = m.group(1).strip()
                userline = raw_userlist[index+1].strip()
                userlist.append((keyid, userline))
        return userlist
40038
def _UpdateUserGroups(self, user, groups):
    
    groups = ','.join(groups)
    self.logger.debug('Updating user %s with groups %s.', user, groups)
    command = self.usermod_cmd.format(user=user, groups=groups)
    try:
      subprocess.check_call(command.split(' '))
    except subprocess.CalledProcessError as e:
      self.logger.warning('Could not update user %s. %s.', user, str(e))
      return False
    else:
      self.logger.debug('Updated user account %s.', user)
      return True
682493
def get_groups_by_token(cls, username, token, request):
        
        try:
            user = cls.get_item(username=username)
        except Exception as ex:
            log.error(str(ex))
            forget(request)
            return
        else:
            if user and user.api_key.token == token:
                return ['g:%s' % g for g in user.groups]
372991
function getUserGroups(user) {
  try {
    const output = runProgram('groups', [user]).trim();
    const groupsText = isBusyboxCommand('groups') ? output : output.split(':')[1].trim();
    return groupsText.split(/\s+/);
  } catch (e) {
    throw new Error(`Cannot resolve user ${user}`);
  }
}