Operation: Add User Role to User.
776249
def post(method, hmc, uri, uri_parms, body, logon_required,
             wait_for_completion):
        """"""
        assert wait_for_completion is True  # synchronous operation
        user_oid = uri_parms[0]
        user_uri = '/api/users/' + user_oid
        try:
            user = hmc.lookup_by_uri(user_uri)
        except KeyError:
            raise InvalidResourceError(method, uri)
        check_required_fields(method, uri, body, ['user-role-uri'])
        user_type = user.properties['type']
        if user_type in ('pattern-based', 'system-defined'):
            raise BadRequestError(
                method, uri, reason=314,
                message="Cannot add user role to user of type {}: {}".
                format(user_type, user_uri))
        user_role_uri = body['user-role-uri']
        try:
            hmc.lookup_by_uri(user_role_uri)
        except KeyError:
            raise InvalidResourceError(method, user_role_uri, reason=2)
        if user.properties.get('user-roles', None) is None:
            user.properties['user-roles'] = []
        user.properties['user-roles'].append(user_role_uri)
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
1190925
public ServerUpdater addRoleToUser(User user, Role role) {
        delegate.addRoleToUser(user, role);
        return this;
    }
651258
public void map(final User user, final Role role)
    {
        this.getRoleMappings().add(new RoleMapping(user, role));
    }
599198
def add_role(ctx, role):
    """"""

    if role is None:
        log('Specify the role with --role')
        return
    if ctx.obj['username'] is None:
        log('Specify the username with --username')
        return

    change_user = ctx.obj['db'].objectmodels['user'].find_one({
        'name': ctx.obj['username']
    })
    if role not in change_user.roles:
        change_user.roles.append(role)
        change_user.save()
        log('Done')
    else:
        log('User already has that role!', lvl=warn)
1371824
def add_user(self, username, password):
        """"""
        self.server.user_dict[username] = password
        self.server.isAuth = True
815518
def add_group_role(request, role, group, domain=None, project=None):
    """"""
    manager = keystoneclient(request, admin=True).roles
    return manager.grant(role=role, group=group, domain=domain,
                         project=project)
143825
function addRolePrivilege (access, role, privilege) {
  if (role === true || access[privilege].role === true) {
    access[privilege] = {
      role: true
    }
    return
  }

  access[privilege].role = _.union(access[privilege].role, _.concat(role))
}
986421
def assign(self, role):
        ''''''
        if role.owner_id != self.id:
            return self.roles.add(role)
804671
def add_user(self, user, **kwargs):
        """"""
        if isinstance(user, User):
            user = user['id']

        assert isinstance(user, six.string_types)

        endpoint = '{0}/{1}/users/{2}'.format(
            self.endpoint,
            self['id'],
            user,
        )
        result = self.request('PUT', endpoint=endpoint, query_params=kwargs)
        return result
1233322
public void addUserToRole(String user, String role) throws CmsException {

        OpenCms.getRoleManager().addUserToRole(m_cms, CmsRole.valueOfRoleName(role), user);
    }
905584
public void addRole(Role role) {
        apiRoles.add(role);
        roles.add(role.getName());
        for (org.seedstack.seed.security.Permission permission : role.getPermissions()) {
            if (!role.getScopes().isEmpty()) {
                for (Scope scope : role.getScopes()) {
                    ScopePermission sp = new ScopePermission(permission.getPermission(), scope);
                    scopePermissions.add(sp);
                }
            } else {
                stringPermissions.add(permission.getPermission());
            }
        }
    }
20267
public BoxGroupMembership.Info addMembership(BoxUser user, Role role) {
        BoxAPIConnection api = this.getAPI();

        JsonObject requestJSON = new JsonObject();
        requestJSON.add("user", new JsonObject().add("id", user.getID()));
        requestJSON.add("group", new JsonObject().add("id", this.getID()));
        if (role != null) {
            requestJSON.add("role", role.toJSONString());
        }

        URL url = ADD_MEMBERSHIP_URL_TEMPLATE.build(api.getBaseURL());
        BoxJSONRequest request = new BoxJSONRequest(api, url, "POST");
        request.setBody(requestJSON.toString());
        BoxJSONResponse response = (BoxJSONResponse) request.send();
        JsonObject responseJSON = JsonObject.readFrom(response.getJSON());

        BoxGroupMembership membership = new BoxGroupMembership(api, responseJSON.get("id").asString());
        return membership.new Info(responseJSON);
    }
541619
def add_user(self, nick, prefixes=None):
        """"""
        if nick not in self._user_nicks:
            self._user_nicks.append(nick)

        self.prefixes[nick] = prefixes
739482
def role_create(self, data, **kwargs):
        ""
        api_path = "/api/v2/roles"
        return self.call(api_path, method="POST", data=data, **kwargs)
860729
def add_user_role(self, user, role_name):
        """"""

        # For SQL: user.roles is list of pointers to Role objects
        if isinstance(self.db_adapter, SQLDbAdapter):
            # user.roles is a list of Role IDs
            # Get or add role
            role = self.db_adapter.find_first_object(self.RoleClass, name=role_name)
            if not role:
                role = self.RoleClass(name=role_name)
                self.db_adapter.add_object(role)
            user.roles.append(role)

        # For others: user.roles is a list of role names
        else:
            # user.roles is a list of role names
            user.roles.append(role_name)
398970
private void appendRoles(final StringBuilder builder, final User user) {
        for (final UserRoleName role : user.getRoles()) {
            append(builder, ",", role.name());
        }
    }