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?


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: https://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.

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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