Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Maybe I'm getting this wrong, but... I have a SQL Server 2000 database with a stored procedure that is owned by DBO. This stored procedure is calling sp_grantdbaccess, which can be run by DBO, according to MS documentation. and I'm running a Windows user that belongs to a database role that has execute permission on this stored procedure.

If I understand ownership chaining correctly (which I obviously don't), I should be able to run this stored procedure, since it is run with impersonation as DBO.

But alas, it is telling me that the user doesn't have permission to run sp_grantdbaccess.

What can I do to solve this?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Ownership chaining works only inside the database. sp_grantdbaccess lives in master and is therefore excluded from ownership chaining. Even worse, according to the sp_grantdbaccess topic in SQL Server 2000's Books Online:

Only members of the sysadmin fixed server role, the db_accessadmin and db_owner fixed database roles can execute sp_grantdbaccess.

Erland Sommarskog wrote a great article on ownership chaining; however, it covers SQL Server 2005 and later, and there were some significant changes in the security model, so proceed with care when reading.

The only way I can think of to make this work is a hack: Create a loopback linked server and elevate the permissions that way: http://stackoverflow.com/questions/982782/sql-server-2000-execute-as

But be aware that that opens a big security hole.

So my best recommendation - I know you probably don't want to hear this now - is to upgrade to a more modern version of SQL Server.

share|improve this answer
    
Thanks for the detailed explanation. I find it ridiculous that you need to be DBO to run sp_addrolemember, but apparently, until I upgrade to 2012, that's what I'll have to do. –  user884248 Nov 5 '13 at 7:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.