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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Ncedia
Frequent Visitor

Embed Power BI report in web application

Hi!

 

I have some questions regarding showing Power BI reports in a custom web application.

 

The web application is based on an ASP.NET 4.6/ASP.NET identity, (claims aware) and the users authenticate with an AD FS server.
(Both onprem Active Directory and other non Active Directory IDP).

 

- Is it possible to publish an embedded Power BI report in the web application, and show data based on the logged in user identity?

- If this is possible, does the users of the web application need any Power BI licens?


Best regards!

 

/Jonas

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @rossnruthie,

 

Thanks for response. That is a serious issue and makes the new API way less powerfull then the old embedded system. Not to say useless in a multi tenant environment. @Eric_Zhang hope the RLS feature comes soon 🙂

View solution in original post

5 REPLIES 5
Eric_Zhang
Microsoft Employee
Microsoft Employee


@Ncedia wrote:

Hi!

 

I have some questions regarding showing Power BI reports in a custom web application.

 

The web application is based on an ASP.NET 4.6/ASP.NET identity, (claims aware) and the users authenticate with an AD FS server.
(Both onprem Active Directory and other non Active Directory IDP).

 

- Is it possible to publish an embedded Power BI report in the web application, and show data based on the logged in user identity?

- If this is possible, does the users of the web application need any Power BI licens?


Best regards!

/Jonas


 

@Ncedia

Two options.

With license, you can use Embedding with Power BI users and set Power BI Row Level Security or either use filter.

 

Without license, you'll have to use Embedding with non-Power BI users. As to filter or using RLS, RLS used to work for the old embedding model(deprecated), for the new model, the RLS feature is on the roadmap and would be released in next quarter. So at this moment, use filter in the Power BI Javascript API can be the only workaround. See a demo below.

 

 

<html>

 <script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/jquery/dist/jquery.js"></script>

<script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/powerbi-client/dist/powerbi.js"></script>
 
<script type="text/javascript">
window.onload = function () { 
var users= ["user1"]; //get the client name with javascript from your page var Filter = { $schema: "http://powerbi.com/product/schema#basic", target: { table: "Table", column: "username" }, operator: "Contains", values: users } // Read embed application token from Model var accessToken = "H4sIAAAAAAAEAB2 xxxxx uCwAA"; // Read embed URL from Model var embedUrl = "https://app.powerbi.com/reportEmbed?reportId=1f1d9145-738a-4d20-ab5b-1236b283e942&groupId=73e1a3c6-08c4-4651-aa04-2bb701a573c7"; // Read report Id from Model var embedReportId = "1f1d9145-738a-4d20-ab5b-1236b283e942"; // Get models. models contains enums that can be used. var models = window['powerbi-client'].models; // Embed configuration used to describe the what and how to embed. // This object is used when calling powerbi.embed. // This also includes settings and options such as filters. // You can find more information at https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details. var embedConfiguration = { type: 'report', tokenType: models.TokenType.Embed, accessToken: accessToken, embedUrl: embedUrl, id: embedReportId, permissions: models.Permissions.All, filters:[Filter,Filter2], settings: { filterPaneEnabled: true, navContentPaneEnabled: true } }; var $reportContainer = $('#reportContainer'); var report = powerbi.embed($reportContainer.get(0), embedConfiguration); } </script> <div id="reportContainer" powerbi-settings-nav-content-pane-enabled="true" powerbi-settings-filter-pane-enabled="true"></div> </html>

 

Anonymous
Not applicable

How does this implementation avoid that the user might change the username?

Hi @Anonymous,

 

Using the filter logic does NOT prevent the user from changing the username and that is a serious security problem.  Based on my research there is no way to currently use RLS in the new api.  The only option currently is to create a report filter and apply it within the JS as the sample above shows.

Anonymous
Not applicable

Hi @rossnruthie,

 

Thanks for response. That is a serious issue and makes the new API way less powerfull then the old embedded system. Not to say useless in a multi tenant environment. @Eric_Zhang hope the RLS feature comes soon 🙂

Anonymous
Not applicable

You can use the username() function in the DAX statement and pass the username via the token. AFAIK a Power BI Premium subscription is needed for that. The user of your application it self does not need any subscription for that. See also https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-embedding/#embedding-with-non-po...

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.