【问题标题】:IIS is changing the database username from "MyUser" to "IIS APPPOOL\MyUser"IIS 正在将数据库用户名从“MyUser”更改为“IIS APPPOOL\MyUser”
【发布时间】:2019-01-15 02:42:10
【问题描述】:

我有一个在 ASP.NET Core 2.2 框架之上使用 c# 编写的应用程序。

尝试连接到 SQL Server 时出现以下错误。

SqlException:无法打开数据库“MyDataBase”请求的 登录。登录失败。用户 'IIS APPPOOL\MyUser' 登录失败。

由于某种原因,它添加了IIS APPPOOL\,这使用户无效。

如何更改它以使用MyUser 而不是IIS APPPOOL\MyUser 登录?

这是连接字符串

Server=MyServerName;Database=MyDatabase;Trusted_Connection=True;security = false;MultipleActiveResultSets=true;user id=MyUser;Password=MyPassword

【问题讨论】:

    标签: sql-server iis


    【解决方案1】:

    Trusted_Connection=True(相当于Integrated_Security=True)表示使用Windows凭据。删除它,它将使用您的用户名/密码。

    来自微软网站:

    Windows 身份验证优先于 SQL Server 登录。如果你 同时指定 Integrated Security=true 以及用户名和 密码,用户名和密码将被忽略,Windows 将使用身份验证。

    https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/connection-string-syntax

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-11
      • 2013-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-18
      • 2013-05-01
      相关资源
      最近更新 更多