cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Get all user groups for given user

SOLVED
Garnet

Re: Get all user groups for given user

I have a follow up question on this. GetCurrentUserGroups returns a list of Groups the user is directly assigned to, it does not take nested hierarchical groups into account. E. g. I have two groups: Managers and Operators, Managers are member of Operators. But for any Manager the Operators Group is not listed, only the Managers Group itself.

 

My ultimate goal is to check whether a user is member of a given group to identify permission level.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Get all user groups for given user

Once you have the first set of groups, you can do a GetGroups on those entities (or vice versa GetMembers)

i.e. Groups[NameofGroup].GetGroups

Also you can check the Type of each before you run that, because it'll either be of Type Group or User

6 REPLIES 6

Re: Get all user groups for given user

If you are on the latest release of Thingworx I do believe there are 'reverse' style services. I haven't looked into it in depth.

Else you would need to use a recursive service / loop

Re: Get all user groups for given user

Thanks for your quick response, @PaiChung . Yes, I am working on Thingworx 8.4 but haven't found a fitting method. I avoided a recursive loop, it doesn't feel right to me. On the one hand concerning performance and on the other it may lead to infinite recursion (not in my and not in most cases but potentially). Any pointer to the 'reverse' style services would be a big help.

Re: Get all user groups for given user

there are some new services like:

CheckPermissionForUser

CheckPermission

CheckDesignTimePermissionForUser

They are on the Things

 

Potentially those help?

I haven't used them so far.

And in Permissions there is Access Reports which I believe use those services.

Re: Get all user groups for given user

Hi Pai,
thanks again for your quick response. Yes, the CheckPermission Services are closely related but not exactly covering what I am looking for. I can check the the Read/Write/Invoke rights on Properties/Services/Events of an entity. But I do not have a particular entity I would like to check, I only want to know if the user is member of a group, directly or inherited.
Some more background on why I want to do this: I am building a data driven menu and would like to add entries based on the group membership. When googling I found this topic but it is not explained on HOW to check the groups.

Highlighted

Re: Get all user groups for given user

Once you have the first set of groups, you can do a GetGroups on those entities (or vice versa GetMembers)

i.e. Groups[NameofGroup].GetGroups

Also you can check the Type of each before you run that, because it'll either be of Type Group or User

Re: Get all user groups for given user

This leads me to recursion again. I figured there might be a function to do this already but I think this is the closest I can get atm. Thank you.