Quantcast
Viewing all articles
Browse latest Browse all 3160

Use SQL Server RLS with SSAS and Power BI

One of the questions I get regularly nowthat SQL Server supports RLS is how can toleverage this withSSAS. What many don’t know is that SSAS already supports this, even for Direct Query mode. So in this case you could have something like the following architecture: Dashboards and reports in Power BI that connect to an on premise SSAS server running DirectQuery mode connecting to SQL Server. All with the same username flowing from Power BI all the way down to SQL Server.

Let’s see how this works in SSAS, the Power BI and gateway part work as usual, no changes are needed there. The example belowis using Tabular DirectQuery but the same works for Multidimensional ROLAP.

I have this simple model with just 1 table set to DirectQuery mode:


Image may be NSFW.
Clik here to view.
Use SQL Server RLS with SSAS and Power BI

I am using the service account to connect to the data source (go to Existing connections, Edit Datasouce, Impersonations to get this dialog)


Image may be NSFW.
Clik here to view.
Use SQL Server RLS with SSAS and Power BI

(By the way you should never use the service account as impersonation setting in any production environment, I just use it here as I am lazy
Image may be NSFW.
Clik here to view.
Use SQL Server RLS with SSAS and Power BI

)

Now if I connect to this model with Excel and run profiler on SQL Server we can see the user that is running the queries to SQL Server and logging into SQL using the service account SSAS is running under:


Image may be NSFW.
Clik here to view.
Use SQL Server RLS with SSAS and Power BI

Now instead of the Service AccountI want to use the credentials of the user who is connecting to my model and use that toconnect to the SQL database. You cannot do this in the SSDT UI. Instead I publish the model to my server and open the Connection Dialog in SSMS:


Image may be NSFW.
Clik here to view.
Use SQL Server RLS with SSAS and Power BI

Again this is set to impersonate the service account:


Image may be NSFW.
Clik here to view.
Use SQL Server RLS with SSAS and Power BI

Clicking there it will give me a new option that I didn’t have in SSDT that allows me to use the credentials of the current user:


Image may be NSFW.
Clik here to view.
Use SQL Server RLS with SSAS and Power BI

I press OK and connect again with Excel to my model, now I will be able to see that my username is being used to connect to SQL Server:


Image may be NSFW.
Clik here to view.
Use SQL Server RLS with SSAS and Power BI

and that’s it, now SSAS passes on the credentials of the current user. If you have RLS configured at your SQL Server SQL database it will now only return the rows approved for this user. This option works for both Multi dimensional and Tabular.

Of course passing along credentials between machines can also complicate matters, in my scenario things are easy as I have all services on a single box but in a real world scenario SSAS and the SQL database system will not be on the same machine. In those cases you will need to configure Kerberos delegation between the two machines. Below you can find multiple blog post of SSAS andsimilar services that should give you a starting point on how to configure this:

https://msdn.microsoft.com/en-us/library/dn194199.aspx

http://sqlmag.com/sql-server-reporting-services/implement-kerberos-delegation-ssrs

https://shuggill.wordpress.com/2015/03/06/configuring-sql-server-kerberos-for-double-hop-authentication/


Viewing all articles
Browse latest Browse all 3160

Trending Articles