Add user to group.
421216
def user_add_to_group_action(model, request):
    
    group_id = request.params.get('id')
    if not group_id:
        group_ids = request.params.getall('id[]')
    else:
        group_ids = [group_id]
    try:
        user = model.model
        validate_add_users_to_groups(model, [user.id], group_ids)
        groups = user.root.groups
        for group_id in group_ids:
            groups[group_id].add(user.name)
        groups()
        model.parent.invalidate(user.name)
        localizer = get_localizer(request)
        message = localizer.translate(_(
            'added_user_to_group',
            default="Added user '${uid}' to group '${gid}'.",
            mapping={
                'uid': user.id,
                'gid': ', '.join(group_ids)
            }
        ))
        return {
            'success': True,
            'message': message
        }
    except ManageMembershipError as e:
        if e.reason is not LM_TARGET_GID_NOT_ALLOWED:
            raise Exception(u"Unknown ManageMembershipError reason.")
        localizer = get_localizer(request)
        message = localizer.translate(_(
            'lm_add_target_gid_not_allowed',
            default=(
                "Failed adding user '${uid}' to group '${gid}'. "
                "Manage membership denied for target group."
            ),
            mapping={
                'uid': user.id,
                'gid': e.data
            }
        ))
        return {
            'success': False,
            'message': message
        }
    except Exception as e:
        return {
            'success': False,
            'message': str(e)
        }
950049
def add_group(group, user=None):
    
    user = get_user(user)

    if user is None:
        raise ValueError("User '{}' not found".format(repr(user)))

    if isinstance(group, basestring):
        group = [group]
    elif isinstance(group, GroupData):
        group = [group]

    portal_groups = get_tool("portal_groups")
    for group in map(get_group, group):
        if group is None:
            continue
        portal_groups.addPrincipalToGroup(get_user_id(user), group.getId())

    return get_groups(user)
517783
def create_user(name, groups=None, key_file=None):
    """"""

    groups = groups or []
    if not user_exists(name):
        for group in groups:
            if not group_exists(group):
                sudo(u"addgroup %s" % group)
        groups = groups and u'-G %s' % u','.join(groups) or ''
        sudo(u"useradd -m %s -s /bin/bash %s" % (groups, name))
        sudo(u"passwd -d %s" % name)
    if key_file:
        sudo(u"mkdir -p /home/%s/.ssh" % name)
        put(key_file, u"/home/%s/.ssh/authorized_keys" % name, use_sudo=True)
        sudo(u"chown -R %(name)s:%(name)s /home/%(name)s/.ssh" % {'name': name})
1241109
def adduser(app, username, password):
    """"""
    with app.app_context():
        create_user(username=username, password=password)
        click.echo('user created!')
163960
def add_group_users(user_ids)
      raise 'Attempted to add a user to a non-group channel!' unless group?

      user_ids = [user_ids] unless user_ids.is_a? Array
      user_ids.each do |user_id|
        API::Channel.add_group_user(@bot.token, @id, user_id.resolve_id)
      end
      self
    end
876953
def groups_create(self, name, **kwargs):
        """"""
        return self.__call_api_post('groups.create', name=name, kwargs=kwargs)
504141
def addUsersToGroup(self, user_ids, thread_id=None):
        
        thread_id, thread_type = self._getThread(thread_id, None)
        data = self._getSendData(thread_id=thread_id, thread_type=ThreadType.GROUP)

        data["action_type"] = "ma-type:log-message"
        data["log_message_type"] = "log:subscribe"

        user_ids = require_list(user_ids)

        for i, user_id in enumerate(user_ids):
            if user_id == self._uid:
                raise FBchatUserError(
                    "Error when adding users: Cannot add self to group thread"
                )
            else:
                data[
                    "log_message_data[added_participants][{}]".format(i)
                ] = "fbid:{}".format(user_id)

        return self._doSendRequest(data)
532162
public void addUser(String userName, String userRealm, char[] password, String... groups) {
      if (userName == null) {
         throw new IllegalArgumentException("userName is null");
      }
      if (userRealm == null) {
         throw new IllegalArgumentException("userRealm is null");
      }
      if (password == null) {
         throw new IllegalArgumentException("password is null");
      }
      final String canonUserRealm = userRealm.toLowerCase().trim();
      final String canonUserName = userName.toLowerCase().trim();
      synchronized (map) {
         Map<String, Entry> realmMap = map.get(canonUserRealm);
         if (realmMap == null) {
            realmMap = new HashMap<String, Entry>();
            map.put(canonUserRealm, realmMap);
         }
         realmMap.put(canonUserName, new Entry(canonUserName, canonUserRealm, password, groups != null ? groups : new String[0]));
      }
   }
1180323
def add(self, item, group_by=None):
        """"""
        key = None

        if not group_by:
            group_by = self.group_by

        if group_by:
            # if group_by is a function, use it with item as argument
            if hasattr(group_by, '__call__'):
                key = group_by(item)

            # if the item has attribute of group_by as string, use that as key
            elif isinstance(group_by, str) and hasattr(item, group_by):
                key = getattr(item, group_by)

            else:
                key = None
                # try to match str(item) with regular expression
                if isinstance(group_by, str):
                    match = re.search(group_by, str(item))
                    if match:
                        if len(match.groups()) > 0:
                            key = match.group(1)
                        else:
                            key = match.group()

        self.groups.setdefault(key, list()).append(item)
514112
def cli(ctx, group, user):
    
    return ctx.gi.users.add_to_group(group, user)
362022
def add_to_groups(self, username, groups):
        
        self._check_fix_users(username)
        current_groups = self.users[username]['groups']
        new_groups = current_groups | set(groups)
        self.users[username]['groups'] = new_groups
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)
776356
def add_member(user, group)
      relation = group.group_member_relations.find_or_initialize_by(user: user, accepted_at: nil)
      relation.accepted_at = Time.now
      relation.accepter = self
      relation.save
    end
495248
def add_users(self, category):
        """"""
        mapping = {'banned': 'ban', 'contributor': 'make_contributor',
                   'moderator': 'make_moderator'}

        if category not in mapping:
            print('{!r} is not a valid option for --add'.format(category))
            return
        func = getattr(self.sub, mapping[category])
        print('Enter user names (any separation should suffice):')
        data = sys.stdin.read().strip()
        for name in re.split('[^A-Za-z0-9_]+', data):
            func(name)
            print('Added {!r} to {}'.format(name, category))
87526
public function addUserToUGroup()
    {
        $aAddUsers = $this->_getActionIds('oxuser.oxid');
        $soxId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('synchoxid');

        if (\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('all')) {
            $sUserTable = $this->_getViewName('oxuser');
            $aAddUsers = $this->_getAll($this->_addFilter("select $sUserTable.oxid " . $this->_getQuery()));
        }
        if ($soxId && $soxId != "-1" && is_array($aAddUsers)) {
            foreach ($aAddUsers as $sAdduser) {
                $oNewGroup = oxNew(\OxidEsales\Eshop\Application\Model\Object2Group::class);
                $oNewGroup->oxobject2group__oxobjectid = new \OxidEsales\Eshop\Core\Field($sAdduser);
                $oNewGroup->oxobject2group__oxgroupsid = new \OxidEsales\Eshop\Core\Field($soxId);
                $oNewGroup->save();
            }
        }
    }
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)
804225
def ib_group_member_add(self, group_id, userids):
        '''  '''
        req_hook = 'pod/v1/admin/group/' + group_id + '/membership/add'
        req_args = {'usersListId': userids}
        req_args = json.dumps(req_args)
        status_code, response = self.__rest__.POST_query(req_hook, req_args)
        self.logger.debug('%s: %s' % (status_code, response))
        return status_code, response