问题
In my web application on IIS 7.0, I want to make a connection to Sql Database Server for which my user is granted for Windows Authentication. (Integrated Security=SSPI)
Login fails for user 'DOMAIN\COMPUTER_NAME$', however I still can connect to database over connect window of Sql Server Management Studio (with DOMAIN\USER_NAME).
How can I connect to Sql Server over my web application?
回答1:
I've found the solution.
On IIS, open Application Pool settings.
For Identity option, choose "Custom Account".
Enter your username (DOMAIN\USERNAME) and password.
It's done.
回答2:
My problem was that I had to assign the application pool accounts in SQL Server the db_owner role. I felt that was too much permission but it is the only thing that worked. my book said to give it db_datareader and db_datawriter roles but that did not work.
I'm using SQL Server with Windows Authentication, Windows 7 Home Premium with IIS all on the same machine.
Perhaps someone else will search this issue and find my answer useful.
回答3:
Being able to connect to a database is a privilege in itself
You may still need to do something like this to give the IIS service account access
USE [<database name>]
GRANT CONNECT TO '<DOMAIN\COMPUTER_NAME$>'
来源:https://stackoverflow.com/questions/13512328/sql-connection-fails-when-using-integrated-security-on-iis-applications