1

I have IIS and SQL Server Express on the same machine. After deployment of web site to this environment I get this error:

Cannot open database "MyDB" requested by the login. The login failed. Login failed for user 'IIS APPPOOL\USER'.

Here are my connection strings where I set SQL Server user

<connectionStrings>
    <add name="myCS1" 
         connectionString="data source=172.20.3.20\SQLEXPRESS;initial catalog=MyDB;user id=SomeUser;password=SomeUser###;integrated security=True;MultipleActiveResultSets=True;" 
         providerName="System.Data.SqlClient" />
    <add name="myCS2" 
         connectionString="metadata=res://*/CLModel.csdl|res://*/CLModel.ssdl|res://*/CLModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=172.20.3.20\SQLEXPRESS;initial catalog=myDB;persist security info=True;user id=SomeUser;password=SomeUser###;MultipleActiveResultSets=True;App=EntityFramework&quot;" 
         providerName="System.Data.EntityClient" />
</connectionStrings>

I want to use SQL Server user for connection to the database but not AppPool user.

I specified login and password but it seems that this info is not taken in account and in error message I still see IIS user but not sql.

What I missed?

1 Answer 1

2

Well, you specify both - explicit user id and password, and Integrated Security=True - in your myCS1 connection string:

data source=172.20.3.20\SQLEXPRESS;initial catalog=MyDB;
  user id=SomeUser;password=SomeUser###;integrated security=True;  

In this case, the integrated security wins over your user - you need to specify only the user id and password and get rid of the integrated security - so use this:

<connectionStrings>
    <add name="myCS1" 
         connectionString="data source=172.20.3.20\SQLEXPRESS;initial catalog=MyDB;user id=SomeUser;password=SomeUser###;MultipleActiveResultSets=True;" 
         providerName="System.Data.SqlClient" />
    <add name="myCS2" 
         connectionString="metadata=res://*/CLModel.csdl|res://*/CLModel.ssdl|res://*/CLModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=172.20.3.20\SQLEXPRESS;initial catalog=myDB;persist security info=True;user id=SomeUser;password=SomeUser###;MultipleActiveResultSets=True;App=EntityFramework&quot;" 
         providerName="System.Data.EntityClient" />
</connectionStrings>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.