Re: Permission Denied executing SP that reads foreign table!

From: Dan Guzman (guzmanda_at_nospam-online.sbcglobal.net)
Date: 10/31/05


Date: Mon, 31 Oct 2005 07:11:43 -0600


> When a stored procedure is executed the user calling the SP may not have
> access to the base tables, but that doesn't matter as the SP runs under
> the creators rights and in this case its the dbo who owns the SP. So far
> so good.

This statement is not entirely correct; the proc doesn't run under the
creator's (owner) rights. Permissions on objects referenced by the proc are
not checked as long as the objects involved have the same owner. This is
called an unbroken ownership chain.

> Why is this? All objects across these databases on the same server are
> owned by the same person... the DBO. so why doesn't this work.

Cross-database ownership chaining is a little confusing because of
login/user mapping. It is not the name of the object owner that controls
the ownership chain, it is the login associated with the object owner.
Since the login mapping for the 'dbo' user is determined by database
ownership, both databases need to have the same owner in order to provide an
unbroken ownership chain for dbo-owned objects.

If you are using SQL 2000 SP3 or above, you need to also enable the 'db
chaining' database option for the databases involved. This should be done
only when you fully trust those users that have permissions to create
dbo-owned objects. See the Books Online for more information.

-- 
Hope this helps.
Dan Guzman
SQL Server MVP
"Steve Le Monnier" <steve_lemon@hotmail.com.nospam.com> wrote in message 
news:OBrDEOh3FHA.2432@TK2MSFTNGP10.phx.gbl...
> I thought I had a reasonable understanding of how Stored Procedure 
> security worked, but I've been caught out by something and now I'm a 
> little puzzled.
>
> When a stored procedure is executed the user calling the SP may not have 
> access to the base tables, but that doesn't matter as the SP runs under 
> the creators rights and in this case its the dbo who owns the SP. So far 
> so good.
>
> However we have split our tables across two database (still on the same 
> server however). We have company data DB's where all requests originate 
> and to save time and duplication we have a central database holding 
> information that is common to all company DB's.
>
> When an SP is executed on a company DB that needs to select data from the 
> central DB, we get a permission denied message.
>
> Why is this? All objects across these databases on the same server are 
> owned by the same person... the DBO. so why doesn't this work.
>
> In order to resolve this it seems I'm going to have to give select 
> permissions on certain tables within this central DB and that is what I 
> was trying to avoid.
>
> Any help on the mechanics of this would be gratefully received
>
> Steve Le Monnier
>
>
> 


Relevant Pages

  • Re: Rights to change an SP
    ... What do you mean by "ownership chain issues"? ... >>I'd like to give a user the rights to change the code a several specific ... >>However I don't want to make him an owner of the database. ...
    (microsoft.public.sqlserver.security)
  • RE: Truncated INSERT statements when using sp_generate_inserts by Vyas
    ... SET NOCOUNT ON ... This procedure is also useful to create a database setup, ... ALSO NOTE THAT THIS PROCEDURE IS NOT UPDATED TO WORK WITH NEW DATA TYPES INTRODUCED IN SQL SERVER 2005 / YUKON ... IF @owner IS NULL ...
    (microsoft.public.sqlserver.programming)
  • Re: SQL 2005 Express-Database does not have a valid owner?
    ... That means that the database's owner is MYDOMAIN\MyUserName ... My design machine is running Windows XP Pro. ... database diagram. ... Database diagram support objects cannot be installed because this ...
    (microsoft.public.sqlserver.security)
  • Re: conflicting object names in sql server 2000
    ... The owner of the object will depend on the user ... On the local database server when it does the select * from ... she must specify the owner: ...
    (microsoft.public.sqlserver.server)
  • Re: unknown database owner
    ... cleared for the 'Admin' user. ... the "owner is unknown" (you described ... An old database, ... Rick Brandt, Microsoft Access MVP ...
    (microsoft.public.access.security)

Quantcast