I have a Sitefinity ASP.NET web site which has a database Db1. I have the database attached to SQL Server Management Studio.
When I run the ASP.NET application, it doesn’t seem to have permission to access the database. Sitefinity fails to connect to the existing db, then tries to create a new db, which it throws this error:
CREATE DATABASE permission denied in database ‘master’
The connection string is:
<add connectionString="data source=localhost\sqlexpress;Integrated Security=SSPI;initial catalog=Db1" providerName="System.Data.SqlClient" dbType="MsSql" name="Sitefinity" />
In SQL Management Studio, I connect to the localhost\SQLEXPRESS instance using Windows Authentication.
I think the problem is, I need to give the ASP.NET process user, permission to access the database Db1. Where can I find this user and how can I give permission?
I’m also unsure if the app should be using a proper SQL Server user to connect instead of Windows Authentication.
The most direct, and portable/deployable, solution, is to switch to SQL Server Authentication.
In SSMS, expand the security tab for the server, and add a user with a suitable name and password. Be sure to uncheck the “must change password at next logon” checkbox.
Then, expand the security tab for the database, add the user, and add it to whatever roles are necessary. For debugging you may just want to add it to the db owner role.
This is helpful because all of the relevant settings are stored within your app config and the database itself, making deployent a cinch, and you don’t need to worry about keeping application user accounts updated when passwords expire, etc.