`login` - Login or username of user to add to `role`
        `role` - Role to add user to

        Add user to role
5124
def role_add(self, role=None, login=None, envs=[], query='/roles/'):
        
        data = {'login': self.args.login}
        juicer.utils.Log.log_debug(
                "Add Role '%s' to '%s'", role, login)

        for env in self.args.envs:
            if not juicer.utils.role_exists_p(role, self.connectors[env]):
                juicer.utils.Log.log_info("role `%s` doesn't exist in %s... skipping!",
                                          (role, env))
                continue
            elif not juicer.utils.user_exists_p(login, self.connectors[env]):
                juicer.utils.Log.log_info("user `%s` doesn't exist in %s... skipping!",
                                          (login, env))
            else:
                url = "%s%s/users/" % (query, role)
                _r = self.connectors[env].post(url, data)
                if _r.status_code == Constants.PULP_POST_OK:
                    juicer.utils.Log.log_info("added user `%s` to role `%s` in %s",
                                              (login, role, env))
                else:
                    _r.raise_for_status()
        return True
324215
def login(self, login, password, set_auth=False):
        
        rv = self.session.post(
            self.host,
            dumps({
                "method": "common.db.login",
                "params": [login, password]
            }),
        )
        rv = loads(rv.content)['result']
        if set_auth:
            self.set_auth(
                SessionAuth(login, *rv)
            )
        return rv
1104194
def add(self, roles):
        
        return self._client.post(
            url=self._client.get_full_url(
                self.get_path(
                    'single', realm=self._realm_name, id=self._user_id
                )
            ),
            data=json.dumps(roles, sort_keys=True)
        )
1220067
def add_collaborator(self, login):
        
        resp = False
        if login:
            url = self._build_url('collaborators', login, base_url=self._api)
            resp = self._boolean(self._put(url), 204, 404)
        return resp
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!"}
1173659
def add_user(self, name, password=None, read_only=None, db=None, **kwargs):
        
        if db is None:
            return self.get_connection().admin.add_user(
                    name, password=password, read_only=read_only, **kwargs)
        return self.get_connection()[db].add_user(
                    name, password=password, read_only=read_only, **kwargs)
717231
def roles_add(user, role):
    """"""
    user, role = _datastore._prepare_role_modify_args(user, role)
    if user is None:
        raise click.UsageError('Cannot find user.')
    if role is None:
        raise click.UsageError('Cannot find role.')
    if _datastore.add_role_to_user(user, role):
        click.secho('Role "{0}" added to user "{1}" '
                    'successfully.'.format(role, user), fg='green')
    else:
        raise click.UsageError('Cannot add role to user.')
926007
def set_user(self, user):
        
        self.session['user_id'] = user.key
        self.session['user_data'] = user.clean_value()
        role = self.get_role()
        # TODO: this should be remembered from previous login
        # self.session['role_data'] = default_role.clean_value()
        self.session['role_id'] = role.key
        self.current.role_id = role.key
        self.current.user_id = user.key
        # self.perm_cache = PermissionCache(role.key)
        self.session['permissions'] = role.get_permissions()
1003864
def set_role(username, role):
    '''
    
    '''
    try:
        sendline('config terminal')
        role_line = 'username {0} role {1}'.format(username, role)
        ret = sendline(role_line)
        sendline('end')
        sendline('copy running-config startup-config')
        return '\n'.join([role_line, ret])
    except TerminalException as e:
        log.error(e)
        return 'Failed to set password'
618904
def role_add(user, role):
    '''
    
    '''
    ret = {}

    ## validate roles
    roles = role.split(',')
    known_roles = role_list().keys()
    valid_roles = [r for r in roles if r in known_roles]
    log.debug(
        'rbac.role_add - roles=%s, known_roles=%s, valid_roles=%s',
        roles,
        known_roles,
        valid_roles,
    )

    ## update user roles
    if valid_roles:
        res = __salt__['cmd.run_all']('usermod -R "{roles}" {login}'.format(
            login=user,
            roles=','.join(set(role_get(user) + valid_roles)),
        ))
        if res['retcode'] > 0:
            ret['Error'] = {
                'retcode': res['retcode'],
                'message': res['stderr'] if 'stderr' in res else res['stdout']
            }
            return ret

    ## update return value
    active_roles = role_get(user)
    for r in roles:
        if r not in valid_roles:
            ret[r] = 'Unknown'
        elif r in active_roles:
            ret[r] = 'Added'
        else:
            ret[r] = 'Failed'

    return ret
887989
def get_roles(username, **kwargs):
    '''
    
    '''
    user = get_user(username)
    if not user:
        return []
    command = 'show user-account {0}'.format(username)
    info = ''
    info = show(command, **kwargs)
    if isinstance(info, list):
        info = info[0]
    roles = re.search(r'^\s*roles:(.*)$', info, re.MULTILINE)
    if roles:
        roles = roles.group(1).strip().split(' ')
    else:
        roles = []
    return roles
588300
def assign_role(backend, user, response, *args, **kwargs):
    '''
    
    '''
    if backend.name is 'passthrough' and settings.DEMO is True and 'role' in kwargs['request'].session[passthrough.SESSION_VAR]:
        role = kwargs['request'].session[passthrough.SESSION_VAR]['role']
        if role == 'tutor':
            make_tutor(user)
        if role == 'admin':
            make_admin(user)
        if role == 'owner':
            make_owner(user)
1159144
function (login_id, session, data) {

	// acknowledge as 'logined'	
	l_loginID[login_id] = data.account;
	
	// init session
	session['_account'] = data.account;
	
	// TODO: needs to fix this, should read "groups" from DB
	session['_groups'] = data.groups;
	session['_permissions'] = data.permissions;
	session['lastStatus'] = data.lastStatus;
	
	// TODO: centralize handling of logined users?
	//SR.User.addGroup(user_data.account, ['user', 'admin']);
}
1055987
async def add_user(self, username, password=None, display_name=None):
        
        if not display_name:
            display_name = username
        user_facade = client.UserManagerFacade.from_connection(
            self.connection())
        users = [client.AddUser(display_name=display_name,
                                username=username,
                                password=password)]
        results = await user_facade.AddUser(users)
        secret_key = results.results[0].secret_key
        return await self.get_user(username, secret_key=secret_key)
571480
@CommandArgument
  public void adduser(
      @OptionArgument("username") String username,
      @OptionArgument("password") String password,
      @OptionArgument("roles") String roles) {

    if (users.containsKey(username)) {
      System.err.println(String.format("User '%s' already exists", username));
    } else {

      User user = new User(username);
      user.salt = passwd.generateSalt();
      user.hash = passwd.getEncryptedPassword(password, user.salt);
      user.roles.addAll(Arrays.asList(roles.split(",")));
      users.put(username, user);

    }
  }
705669
def create_role(self, role_name, mount_point='approle', **kwargs):
        

        return self._adapter.post('/v1/auth/{0}/role/{1}'.format(mount_point, role_name), json=kwargs)
7024
function(usernames, rolename) {
    if (_.isEmpty(usernames)) {
      return Promise.reject(new Error('One or more usernames must be provided'));
    }

    if (!_.isArray(usernames)) {
      usernames = [usernames];
    }

    return Role.findOne({
      name: rolename
    }).populate('users').then(function(role) {
      return User.find({
        username: usernames
      }).then(function(users) {
        role.users.add(_.pluck(users, 'id'));
        return role.save();
      });
    });
  }