sql-serverasp.net-mvciis-7connection-stringwindows-authentication

I need to connect my web application to sql server using windows authentication with a different user


I have a web application (on IIS 7.0) developed with ASP.NET MVC 4. The application manages a database on a SQL Server 2008 R2. Only Windows Authentication is enabled on the site. In my intranet, the domain users access the program without authentication requests. web.config sets a connection string on the site that uses a sql user. All operations on the database are done by this last user. The application should access the database with a windows user instead of a sql user. For this, I created a windows user “MyUser” on Sql Server. I thought I could set a new “connection string” with windows authentication but I wasn't able to pass the credential of “MyUser”. When I set windows authentication on the connection string it uses the client user, and I don't want this.

How I can operate on the database with a different user? I would like all operations on database to be performed by a single windows user (MyUser).


Solution

  • You can give "MyUser" privileges over the folder where your app is. Then you can create an application pool and set the identity to "MyUser" (read this) and assign your app to this application pool.

    Your application will be executing with "MyUser" account thus login into SQL with its credentials.