December 20, 2004 at 11:07 am
I want all my developers to give execute permission on store proc, when user execute store proc its give Update permission denied, I don't want to give permission on tables update.
What should I do??
thanks
Nita
December 20, 2004 at 12:06 pm
Sounds like your developer use dynamic sql within their stored procedures. Have a look at these procedures and tell your developers to avoid dynamic sql for updates.
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
December 20, 2004 at 12:22 pm
No its not helping, the website is in some other language.
December 20, 2004 at 12:54 pm
Hey, nice you visited my site. However, this is my forum signature. My reply is above the signature. Sorry, if this is confusing.
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
December 20, 2004 at 12:58 pm
Thanks Frank
BTW: The store procedure is not using dynamic query
Nita
December 20, 2004 at 1:01 pm
Can you post the code?
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
December 20, 2004 at 1:16 pm
Yes Sir,
create PROCEDURE dbo.spjobbegin AS
BEGIN
DECLARE @jobId VARCHAR(36),
DECLARE @jobTotal INT
SET @Jobtotal = 0
SELECT @JobTotal = count(*) FROM db_one.dbo.job_tbl
WHERE jobID = @jobID
UPDATE db_one.dbo.job_tbl SET jobTotal=@jobTotal
WHERE jobID = @jobID
IF @jobTotal > 0
INSERT INTO DB_TWO.dbo.job_log (jobID, type, name
VALUES (@jobID, 'True', 'job_tbl')
END
GO
December 20, 2004 at 1:29 pm
I think the issue is the update is to a different database. The cross checking may be enabled, which would cause the permissions to be checked for the second database. Does that give you something to work with?
December 20, 2004 at 1:35 pm
Cross checking????
The db_one and db_two are on same server
December 20, 2004 at 1:39 pm
Yea, actually I knew they were on the same server, or else you would would have had to have had the server name as the first part of the name.
There's some kind of feature called cross-checking or cross-linking or something (we don't use it, I just remember reading about it). You face the choice explicitly when you upgrade, and if you choose it, cross database statements are checked for security.
One easy way to see if you have it is to see if the person running the sp has specific permission to the item in the second db. If not, give it, and see what the result is.
December 20, 2004 at 2:02 pm
He has same execute permission to the other database as well!
I tried pubs and northwind and it works fine ;(
Why the above cannot?
December 21, 2004 at 1:00 am
Under which security context is the stored procedure executed? It it the same in both db's?
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
December 21, 2004 at 9:43 am
Yes, there is an option that you can only configure when you update sql server 2000. I can't remember if it's call cross chaining database permissions or whatever, but if you didn't install it during the service pack, I think you're out of luck. From what I've been told though, enabling this isn't recommended and can pose security / administration nightmares.
Since your query is accessing another database, you will have to grant update permission to the table in the other database. Your stored procedure security context only exists within the stored procedure's own database.
December 21, 2004 at 11:08 am
Nita,
Cross-database ownership chaining refers to dependant objects in separate databases being owned by the same login account (not the same database user). It can be set after an installation or upgrade at either the server level or database level.
In your case, assuming the dbo.spjobbegin stored procedure is in db_one and dbo is mapped to the same login in both databases, you can grant EXECUTE on the stored procedure and it will update the table in db_two without you having to grant UPDATE permission on the table.
Greg
Greg
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply