How to handle "create database permission denied in database master" in windows Authentication? - asp.net

I opened "ASP.NET SQL Server Setup Wizard" using the command apsnet_regsql from visual studio 10 command propmpt(Run as Administrator).
In that wizard I selected Windows Authentication instead of Sql Authentication. When I tries to connect to Master Database I am getting the following exception
An error occurred during the execution of the SQL file 'InstallCommon.sql'. The SQL error number is 262 and the SqlException message is: CREATE DATABASE permission denied in database 'master'. Creating the TestDB database
and the SqlException is:
create database permission denied in database 'master' in windows authenticAtion.
By the exception I understand that I don't have permission to create database. But how and where can I get permission to do that.
i have SQL Server 2008 in my system which comes as default with Visual Studio 2008 only.
So please help me and give a solution for my problem.Thanks

Obviously the reason why this is happening is because the user does not have the permission in sql sever to do any modification one of the ways to solve it would be to go to security folder chose user select properties might be permissions and make this user a dbadministrator or other advanced role than login with this user and try to create the database
here are couple of articles
http://msdn.microsoft.com/en-us/library/dd568727.aspx
http://msdn.microsoft.com/en-us/library/ms178630(v=sql.90).aspx
http://www.blackwasp.co.uk/SQLChangeOwner.aspx

Related

Login failed for user '' IIS

Im currently trying to deploy my .NET MVC Application to IIS 7.5.
There is a database connection problem that im trying to figure out. In localhost, everything seems fine, however, when I deploy my app to remote server, the app runs, without connecting to database. For example I have a VisualLeadController that has getMonthlyLeadsByYear() method that connects to database and retyrns data. When I try to execute it from brower by typing
http://staging2.landornet.com/WebLeadsVisualizer/VisualLead/getMonthlyLeadsByYear
It generates this error:
Exception Details: System.Data.SqlClient.SqlException: Login failed for user ''.
The steps that I followed:
1-Removed integrated security=True from WebConfig connection strings
2- Changed applicationpool identity from applicationPoolIdentity to local system.
Still now working... anyone has any idea?
When deploying your web app to your remote server, you will need to use a SQL connection string that contains an explicit username and password associated with a SQL account. For example,
Data Source=SERVER;Initial Catalog=DATABASENAME;User ID=SQLUSERNAME;Password=SQLUSERPASSWORD
To use this connection string, you will need to first use SQL Management Studio to create a SQL login with a username and password, and give that user access to your database. Then log out out of SQL Management Studio and log back in using that user/password to make sure that it correctly can access your database. Hopefully then your web app should be able to connect to the database.

Granting sql server database access to IIS APPPOOL\DefaultAppPool

I have an ASP NET APP that's trying to access a sql server database, when I run it, I get an error saying
"Login Failed for user IIS APPPOOL\DefaultAppPool"
Searching the web I found that I should grant access to this user, so I executed the following script:
grant execute on schema :: dbo to [IIS APPPOOL\DefaultAppPool]
It executed succesfully as a script for my database, but I still get the "Login Failed" error.
What's missing?
Check the user your DefaultAppPool is using to connect.
On your IIS manager check DefaultAppPool advanced properties and look for Identity. You need to give it a user with enough privileges, depending on what your site is going to do.
I usually create different AppPools for different sites depending on what they will do, for example, if your app will write documents to a folder on your server, the user of the AppPool will need writing access to that folder.
Also is not a good idea to use an administrator user, as it could lead to potential security breaches. However it could be a good way to check if your problem comes from there.
I think I already know what it is. When I upgraded SQL Server Express, it installed a new server .\SQLEXPRESS (because I used "new sql instance"), remote connections where configured in this server and not LocalDB, my database was still in LocalDB. But now I get other error, maybe related to WCF Data Services...

connect mvc3 application to remote sql server

i publish an mvc3 application on a webserver IIS7 and i want to connect my application with a remote SQL server ( different machine)
here is my connection string:
connectionstring="server=server;database=db;user Id=user;password=psw;user instance=false" providername="System.Data.SqlClient"
i m using entityframework.
i also added the user in the connectionstring to security folder under database in sql management studio with dbo rights.
the problem is i get an error : failed to open a session for the user
SQL exception (0x80131904)
Have you checked the user mapping for the login?
You can find the logins under the server folder security -> logins.
Check there is a login mapped to the database user. Select the appropriate login -> properties -> user mapping tab.
The fact that a user exists in a database, does not directly mean that there is a valid login associated with that user. Ensure that a login maps to the database user and that the user has the required database role.
After hours of research i just figure out that adding the whole groupe of computers (Domain\Computers) granted me the access to the database. i changed my connectionstring to use integrated security= sspi. From the beginning it was a Connection problem.

How to handle "create database permission denied in database 'master' in windows authentication exception?

I opened "ASP.NET SQL Server Setup Wizard" using the command apsnet_regsql from visual studio 10 command propmpt(Run as Administrator).
In that wizard I selected Windows Authentication instead of Sql Authentication. When I tries to connect to Master Database I am getting the following exception
An error occurred during the execution of the SQL file 'InstallCommon.sql'. The SQL error number is 262 and the SqlException message is: CREATE DATABASE permission denied in database 'master'.
Creating the TestDB database
and the SqlException is:
create database permission denied in database 'master' in windows authenticAtion.
I understand that I don't have permission to create database. But how and where can I give permission to do that.
So please help me and give a solution for my problem.Thanks.
You need to login as a user who is a member of the sysadmin or dbcreator roles.

MS SQL update to Integrated Security

For debugging purpose, I backedup one of QA database and restored to local machine. Since it is in my local machine, I just want to connect to it using Integrated Security=True in my asp.net application. But I am getting following error:
Cannot open database "db1" requested
by the login. The login failed. Login
failed for user "DEV-LPTP-1784\ASPNET".
Any thoughts?
Thanks.
Delete and recreate database login you use. After db restore the database user has the same name, but inner SQL Server id is different, so SQL Server thinks that server login "DEV-LPTP-1784\ASPNET" is different than db user "DEV-LPTP-1784\ASPNET"
The user that ASP.NET is running under does not have access to that database. You can either grant that user access via SQL Management Studio, or change your connection string to use a specific username and password.

Resources