Thursday, March 22, 2012

Cannot open user default database. Login failed

Hi,

I have installed SQL Server 2005 Express edition and when i try to run the web site as http://127.0.0.1/SiteName/Login.aspx. I am using default SQL Provider.

Can anyoone please help me? i was struck here from last two days.

System.Data.SqlClient.SqlException: Cannot open user default database. Login failed.

Login failed for user 'XXXXXX\ASPNET'.

Regards,

Pradeep.

hi Pradeep,

please verify the default database for \ASPNET login is available on the target server...

regards

|||See the Security matrix form here:

http://msdn2.microsoft.com/en-us/library/aa302377.aspx

You either can create the ASPNET user on the server, create another one and specify it within the web.config file, or specify in the web.config file, that you want to use impersonation. (Depending on your needs)

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de|||

Hi

Thank U verymuch for the reply. I have created the ASPNET User using Microsoft SQL Server Management Studio Express but the result is same.

How can i see the default database for ASPNET user....

Regards,

Pradeep.

|||

Hi

Thank U for the reply. I have created ASPNET user in the database using Microsoft SQL server Management Studio Express and in web config file i have added

<identity impersonate="true"/>

<authentication mode="Forms" />

but still the reult is same as

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Cannot open user default database. Login failed.
Login failed for user 'MIS-2\ASPNET'.

Hope this might be bug in SQL Server in SQL Server 2005 Express edition.

Regards,

Pradeep

|||

Hi,

ok we are getting closer. The error is related to the fact that you want to redirect to a database where is not granted any access to. Automatic redirection of Users is done in either of the two ways. You have a connection string where no "Inital Catalog"
keyword is specified, then the user will be redirected to his default database which every user has. If you want to change that, you can use the GUI and set the default database to another one where he is granted access to. (You can also use the sp_defaultdb procedure if you prefer the non-Gui version). if you mentioned the "Initial Catalog" in the catalog you will have to make sure that the connecting user (in your case the
ASPNET user) has access to the database mentioned in as the keyword value.

HTH, Jens K. Suessmeyer.


http://www.sqlserver2005.de

|||

Hi,

I am using the default sql provider model.

one more thing is i am having sql server 2000 in (mixed mode authentcation) and sql server 2005 express edition(in windows authentication), is there any problem related to this.

in sql server 2000 i have given the ASPNET user defult database as master and in sql server 2005 i did the same.

so, does these settings has any impact on the default provider model in ASP.NET 2.0?

Regards,

Pradeep

|||

Hi Pradeep,

The error generally comes when the user tried to connect Database for which he don't have access permission so you may use sp_grantdbaccess to grant db access permission and refer below KBs for more

http://support.microsoft.com/kb/321698/en-us

http://support.microsoft.com/kb/316989/en-us

http://support.microsoft.com/kb/824308/en-us

http://support.microsoft.com/kb/821498/en-us

http://support.microsoft.com/kb/308157/en-us

http://support.microsoft.com/kb/301240/en-us

Hemantgiri S. Goswami

|||

An answer provided by monishjain from ASP.net forum

Steps (Windows XP):

Go to Control Panel -> Administrative Tools -> Computer Management -> Local Users and Groups -> Users -> ASPNET

Right Click on ASPNET and select Properties

Go to Member Of tab.

Click on Add -> Advanced -> Find Now

Select SQLServer2005MSSQLUser$<machinename>$SQLExpress

Click on Ok -> Ok - >Apply

Close all the windows and reboot your machine. It should work now.

No comments:

Post a Comment