Why is SELECT USER_NAME() returning my windows credentials and not the database user mapped to a windows security group that I am in? I am trying to implement Row Level Security and have mapped an AD Security Group to a user in my test Database. When trying to select data from a table that I have granted access to I am not getting my intended result. I have added select USER_NAME() to see what is being checked on my predicate function and I get the Windows login and not the database user.
If a Windows principal accessed the database by way of membership in a group, CURRENT_USER will return the name of the Windows principal instead of the group name.
https://docs.microsoft.com/en-us/sql/t-sql/functions/current-user-transact-sql?view=sql-server-ver15