Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I configure SQL Server to allow access via IIS

Tags:

sql-server

iis

I have a web service that stores data in a local SQL Server 2008 database. If I run the web service under my account the web service can successfully access the database. However, if I use the DefaultAppPool (IUSR) account then accessing the database from the web service fails.

How do I set security on SQL Server to allow access to a specific database via IIS?

The specific error message I am getting is: Login failed for user 'IIS APPPOOL\DefaultAppPool'

like image 878
Calanus Avatar asked Jun 30 '09 16:06

Calanus


People also ask

How does IIS connect to SQL Server?

Click the Add Connection button on the Database Manager toolbar. In the Connection name text box, type a connection name. In the Database provider list, select the provider that you would like to use to connect to the database. (For example, to connect to a SQL Server database, select the System.

How install IIS user in SQL Server?

Right click logins and select "New Login" In the Login name field, type IIS APPPOOL\YourAppPoolName - do not click search. Fill whatever other values you like (i.e., authentication type, default database, etc.) Click OK.

How do I give permission to SQL database?

Right-click a stored procedure and select Properties. In the Stored Procedure Properties -stored_procedure_name dialog box, under select a page, select Permissions. Use this page to add users or roles to the stored procedure and specify the permissions those users or roles have.


2 Answers

You have two options (obvious maybe!):

  • Instead of using Windows Integrated Security use SQL Authentication instead.
  • If you can't or don't want to, then you have to create a new user in SQL Server that relates to that Windows account.
  • Or (third option) you can change the web service to run under an account that you know works.
like image 170
Duncan Avatar answered Oct 09 '22 12:10

Duncan


I generally run the app pool under a domain user account, that way you control the specific user for each site on your server.

If I can't use a domain account, I'll run the site as "Network Service" - and the user that would correspond to that in SQL would be the machine account (MACHINENAME$ - replace "machinename" with your IIS server name").

If you plan to use the new IIS7 IIS users - which are not windows users - you'll have to use SQL Authentication instead of Windows authentication for your SQL database access.

like image 35
Scott Ivey Avatar answered Oct 09 '22 13:10

Scott Ivey