Hey Almighty and Kevin,
I'll post a code snippet of a servlet that managed to do the job. (changing roles of users, etc.)
As Almighty already mentioned, you can not change such settings for a user over the WebServices (!)
You have to do this over servlets (see SDK examples, there's one there I believe, as basis) and call methods from the Open SDK API (
https://almdemo.polarion.com/polarion/s ... index.html).
In there, you have methods that can actually do the things an admin can do over his Admin Panel.
Exemplary code (its a draft stage, so might be clumsy) right here:
From Servlet.Java:
Code: Select all
some.debug.print("Removing access to project...");
currentuser = projecserv.getUser("some_user_id");
currentproject = projecserv.getProject("myproject_id");
some_debug_string += "Firstly, displaying global + context roles for user";
some_debug_string += secserv.getRolesForUser(userid,currentuser
.getContextId()).toString();
some_debug_string += "Now, removing project rights for test purposes.<br>";
transserv.beginTx();
secserv.removeContextRoleFromUser(userid, "project_user",
currentproject.getContextId());
try {
transserv.commitTx();
} catch (Exception e) {
e.printStackTrace();
}
some_debug_string += "Results: "+secserv.getContextRolesForUser(userid,
currentproject.getContextId()).toString() + "<br>";
Important parts here are:
- Get projecserv = IProjectService (check API):
Code: Select all
IProjectService projecserv = (IProjectService) PlatformContext.getPlatform()
.lookupService(IProjectService.class);
- Get secserv = ISecurityService (check API):
Code: Select all
ISecurityService secserv = (ISecurityService) PlatformContext.getPlatform()
.lookupService(ISecurityService.class);
- Get current user and project, call removeContextRoleFromUser and give id, role, currentProjectID
- wrap in beginTx - commitTx (this can be tricky, best of luck)
- check results and hopefully be happy
Sorry if this was confusing. This is how we managed to execute code to adapt users.
I'll check in here again, just ask away if there's any confusion.