I had to grant a server permissions to an active directory group, in order to solve a LIVE Bug:
GRANT VIEW ANY DEFINITION TO [mycompany\webDevSeniors]
GO
after the permission was no longer needed I revoked it:
revoke VIEW ANY DEFINITION TO [mycompany\webDevSeniors]
go
this didn't seem to revoke the permission on all databases so I have tried it in a different way:
use master
go
revoke VIEW DEFINITION ON SCHEMA::[dbo] to [mycompany\webDevSeniors]
go
still, when I use one of my procedures to check which permissions are active in a specific database, it shows the "VIEW DEFINITION
"
sp_getlogindbpermissionsX @db='ATPayment',@login='MYCOMPANY\webDevSeniors'
as you can see on the picture below, the permission is not there at server level:
Problem Solved:
At the end, this is how I solved this problem:
I downloaded the sp_foreachdb stored procedure by Aaron Bertrand
And then I run the following command on my server:
sp_foreachdb @command='use ?; REVOKE VIEW DEFINITION ON SCHEMA::[dbo] to [mycompany\webDevSeniors]'
-- ,@print_dbname = 1
--,@print_command_only = 1
SELECT a.name AS Name, a.type_desc AS LoginType,b.class_desc AS ClassDesc ,b.permission_name AS ServerLevelPermission,b.state_desc AS PermissionState FROM sys.server_principals a JOIN sys.server_permissions b ON a.principal_id = b.grantee_principal_id