gpt4 book ai didi

SQL Server 可信连接在 IIS 中的用户错误,但 SSMS 正常

转载 作者:行者123 更新时间:2023-12-04 18:03:22 27 4
gpt4 key购买 nike

我正在使用 VS 2012,使用 Windows 凭据连接到 SQL Server 2008 主机。我可以从 Management Studio 正常连接,但是当我运行 Web 应用程序(集成 IIS 7.5 windows 7 ASP.NET 4.0)并且我的应用程序尝试连接时,我得到了这个:

Login failed for user 'MyDomain\MyMachineName$'.



出于某种原因,使用网络标识的 IIS 应用程序池不使用 MyUserName 而是使用我的机器名称。我的连接字符串是:
<connectionStrings>
<clear />
<add name="Assignment"
connectionString="Data Source=a.b.c.d;Initial Catalog=My_Db;Trusted_Connection=true;Max Pool Size=200;Pooling=True;" />
</connectionStrings>

我应该提到这是一台新的(对我来说)电脑。我查看了凭证管理器,那里什么也没有。任何想法为什么 IIS 和我的 Web 应用程序使用错误的东西?

最佳答案

当您在网络服务标识下运行应用程序池时,IIS 实际上正在执行它的设计目的。

Using the Network Service account in a domain environment has a greatbenefit. Worker process running as Network Service access the networkas the machine account. Machine accounts are generated when a machineis joined to a domain. They look like this:

<domainname>\<machinename>$,

For example: mydomain\machine1$

The nice thing about this is that network resourceslike file shares or SQL Server databases can be ACLed to allow thismachine account access.


上面的引用来自以下文档...
http://www.iis.net/learn/manage/configuring-security/application-pool-identities
希望这能回答为什么它没有按您期望的方式工作的问题。
至于如何让它按照你想要的方式工作,我认为这篇文章应该回答这个问题,如果没有,一些基本的谷歌搜索应该会提供很多关于如何正确配置你的环境的信息。重新尝试做。
https://gilesey.wordpress.com/2013/05/11/allowing-iis-7-5-applications-to-communicate-to-sql-server-via-windows-authentication/

关于SQL Server 可信连接在 IIS 中的用户错误,但 SSMS 正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31416666/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com