Is there any way in which I can see what permissions are being used to determine a users access to a given object? I'm able to see which permissions have been granted to various roles and users within a database, but am having problems with these reports not lining up with what is actually happening.
For example, the SQL below will return my effective permissions on a given object:
SELECT * FROM fn_my_permissions('dbo.SomeTable', 'OBJECT')
ORDER BY subentity_name, permission_name ;
Which returns:
entity_name subentity_name permission_name
------------------- -------------- ---------------
dbo.SomeTable INSERT
dbo.SomeTable SELECT
dbo.SomeTable UPDATE
What would be very useful is something along the lines of below, which explains where each line item is coming from:
entity_name subentity_name permission_name reason
------------------- -------------- --------------- ----------------
dbo.SomeTable INSERT dbowner
dbo.SomeTable SELECT role: datareader
dbo.SomeTable UPDATE role: sysadmin
Note, there is a similar question on the site, however the accepted answer is a query that returns the permissions that are set, not where said permissions are coming from.
Edit: The reason for asking was that there were 'shadows' of former permissions as seen and explained here. However if I had access to something like the above, it would have shown the SQL Server thought I was a member of a given role and thus pointed me in the right direction...