Forum Discussion
RLS using aduser name
- 1 year ago
If it is not working in the service, create a mapping table that links AD usernames to UPNs. Use USERNAME() in the service to retrieve the UPN, and apply a DAX lookup (LOOKUPVALUE) to map it to the corresponding AD username for RLS filtering.
- 1 year ago
Hi DiKi-I ,
we can also do thses steps Update your data source to store the full UPNs (e.g., [email protected]) in the ADUser field so that it directly matches what Power BI returns using USERNAME().
If that’s not possible, use a DAX expression in your RLS rule to extract just the username from USERNAME(), ensuring compatibility across both Desktop and Service.
You can use the following DAX to extract the short username from USERNAME()
Table[ADUser] =
VAR _user = USERNAME()
RETURN
IF(
FIND("@", _user, 1, 0) > 0,
LEFT(_user, FIND("@", _user) - 1),
_user
)Regards
Chaithanya.
I tested like this in power bi desktop and I'm passing aduser in the role, this is working. But when I'm checking username () in card in service it is giving me [email protected]. I don't have access to test with real data yet in service.
In case if it doesn't work is there a way to lookup the upn using aduser in power bi?
- Akash_Varuna1 year agoSuper User
If it is not working in the service, create a mapping table that links AD usernames to UPNs. Use USERNAME() in the service to retrieve the UPN, and apply a DAX lookup (LOOKUPVALUE) to map it to the corresponding AD username for RLS filtering.
- v-kathullac1 year agoCommunity Support
Hi DiKi-I ,
we can also do thses steps Update your data source to store the full UPNs (e.g., [email protected]) in the ADUser field so that it directly matches what Power BI returns using USERNAME().
If that’s not possible, use a DAX expression in your RLS rule to extract just the username from USERNAME(), ensuring compatibility across both Desktop and Service.
You can use the following DAX to extract the short username from USERNAME()
Table[ADUser] =
VAR _user = USERNAME()
RETURN
IF(
FIND("@", _user, 1, 0) > 0,
LEFT(_user, FIND("@", _user) - 1),
_user
)Regards
Chaithanya.
- DiKi-I1 year agoPost Partisan
Thanks for your response. I asked the source to provide me email in the table. As username() is returning upn with domain in service .