Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Stored procedure with EXECUTE AS

Author  Topic 

peva13
Starting Member

2 Posts

Posted - 2011-01-14 : 10:55:30
Hi ALL!

I am new to SQL, and maybe the question is stupid, but please help.

I have database1 (DB1) with stored procedure (StP) who select data from other DB2. It was work fine.

But I have SmallUser with only executer rights to DB1 and without any rights to DB2. Therefore I put in StP EXECUTE AS BigUser. BigUser is full rights to DB1 and DB2.

When SmallUser execute StP receive error:
Msg 916, Level 14, State 1, Procedure SP, Line 11
The server principal "BigUser" is not able to access the database "DB2" under the current security context.


Maybe there is another way to let SmallUser execute StP

Sorry for the language

Regards
peva13

Sachin.Nand

2937 Posts

Posted - 2011-01-14 : 13:27:13
I think what you should do is create a SCHEMA with full authorization for both biguser and smalluser and then create the SP (Stp) under the newly created schema.

PBUH

Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2011-01-14 : 15:22:18
EXECUTE AS in a stored procedure only allows you to execute in the context of the database user, not as server principle (login) to give it acces to another database.

You can give a stored procedure access to another database by signing it with a certificate:
SQL Server 2008 Books Online
Module Signing (Database Engine)
http://msdn.microsoft.com/en-us/library/ms345102(v=SQL.100).aspx






CODO ERGO SUM
Go to Top of Page

peva13
Starting Member

2 Posts

Posted - 2011-01-17 : 06:50:47
Thanks!

Regards
peva13
Go to Top of Page
   

- Advertisement -