Forum Discussion
Custom USERPRINCIPALNAME() when consumming API through Service Principal
- 3 years ago
It took me a long time before being able to figure out the best solution.
Using service principal was not the best approach in order to take the user's rights in account.
So I had to focus on the other way (more complicated for novice as I am) to embed reports, based on user's scope delegation located in the Azure application.
Hi Lauger ,
Maybe you can use username() or userobject() instead of userprinciplename ()
Username() returns the domain name and username from the credentials given to the system at connection time.
Userobject() returns the current user's Object ID or SID.
refer to:
https://learn.microsoft.com/en-us/dax/information-functions-dax
Kind Regards
Gengar
Hi Gengar,
Thanks for your reply.
To make sure I understand well, USERNAME() DAX function will return the name of the authenticated user. However, as a generate an access token using Azure App client ID and secret, will it not simply return the username of the Azure app? The report's embed token is generated using the Access Token generated for the Azure app.
How can PowerBI retrieve the currently-authenticated user's information if I never send his own credentials anywhere? And what will return USERNAME() function if I embed a report into an application which uses Anonymous authentication mode?
Thanks a lot.
Regards,
- Gengar3 years ago
Resolver I
Hi Lauger ,
I mean, normally you use username to return the domain name and username in the credentials, and you could probably use it or some other like: userobject , instead of userprinciplename, which returns the email.
Best Regards
Gengar
- Lauger3 years agoRegular Visitor
Hi Gengar,
Thanks for your reply.
I will check what does the DAX function USERNAME() as soon as possible (I'm waiting feedback from other teams of my company), thanks a lot.
If it works, I will mark your answer as the solution.
To well understand, how can Power BI retrieve the name of the user authenticated on the application? As I authenticate to API using a Bearer token authentication mode refering the Service Principal access token, I'm wondering how it's possible to retrieve the user's name?