I have an AD login added to a SQL Server group. The SQL Server group has the sysadmin role.
When the user logs in they connect correctly
account name type privilege mapped login name permission path
domain\test user admin domain\test domain\groupwithsysadmin
When they execute a stored procedure in a user database, it errors out for not having execute permissions.
The EXECUTE permission was denied on the object 'SomeFunction', database 'SomeDatabase', schema 'Test'.
If I execute as user in the database, the same things happens.
use SomeDatabase
GO
EXECUTE AS USER = 'domain\test';
select Test.SomeFunction ('ComponentTest')
REVERT;
GO
The EXECUTE permission was denied on the object 'SomeFunction', database 'SomeDatabase', schema 'Test'.
If I execute as the login it works.
EXECUTE AS login= 'domain\test';
select SomeDatabase.Test.SomeFunction ('ComponentTest')
REVERT;
GO
I am stumped as to why a the login will not carry the sysadmin privileges when using the database.
domain\test
User orphaned from the Login?SELECT dp.name, dp.type, dp.sid, sp.sid AS server_sid, sp.type AS server_type FROM sys.database_principals AS dp LEFT JOIN sys.server_principals AS sp ON dp.sid = sp.sid WHERE dp.principal_id = DATABASE_PRINCIPAL_ID();
dbfiddle.uk/x8WN9yY0 and show us the results, the last two columns will be null if orphaned.