cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kk0036 Regular Visitor
Regular Visitor

Row Level Security with Username() with b2b accounts

Previously when I used this as my RLS filter the Username function returned Users@userdomain.com for all of my b2b users. Now when I add and external user username() and userprinciplename() return the external version User_Userdomain.com#ext#mydomain.com. I just want to know why that might occur and if I can go back to having it return just the email in invited rather than the entire extension. 

5 REPLIES 5
Super User
Super User

Re: Row Level Security with Username() with b2b accounts

Hi @kk0036

 

From my testing, when you use the USERPRINCIPALNAME() function with B2B it should still return the external email address which should then map through to your table where you have got the email address stored.

 

My understanding is that what is viewed in the Azure AD Display Name, but that is not what is returned by the USERPRINCIPALNAME() function 



Did I answer your question? Mark my post as a solution!

"Proud to be a Datanaut!"
kk0036 Regular Visitor
Regular Visitor

Re: Row Level Security with Username() with b2b accounts

I have tested too with 6 users from 3 domains with one user being newly added and one user being old. I get this long form email address now for username() and userprinciplename() for any b2b user that I add. I created a testing workspace with measures to show what the Username and UPN are for each user. I then signed in as those users to view this page, and for users added prior to yesterday both return just the email address username@userdomain.com and for any users added yesterday or after I get the ext version. 

 

So both functions now return the email address in the long form, and the old users still return the normal email address even when they are in the same external domain as the new users I added. 

kk0036 Regular Visitor
Regular Visitor

Re: Row Level Security with Username() with b2b accounts

 

I figured I would share a screenshot of the results in the testing report. These are two users from the same domain with different results for the username() and userprinciplename() functions. The top user was added last week, bottom user added yesterday. 

user 1.png

User 2.png

Super User
Super User

Re: Row Level Security with Username() with b2b accounts

Hi there,

Could it be that it takes Azure AD a few days to sort out the email address, or possibly that someone changed it in Azure AD?


Did I answer your question? Mark my post as a solution!

"Proud to be a Datanaut!"
kk0036 Regular Visitor
Regular Visitor

Re: Row Level Security with Username() with b2b accounts

It hasn't lagged like this before. Typically I am able to add users to power bi reports within hours of the request. 

 

As I am really the only person that does this activity, I don't think that the user account would have been changed by anyone else. 

 

I did something just for a test. I had an account that was added as an external user test. It was working appropriately with the username() function returning the user@domain.com. I removed that account from office 365 and my AD and reinvited. Upon re-entering the username() and userprinciplename() function returned with the #EXT#.