How to get the permissions set on a user programmatically(serverside)
Hi
I am trying to check the permissions on a user .If the user has a permission to create workitem in a project area or not. Is there a way to get this information once I have the contributer handle. For eg:
I have the the following to get the contributer
IRepositoryItemService item = getService(IRepositoryItemService.class);
IContributorHandle approver = getAuthenticatedContributor();
IItem username = item.fetchItem(approver, null);
IContributor contributor = (IContributor)username.getFullState();
return contributor.getName();
So once I get the contributer I need to check whether this user has permission to create and save workitem on a particular project area. I do not know whether there is any API functions which support this operation.
Appreciate your help.
I am trying to check the permissions on a user .If the user has a permission to create workitem in a project area or not. Is there a way to get this information once I have the contributer handle. For eg:
I have the the following to get the contributer
IRepositoryItemService item = getService(IRepositoryItemService.class);
IContributorHandle approver = getAuthenticatedContributor();
IItem username = item.fetchItem(approver, null);
IContributor contributor = (IContributor)username.getFullState();
return contributor.getName();
So once I get the contributer I need to check whether this user has permission to create and save workitem on a particular project area. I do not know whether there is any API functions which support this operation.
Appreciate your help.
Accepted answer
The permissions are not tied to the user, but to the role the user has. The permissions are also not stored with the user but in some other process related API. See for how to at least get the roles of a user. http://rsjazz.wordpress.com/2012/12/09/analyzing-a-aroject-areas-members-and-roles-using-the-plain-java-client-libraries/
2 other answers
Old post, but still might be useful to someone out there.
If you have the IRole object, you can send the actions as a string array:
String[] actions = {"modify","any","create","delete"}; //<- not sure if this encompass all the actions available.
to the process service (using client side libraries here):
boolean[] actionsAllowed = processService.getPermittedActions(role.getId(), actions, monitor);
and you'll get true or false, depending if the current role has those actions. Haven't tested this, though.