Quantcast
Channel: All Forums
Viewing all articles
Browse latest Browse all 27852

"Login failed for user" failure for SQL Express database with IIS on Windows 7 Home Premium

$
0
0

I am developing a web application using "Visual Studio Express for Web 2012". 
Operating System:  Windows 7 Home Premium with Service Pack 1

I have IIS Version 7.5.7600.16385 installed with ASP.NET via cmd line - "C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i"

In my web application I open a connection to a SQL Server Express database named "CurriculumBuilder.mdf" that I created in my ".\App_Data" subfolder.

My project is in a local folder ("C:\Users\<MyUserName>\Documents\Visual Studio 2012\Projects\Websites\CurriculumBuilder").

The connection string when running the web application from Visual Studio is:
"Data Source=(LocalDb)\v11.0;Initial Catalog=CurriculumBuilder;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|CurriculumBuilder.mdf"

When I run my web application from Visual Studio, the connection opens just fine and I can work with the database as expected.  However, when I copy the project to IIS and attempt to open the connection, it fails.

Here are the details for IIS setup:
1)  I have created a user named "CurriculumBuilder" with Adminstrator Privileges on my computer.
 - Set a password.

2)  I created a "CurriculumBuilder" application pool using these settings:
- .NET Framework = v4.0
- Managed Pipeline Mode = Integrated
- Identity - "<MachineName>\CurriculumBuilder" (the user with Admin priveleges)
- All other settings are the defaults

3)  I copied my web application project to "C:\inetpub\wwwroot\CurriculumBuilder" (a subdirectory under the "Default Web Site" in IIS).  I then converted it to an application in IIS (Rt. Click in IIS on the subdirectory and hit "Convert to Application"). 
I gave it the alias "CurriculumBuilder".
Application Pool = "CurriculumBuilder"

4)  Modify the web.config to change the connection string to:
"Data Source=.\SQLEXPRESS;Initial Catalog=CurriculumBuilder;Integrated Security=SSPI"

5)  Edit the permissions for "C:\inetpub\wwwroot\CurriculumBuilder"
- Added the "<MachineName>\CurriculumBuilder" user and gave that user "Full Control"
- Gave "IIS_IUSR" and "NETWORK_SERVICE" Full Control
- In Advanced Security Settings for CurriculumBuilder
 - Select "Replace all child object permissions with inheritable permissions from this object"

6)  Configure the Properties for the SQL Server (SQLEXPRESS) Service
- Open "%windir%\system32\services.msc", Select "SQL Server (SQLEXPRESS)" service, Rt. Click, Properties
 - In the "Log On" tab, select "This account", the "Browse", Advanced, Find Now,
  Select "CurriculumBuilder" as the user, Hit "OK" twice. 
  Set the password to be the same as is being used for the machine login (step 1)

When I attempt to open the connection via IIS, it fails with this exception:

Exception opening connection to database using Connection String:

Data Source=.\SQLEXPRESS;Initial Catalog=CurriculumBuilder;Integrated Security=SSPI

Cannot open database "CurriculumBuilder" requested by the login.
The login failed.

Login failed for user '<MachineName>\CurriculumBuilder'.

I have read several blogs about this error and it seems like these steps should work, but they are not working.


Viewing all articles
Browse latest Browse all 27852

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>