Page 1 of 1

adding a list of users to global role

Posted: Fri Jun 01, 2018 5:13 pm
by kevin1119
hi, i have a list of ids that i want to add to a global roles. it's painful to manually do it 1 by 1.

in the wiki script, i'm following securityService api to retrieve the target context role, but i don't see any method that returns context role. please help

thanks and regards

Re: adding a list of users to global role

Posted: Thu Aug 02, 2018 1:04 pm
by dan7777777
Are you wanting to add global roles or project roles? Context roles are project roles. Regardless, since I usually know exactly what roles I am trying to programmatically grant, I usually hard code the role id string and use it as the parameter of the method that grants the roles. For example with project role:
txService.beginTx();
securityService.addContextRoleToUser(userId, "project_user", contextId);
txService.commitTx();

However, if you are talking about retrieving a list of global roles, this method works:
var globals = securityService.getGlobalRoles();