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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.