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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Indra_n
New Member

Execute query on sql server as current user

 

Hi,

I have configured a PowerBI report using Gateway and data source connection to SQL Server (the SQL server in Azure VM) with my Windows service credentials . I want to render customized data based on the logged-in user privileges. Is there a way to configure PowerBI to connect directly to a SQL server based on the logged-in user information? Basically, I am trying to see from PowerBI if I can directly query as the logged-in user (passing the user identity to the SQL server) without using the service account configured in the gateway. Note: PowerBI communicates with the SQL server through a view, and the view currently does not provide us with the username (could not attempt roles + row-level security). Please kindly share your thoughts.

 

Thanks!

 

1 REPLY 1
marcelsmaglhaes
Super User
Super User

Hey @Indra_n ,

Unfortunatelly, when using Power BI with a direct connection to a SQL Server, you can't directly pass the logged-in user's identity to the SQL Server unless (and maybe) you are using the "Effective Username" feature in combination with Row-Level Security (RLS).

Please note that setting up Effective Username and RLS may require changes to your SQL Server and may depend on your specific setup. It's a powerful feature for security but can be complex to configure based on your use case.

If you are unable to access the username in the view directly, you may need to consider modifying your SQL Server setup to capture or map user identities. Additionally, working with a local service account configured in the gateway for secure communication is a common practice, as it isolates the data source from direct user access.

 


Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI

If I've helped, don't forget to mark my post as a solution!



Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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