简体   繁体   English

如何配置SQL Server以允许通过IIS进行访问

[英]How do I configure SQL Server to allow access via IIS

I have a web service that stores data in a local SQL Server 2008 database. 我有一个Web服务,将数据存储在本地SQL Server 2008数据库中。 If I run the web service under my account the web service can successfully access the database. 如果我在我的帐户下运行Web服务,则Web服务可以成功访问数据库。 However, if I use the DefaultAppPool (IUSR) account then accessing the database from the web service fails. 但是,如果我使用DefaultAppPool(IUSR)帐户,则从Web服务访问数据库失败。

How do I set security on SQL Server to allow access to a specific database via IIS? 如何在SQL Server上设置安全性以允许通过IIS访问特定数据库?

The specific error message I am getting is: Login failed for user 'IIS APPPOOL\\DefaultAppPool' 我得到的具体错误消息是:用户'IIS APPPOOL \\ DefaultAppPool'登录失败

You have two options (obvious maybe!): 你有两个选择(显然可能!):

  • Instead of using Windows Integrated Security use SQL Authentication instead. 而不是使用Windows集成安全性而是使用SQL身份验证。
  • 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. 如果您不能或不想,则必须在SQL Server中创建与该Windows帐户相关的新用户。
  • Or (third option) you can change the web service to run under an account that you know works. 或者(第三个选项)您可以将Web服务更改为在您知道有效的帐户下运行。

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"). 如果我不能使用域帐户,我将以“网络服务”运行该站点 - 与SQL中的对应的用户将是机器帐户(MACHINENAME $ - 用您的IIS服务器名称替换“machinename” “)。

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. 如果您计划使用新的IIS7 IIS用户(不是Windows用户),则必须使用SQL身份验证而不是Windows身份验证来进行SQL数据库访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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