简体   繁体   English

IIS没有将凭据传递给Web服务进行数据库连接

[英]IIS not passing credentials to webservice for database connections

I've spent the whole day trying to work this out. 我花了一整天的时间来解决这个问题。 I have a new webservice that works fine when included as a project reference inside the same solution. 我有一个新的Web服务,当作为项目参考包含在同一解决方案中时,它可以正常工作。 But now I need to publish it to my local IIS so somebody else can test against it. 但是现在我需要将其发布到本地IIS,以便其他人可以对其进行测试。 I have applied the correct application pool to the site. 我已将正确的应用程序池应用于该站点。 The application pool is set to use Intergrated pipeline and has the correct active directory identity. 应用程序池设置为使用集成管道,并具有正确的活动目录标识。

The connection string in the config file has "integrated security=True". 配置文件中的连接字符串具有“ integrated security = True”。

When the webservice sets up the connection string, it has no credentials and I get the following exception when the connection is opened: "Login failed for user ''. Reason: An attempt to login using SQL authentication failed. Server is configured for Windows authentication only. [CLIENT: ]" 当Web服务设置连接字符串时,它没有凭据,打开连接时出现以下异常: “用户登录失败”。原因:尝试使用SQL身份验证登录失败。服务器配置为Windows身份验证仅。[客户:]”

When I check my database Server Properties -> Security -> Server Authentication, it has "SQL Server and Windows Authentication mode" checked. 当我检查数据库的服务器属性->安全性->服务器身份验证时,它已选中“ SQL Server和Windows身份验证模式”。

I also confirmed that the AD account has access to the database as well. 我还确认了AD帐户也可以访问数据库。

I have looked at all kinds of other posts but can't find one that offers a solution that works for me. 我看过各种其他文章,但找不到提供适合我的解决方案的文章。 I must be missing something simple and just can't see it. 我一定错过了一些简单的东西,只是看不见。

What am I missing? 我想念什么?

Here is my config file: 这是我的配置文件:

 <configuration> <system.web> <compilation debug="true" targetFramework="4.6.1" /> <httpRuntime targetFramework="4.5.2" /> <httpModules /> </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <modules /> </system.webServer> <connectionStrings> <add name="CoreServices" connectionString="data source=localhost;initial catalog=CoreServices;integrated security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" /> </connectionStrings> </configuration> 

Try adding this line to your web.config: 尝试将以下行添加到您的web.config中:

<authentication mode="Windows"/>

Add it in your <System.Web> tag. 将其添加到您的<System.Web>标记中。

That connection string will not cause that error. 该连接字符串不会导致该错误。 Try hard-coding the connection string in your application code to troubleshoot. 尝试在应用程序代码中硬编码连接字符串以进行故障排除。

It turns out the connection string wasn't being retrieved from the config file. 原来没有从配置文件中检索到连接字符串。 I am having to reuse another project that provides database access. 我不得不重用另一个提供数据库访问的项目。 It was expecting the connection string to be in the app settings section. 期望连接字符串位于“应用程序设置”部分中。

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

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