Re: db_owner & multiple databases

From: Dan Guzman (danguzman@nospam-earthlink.net)
Date: 02/19/03


From: "Dan Guzman" <danguzman@nospam-earthlink.net>
Date: Wed, 19 Feb 2003 10:08:00 -0600


The database owner login determines the object owner with dbo-owned
objects and thereby the SID used for ownership chain checking.
Cross-database ownership chaining will be allowed only if:

1) the databases have the same owner as reported by sp_helpdb

2) introduced in SQL Server 2000 SP3, you have enabled chaining at the
server level or at the database level for the databases involved

To lock down your development database, you can specify a different
database owner (using sp_changedbowner) and/or disable cross-database
chaining (using sp_dboption 'db chaining'). Cross database chaining
behavior is described in detail in the Books Online distributed with
SP3.

-- 
Hope this helps.
Dan Guzman
SQL Server MVP
-----------------------
SQL FAQ links (courtesy  Neil Pike):
http://www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
-----------------------
"Vladimri Luzhkov" <vluzhkov@gw.tcs.spb.ru> wrote in message
news:bea9dbb9.0302190744.6545296b@posting.google.com...
> I'm having problem with ability to grant db_owner access for user
> (USER) to only one database (database A).
> The main problem is that this user must have public (for example)
> access to other databases (database B).
> All objects in all databases are owned by dbo.
> So if this user creates stored procedure in it's own database (A) and
> this stored procedure accesses to object in other database (B) user
> gain access to this object in database B without checking permissions.
>
> "Online books" tells in "ownership chains" section:
> "If the same user owns a stored procedure and all the views or tables
> it references, and if the procedure and objects are all in the same
> database, SQL Server checks only the permissions on the procedure."
> But there is no explanation (or i coudnt find it) of situation, when
> objects aren't in the same database.
> How can i brake an ownership chain, when it flows to another database?
>
> 4 example:
> USER exists in db_owner in database A and in public in database B
> We have table B.dbo.Table1 without any permissions (or even with deny
> all permission to USER).
> USER writes stored procedure
> CREATE PROCEDURE A.dbo.prcTest AS
> SELECT * FROM B.dbo.Table1
> GO
> And through this stored procedure by EXEC prcTest USER may read data
> from Table1. :(
>
> db_owner access to database A is needed to develop this database, and
> access to database B is nedded, because SOME (not all) data in
> database B is used by client applications and server-side stored
> procedures in database A.
> I need to maintain abilities of development database A, but to
> restrict USER access to some valuable data in database B.
> How can I keep it together?


Relevant Pages

  • Re: extended stored procedure catch 22
    ... >> user database only if you fully understand the security implications. ... >> preventing direct ad-hoc extended stored procedure execution. ...
    (microsoft.public.sqlserver.security)
  • Re: Extended Stored Procedure: Get the current db of the client
    ... with the caveat that you don't recommend it because Microsoft ... of a stored procedure versus umpteen of the same stored procedure spread ... I am not going after Gert Sue. ... the database context as a parameter if you need it, ...
    (microsoft.public.sqlserver.odbc)
  • Trying to set up a SQL Server Agent Account and I hit a wall....
    ... Our database is on SQL Server 2005, however it is set to compatibility mode ... You may need to set the compatibility level ... of the current database to a higher value to enable this feature. ... for the stored procedure sp_dbcmptlevel. ...
    (microsoft.public.sqlserver.security)
  • Re: Extended Stored Procedure: Get the current db of the client
    ... I am not going after Gert Sue. ... the database context as a parameter if you need it, ... Did you ever write an extended stored procedure? ... different than an extended stored procedure, so that is not giving you want ...
    (microsoft.public.sqlserver.odbc)
  • Re: Extended Stored Procedure: Get the current db of the client
    ... Thanks for the link Sue. ... I am not going after Gert Sue. ... the database context as a parameter if you need it, ... Did you ever write an extended stored procedure? ...
    (microsoft.public.sqlserver.odbc)