Re: Urgent: Permissions Problem with Dynamic SQL
From: Andrew J. Kelly (akelly@targitinteractive.com)
Date: 08/14/02
- Next message: Tim: "SQL 2000 Encryption"
- Previous message: Paul Gascoigne: "ODBC Call to SQL Server Fails from ASP Application"
- In reply to: Mike Wade: "Urgent: Permissions Problem with Dynamic SQL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: "Andrew J. Kelly" <akelly@targitinteractive.com> Date: Wed, 14 Aug 2002 08:07:27 -0400
Mike,
I believe this was answered in .programming. You can post to more than one
NG by simply adding in the other NG's in the "Newsgroups" section of the
post. This way they will all be linked so when an answer is posted in one
NG it shows up in all the others as well.
-- Andrew J. Kelly SQL MVP Targitinteractive, Inc. "Mike Wade" <mike.wade@doh.gsi.gov.uk> wrote in message news:24a901c24381$608d4b70$3bef2ecf@TKMSFTNGXA10... > *** Also Posted in Programming *** > > Hi, > > I have 2 databases residing on the same server and an > having problems with permissions when using dynamic sql. > The first database is a sort of Portal to numerious data > sources. It contains all user accessible stored procs, > etc. The second contains source data. > > The problem I have is (for example): > > USE db1 > GO > CREATE PROC a AS > BEGIN > SELECT * FROM db2.dbo.Table1 > END > GO > GRANT EXECUTE ON a TO user1 > GO > EXECUTE a -- ****** THIS WORKS OK > GO > > > USE db1 > GO > CREATE PROC a2 AS > BEGIN > DECLARE @Sql VARCHAR(8000) > SET @Sql ='SELECT * FROM db2.dbo.Table1' > EXEC (@Sql) > END > GO > GRANT EXECUTE ON a2 TO user1 > GO > EXECUTE a2 -- ****** THIS DOES NOT WORK > /* Reports Permission Denied on Table1 */ > GO > > USE db1 > GO > CREATE VIEW v AS > SELECT * FROM db2.dbo.Table1 > > CREATE PROC a3 AS > BEGIN > DECLARE @Sql varchar(8000) > SET @Sql='SELECT * FROM v' > EXEC (@Sql) > END > GO > GRANT EXECUTE ON a3 TO user1 > GO > EXECUTE a3 -- ****** THIS WORKS OK > GO > > > > In all cases user1 is a user of both db1 and db2 but in > db2 the user is in the public group only and no express > permissions have been granted (or revoked) to the user or > public group. > > > The core problem is that I need a work around to the > procedure a2 which is functionally equivelent (ie the > dynamic slq is built in the stored proc), but do not want > to open up db2 to abuse by granting express select > permissions to tables (as some of the data is sensative). > > > Any Ideas? > >
- Next message: Tim: "SQL 2000 Encryption"
- Previous message: Paul Gascoigne: "ODBC Call to SQL Server Fails from ASP Application"
- In reply to: Mike Wade: "Urgent: Permissions Problem with Dynamic SQL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|