Have you considered using SmartObjects?
I know there is a method that lists roles, and a method that lists a role's members.
The UMRole SmartObject has a Get Roles method, and the UMUser SmartObject has a Get Role Users method.
Hi
To get clarification on what you are trying to accomplish.
You basically want to retrieve all the users for each group?
To do this there is an easier way, navigate to (C:Program Filesx86K2BlacpearlBinSmartObject Service Tester.exe) and expand SmartObject Explorer > Active Directory > AD Group and AD User > methods on both AD Group and User (This is where you can add users and groups).
Now if you want to rietrieve all the users or groups you navigate to "ServiceObject Explorer" in the SmartObject Service Tester and Expand AD Servie 2 >Active Ddirectory Service 2 > Right click AD Group > Select Create SmartObject > Change the name and Category as displayed in image below > Click Publish SmartObject. (Do this for the AD User as well)
Navigate back to SmartObject Explorer > Active Directory 2 > Right Click AD User or AD Group > Select Execute SmartObject > Select the GetUsers or GetGroup option from the dropdown depending on which AD SmartObject you are executing > Click Execute > All Users or Groups should be displayed to you.
These documents can be used as guidelines:
More information about defining Roles
K2 Management Console - Add Users through a SmartObject
K2 blackpearl Roles and Advanced Destination Rules
If you are actually interested in K2 roles, not AD groups, have a look at the Get Role Users method of the UMUser SmartObject.
But to answer the question you asked, roles also appear in the Identity.Identity table in the K2 db. You need to cross reference with the Identity.IdentityMember table to determine membership. It should be noted that this will get you cached role membership. If role membership recently changed, K2 may not have updated its identity cache (these tables) to reflect this change.
Also, consider having a look at the K2 ERD.