Add a user to a group
        :param username: The username to assign to the group
        :param groupname: The group name into which to assign the user
        :return: True on success, False on failure.
425127
def add_user_to_group(self, username, groupname, raise_on_error=False):
        
        data = {
                'name': groupname,
        }
        response = self._post(self.rest_url + "/user/group/direct",
                              params={"username": username,},
                              data=json.dumps(data))

        if response.status_code == 201:
            return True

        if raise_on_error:
            raise RuntimeError(response.json()['message'])

        return False
569185
def change_username(self, username):
        
        username = username.lower()
        if self.username != username:
            if self.get_by_username(username):
                raise exceptions.AuthError("Username exists already")
            self.update(username=username)
1165742
def add_account_to_group(self, account, group):
        
        lgroup: OpenldapGroup = self._get_group(group.name)
        person: OpenldapAccount = self._get_account(account.username)

        changes = changeset(lgroup, {})
        changes = lgroup.add_member(changes, person)
        save(changes, database=self._database)
646593
def add_user_to_group(self, user, group_name):
        
        group, _ = Group.objects.get_or_create(name = group_name)
        group.user_set.add(user)
94707
def add_user(self, user_name, role='user'):
        
        role_uri = self._get_role_uri(role=role)
        return self.api.put(path=role_uri, data={'username': user_name})
288920
def change_name(self, username):
        
        self.release_name()

        try:
            self.server.register_name(username)
        except UsernameInUseException:
            logging.log(', '.join(self.server.registered_names))
            self.server.register_name(self.name)
            raise
            
        self.name = username
244416
def CreateGroup(self, GroupName):
        
        groups = self.CustomGroups
        self._DoCommand('CREATE GROUP %s' % tounicode(GroupName))
        for g in self.CustomGroups:
            if g not in groups and g.DisplayName == GroupName:
                return g
        raise SkypeError(0, 'Group creating failed')
637097
def create_user(username, password, **kwargs):
    
    try:
        User = get_model('user')
        user = User.get(User.c.username==username)
        if user:
            return False, {'username':"Username is already existed!"}
        user = User(username=username, password=password, **kwargs)
        user.set_password(password)
        user.save()
        return True, user
    except Exception as e:
        log.exception(e)
        return False, {'_': "Creating user failed!"}
1295924
def add_member(self, username, permissions, api=None):
        
        api = api or self._API
        data = {
            'username': username,
            'permissions': permissions
        }

        response = api.post(
            url=self._URL['members'].format(id=self.id),
            data=data
        )
        data = response.json()
        return Member(api=api, **data)
1087420
def group_add(self, name='Ungrouped'):
        
        if not hasattr(self, name):
            self.__dict__[name] = Group(self, name)
            self.loaded_groups.append(name)
676554
def populate_username(self, request, user):
        
        from .utils import user_username, user_email, user_field
        first_name = user_field(user, 'first_name')
        last_name = user_field(user, 'last_name')
        email = user_email(user)
        username = user_username(user)
        if app_settings.USER_MODEL_USERNAME_FIELD:
            user_username(
                user,
                username or self.generate_unique_username([
                    first_name,
                    last_name,
                    email,
                    username,
                    'user']))
400691
def set_group_name(group, old_name, new_name):
    
    for datastore in _get_datastores():
        datastore.set_group_name(group, old_name, new_name)
621976
def add_user(self, user, group):
        
        if self.is_user_in(user, group):
            raise UserAlreadyInAGroup
        self.new_groups.add(group, user)
1009306
def belongs_to_ldap_group?(username, groupname)
      return false if service.nil?
      group_filter = Net::LDAP::Filter.equals('cn', groupname)
      member_filter = Net::LDAP::Filter.equals('member', "cn=#{username},#{account_tree}")
      entry = service.search(base: tree,
                             filter: group_filter & member_filter,
                             attributes: ['cn'])
      entry.count > 0
    end
1241752
def add_permission(self, role, name):
        
        if self.has_permission(role, name):
            return True
        targetGroup = AuthGroup.objects(role=role, creator=self.client).first()
        if not targetGroup:
            return False
        # Create or update
        permission = AuthPermission.objects(name=name).update(
                add_to_set__groups=[targetGroup], creator=self.client, upsert=True
        )
        return True
1293889
def remove_user_from_group(self, username, group_name):
        
        log.warning('Removing user from a group...')
        url = 'rest/api/2/group/user'
        params = {'groupname': group_name, 'username': username}

        return self.delete(url, params=params)
460030
public void addUsername(String username) {
        SystemAssert.requireArgument(username != null && !username.isEmpty(), "Username cannot be null or empty.");
        this.usernames.add(username);
    }