Skip to main content
16-Pearl
May 8, 2019
Solved

Re: Get all user groups for given user

  • May 8, 2019
  • 1 reply
  • 3929 views

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.

Best answer by PaiChung

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

1 reply

22-Sapphire I
May 8, 2019

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

BennyB16-PearlAuthor
16-Pearl
May 8, 2019

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.

22-Sapphire I
May 8, 2019

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.