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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MikeBaker
New Member

PBI Issue using RLS implemented in Azure SQL DB

Has anyone had any luck implementing RLS in Azure SQL DB and having it work in Power BI reports? I was able to implement and get the desired result set in Azure SQL DB. However, I am not able to get any rows using the same account in PowerBI service\premium using directquery on a basic report using only one table. I cannot see anything in PBI Desktop either, but that is expected since it uses a domain account and Azure SQL DB uses the O365 UID. When I set the security policy below to off then I get all of the rows for the table in Power BI without publishing again. Below is brief description of what I have done.

Setup a Mapper table

  • Create Table[dbo].[Mapper]([User] sysname NULL, CurrentOfficerCode [varchar](255) NULL)
  • Insert into Mapper([User], CurrentOfficerCode) VALUES('Actual office 365 UID', 'Actual officer code')
    • Office 365 UID example: account@domain.net
    • Actual officer code: would be same as account above

 

Create Schema

CREATE SCHEMA Security;

 

Create Function

CREATE FUNCTION Security.fn_ChkSavPredicate(@CurrentOfficerCode as varchar(255))

RETURNS TABLE

WITH SCHEMABINDING

AS

RETURN SELECT 1 AS AccesResult FROM dbo.Mapper

WHERE ([CurrentOfficerCode] = @CurrentOfficerCode AND [User] = USER_NAME());

 

Create Policy

CREATE SECURITY POLICY ChkSavMap

ADD FILTER PREDICATE Security.fn_ChkSavPredicate([CurrentOfficerCode])

ON [dbo].[ChkSav]

WITH (STATE = ON);

 

Validate

Execute AS USER = 'account@domain.net'

Select * from ChkSav

  • When I run this statement, I get the desired result set in Azure SQL DB.

 

0 REPLIES 0

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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