I would like to know all the users that have access to symmetric keys and the type of access they have. Can you please let me know how I can do this?
The answers above do not actually reflect the Object Name, please consider this instead:
select
[database] = db_name()
, u.name
, p.permission_name
, p.class
, p.class_desc
, ObjectNameForObjectORColumn
= object_name(p.major_id)
, objectNameActual
= case class_desc
when 'SYMMETRIC_KEYS' then sm.name
when 'CERTIFICATE' then [cert].name
end
, state_desc
from sys.database_permissions p
inner join sys.database_principals u
on p.grantee_principal_id = u.principal_id
left outer join sys.symmetric_keys sm
on p.major_id = sm.symmetric_key_id
and p.class_desc = 'SYMMETRIC_KEYS'
left outer join sys.certificates [cert]
on p.major_id = [cert].[certificate_id]
and p.class_desc = 'CERTIFICATE'
where class_desc in('SYMMETRIC_KEYS', 'CERTIFICATE')
order by u.name
More here https://danieladeniji.wordpress.com/2015/10/09/sql-server-list-permissions-for-user/
Maybe this query can help:
select u.name, p.permission_name, p.class_desc,
object_name(p.major_id) ObjectName, state_desc
from sys.database_permissions p join sys.database_principals u
on p.grantee_principal_id = u.principal_id
where class_desc = 'SYMMETRIC_KEYS'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With