简体   繁体   中英

Configure IIS 8 for SQL Server Authentication

I'm getting the following error when trying to query SQL Server 2012 from Windows 2012 IIS 8.5, in an MVC 4 website:

SqlException (0x80131904): Login failed for user [domain/user]

I have the connection string in Web.config set up just the way we did it back in the olden days:

<add name="MYPROJECT.Properties.Settings.defaultConn" connectionString="Data Source=MYSERVER;Initial Catalog=MYDATABASE;Persist Security Info=True;User ID=MYUSER;Password=MYPASSWORD"

IIS8 seems to be using an Application Pool to login, bypassing the connectionstring in Web.config.

Database and Website are on different servers. Is there a straightforward way that I can configure IIS to bypass the Application Pool and read the connectionstring from Web.config?

If Persist security info is set to true, it will be ignored. From MSDN

The ConnectionString is similar to an OLE DB connection string, but is not identical. Unlike OLE DB or ADO, the connection string that is returned is the same as the user-set ConnectionString, minus security information if the Persist Security Info value is set to false (default). The .NET Framework Data Provider for SQL Server does not persist or return the password in a connection string unless you set Persist Security Info to true.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM