It's all about the answers!

Ask a question

How to get the permissions set on a user programmatically(serverside)

Meera Varma (911012) | asked Jan 16 '13, 6:22 a.m.

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

permanent link
Ralph Schoon (63.2k33646) | answered Jan 17 '13, 6:52 a.m.
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.
Meera Varma selected this answer as the correct answer

2 other answers

permanent link
Lauren Hayward Schaefer (3.3k11727) | answered Jan 17 '13, 6:47 a.m.
Hi Meera,
I don't have personal experience with this, but the following forum post has some suggestions:

permanent link
Carlos Maciel (3112) | answered Jan 14 '15, 12:59 p.m.
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.

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.