【问题标题】:Connecting IIS to SQL Server 2014 on Windows Server 2012在 Windows Server 2012 上将 IIS 连接到 SQL Server 2014
【发布时间】:2016-01-07 20:19:35
【问题描述】:

我不断收到错误

'无法打开登录请求的数据库“mydb”。登录失败。用户“NT Authority\NETWORK SERVICE”'登录失败

这是我的连接字符串

SqlConnection _connection = new SqlConnection("Data Source='MYSERVER\\SE';Initial Catalog=mydb;Integrated Security=True;MultipleActiveResultSets=True; Trusted_Connection=Yes");

相同的 Web 表单可以本地连接到 Windows 8.1 上的 SQL Server。

这是为什么?

【问题讨论】:

    标签: c# sql-server windows-8.1 windows-server-2012 iis-8.5


    【解决方案1】:

    在您的连接字符串中,Integrated Security=True 导致它尝试使用运行 IIS 的帐户登录到 SQL Server。

    根据您的描述,您的 8.1 机器上运行的 IIS 使用有权访问您的 SQL Server 的帐户运行。

    您可以将网络服务帐户作为有效登录名添加到 SQL Server,将 IIS 在服务器上启动时使用的帐户更改为已经有权访问 SQL Server 的帐户,或在连接字符串中指定 SQL 登录名而不是使用集成安全性。

    【讨论】:

    • 没有像在 Windows 8 中那样将网络服务登录添加到数据库。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-20
    • 2015-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多