Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The EXECUTE permission was denied on the object 'aspnet_CheckSchemaVersion', database 'XXX'

I use asp.net 4 C# and entity framework 4 with MS SQL 2008. I'm trying to set up my web application locally using IIS 7.

For my website I user Asp membership provider which has installed different tables and sprocs in my db (aspnet_).

Running the script we receive this error:

The EXECUTE permission was denied on the object 'aspnet_CheckSchemaVersion', database 'XXX', schema 'dbo'. at System.Data.SqlClient.SqlConnection.OnError

How can I solve the problem?

like image 985
GibboK Avatar asked Oct 10 '11 09:10

GibboK


People also ask

How do you fix the Execute permission was denied on the object?

This can be done from SQL Management Studio or directly by SQL query: - Right click on the specific stored procedure, select Properties, go to Permissions page. Search for 'ComXClient' user and then select checkbox in Execute line and Grant column.

Does Db_owner have execute permission?

Btw, db_owner is a database ROLE in SQL Server , not a permission. Or if you want the user to execute all current and future stored procedures and scalar-valued functions: grant execute on schema::dbo to User for a single schema, or just grant execute to User for the whole database.


2 Answers

There should be some db roles related to the membership tables, eg aspnet_profile_fullaccess. Make sure the account you're using is a member of the appropriate role.

You should NOT assign the user you connect to the DB as dbowner privilege. The account should have only the rights it needs & nothing more. If you grant dbo & someone were to exploit a flaw in your website they would have full uncontrolled access to your entire db to what they wanted - delete tables, change data at will.

like image 111
Simon Halsey Avatar answered Oct 06 '22 19:10

Simon Halsey


I don't think you should make the user the db_owner. I had the same problem, and it was sufficient to grand the 4 roles with BasicAccess to my user + to give him EXECUTE permission on all stored proc:

GRANT EXECUTE TO [theUserName];

I know this is not ideal. One should grant EXECUTE permissions only on the required stored proc, but if you need a quick solution until you find which SP's your user needs to be able to execute, this should work.

like image 26
Jean-François Beauchamp Avatar answered Oct 06 '22 18:10

Jean-François Beauchamp