Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Shaamil
Regular Visitor

Programmatically grant user permission to a dataset

Hi, There are Power BI reports in my organization targeted for various users. Currently for the reports we grant access to users by going into The Wokspace, and selecting the datsets. From there we select security and add the AD user. A sample destination url where the  users are added would be something like https://app.powerbi.com/groups/{workspace-guid}/rowLevelSecurity/{group_id}

 

Is there a way that I can programmatically do this through the Power BI API ? So that I can add users to the selected dataset by passing the relevant AD user information. Planning to send the related data/request through a web site using C#.

 

If so, what approach should I take? I have currently created an "app registration" in Azure. I also had a look at the sample code at PowerBI-Developer-Samples. In this sample what confuses me is the resourceUrl which is passed at the code line

 

var authenticationResult = await authenticationContext.AcquireTokenAsync(ResourceUrl, ClientId, credential);

 

What should the resource link be? Is it the app registration's url in Azure ?  Azure seem to create a random url for the "app registration" such as  https://MycompanysDomain.com/80311e9d-c75f-4692-a513-ab36e55ba3ab which is not a valid URL

 

Please advise me on this. I am a complete newbie for this

7 REPLIES 7
Anonymous
Not applicable

does anyone find a solution using API or c#, I need to add a new user and grant him admin/read permission on a specific workspace.

Hi this can be done using ps script "Add-PowerBIWorkspaceUser -Scope Organization -Id $workspace.id -UserEmailAddress $Email_Id -AccessRight Admin "

Shaamil
Regular Visitor

Hi, There are Power BI reports in my organization. Currently for the reports we grant access to users by going into The Wokspace, and selecting the datsets. From there we select security and add the AD user.

 

Is there a way that I can programmatically do this through the Power BI API ? So that can add users to the selected datasheet by passing the relevant AD user information.

 

If so, what approach should i take? I have currently created an "app registration" in Azure. I also had a look at the sample code at PowerBI-Developer-Samples . In this sample what confuses me is the resourceUrl which is passed at the code line

 

var authenticationResult = await authenticationContext.AcquireTokenAsync(ResourceUrl, ClientId, credential);

 

What should the resource link be? Is it the app registration's url? Azure seem to create a random url for it such as  https://MycompanysDomain.com/80311e9d-c75f-4692-a513-ab36e55ba3ab which is not a valid URL

 

Please advise me on this. I am a complete newbie for this

Hi @Shaamil,

 

I'm afraid there isn't such a API for now. I would suggest you vote up this idea or create a new one. Please refer to the REST APIs of Power BI: rest/api/power-bi/datasets.

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Has anyone got a working version of the programmatical manipulation of RLS in Power BI? It will be a big help if any lead is shown.

Hi @v-jiascu-msft

 

I upvoted the idea to create a new one. Also I checked out on the Power BI REST API. Although there is a REST method to add user to group, it only adds users to the workspace as members and not to RLS groups. [Reference: https://docs.microsoft.com/en-us/rest/api/power-bi/groups/addgroupuser] . So it seems there is no support from the Power BI REST API as well. Thanks Dale for replying for my post !

we would need this API for the exactly same use case. it would be great if Microsoft could provide it.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.