Forum Discussion
REST API to get role names (RLS) from power bi service
- 4 years ago
Hi,
1. There is no Power BI REST API endpoint for this unfortunately. I've tried looking for the same and lbendlin had pointed me in the DMV direction also. To expand on that, you can connect to the XMLA endpoint and run some queries. There are pros and cons. In case you want more info, here is some doco with examples: https://docs.microsoft.com/en-us/analysis-services/instances/use-dynamic-management-views-dmvs-to-monitor-analysis-services?view=asallproducts-allversions#tools-and-permissions
Using the DMVs you can get roles, members, and the role filters per table, however only one view can be queried at a time with no joins allowed. I ended up building up data from the following DMVs:
$SYSTEM.TMSCHEMA_ROLES
$SYSTEM.TMSCHEMA_ROLE_MEMBERSHIPS
$SYSTEM.TMSCHEMA_TABLES
$SYSTEM.TMSCHEMA_TABLE_PERMISSIONS
Here's a link to my previous post if you're interested (there is a analysis.windows.net API endpoint you could call but I couldn't make it work): https://community.powerbi.com/t5/Developer/How-to-get-model-not-Dataset-ID-Part-of-getting-RLS-Roles-and/m-p/2096105#M32012
2. From the doco (https://docs.microsoft.com/en-us/rest/api/power-bi/admin/datasets-get-datasets-as-admin#dataset)
IsEffectiveIdentityRequired Whether the dataset requires an effective identity. This indicates that you must send an effective identity using the GenerateToken API.
IsEffectiveIdentityRolesRequired Whether RLS is defined inside the PBIX file. This indicates that you must specify a role.
Hope that helped.
Hi, now it`s accesible by using method described here https://learn.microsoft.com/en-us/rest/api/power-bi/admin/workspace-info-post-workspace-info
PostWorkspaceInfo makes Power BI generate a scan of your workspace, which you can check for using GetScanStatus, then read using GetScanResult. The scan result contains information about row-level security roles https://learn.microsoft.com/en-us/rest/api/power-bi/admin/workspace-info-get-scan-result#definitions, including members of those roles and the RLS filters applied to those roles.