SqlException:使用 .NET Core 2.1 的 SQL Server 的用户“DOMAINMACHINENAME$"登录失败 [英] SqlException: Login failed for user 'DOMAINMACHINENAME$' for SQL Server with .NET Core 2.1

查看:27
本文介绍了SqlException:使用 .NET Core 2.1 的 SQL Server 的用户“DOMAINMACHINENAME$"登录失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的连接字符串的内容.它是一个 .NET Core 2.1 Web 应用程序.当我在我的 PC 上运行时,它工作正常.当我将其部署到 IIS 并运行它时,会出现此错误.详细错误在appsetting之后.

Here is the contents of my connection string. It is an .NET Core 2.1 web application. When I run on my PC, it works fine. When I deploy it to IIS and run it, this error will occur. The detailed error is after the appsetting.

"Testing2012Context": "Server=Server;Database=Testing2012;User ID=User;Password=Pwd;Trusted_Connection=False;MultipleActiveResultSets=true"

错误:

SqlException:使用 .NET Core 2.1 的 SQL Server 的用户DOMAINMACHINENAME$"登录失败
...
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity身份,SqlConnectionString 连接选项,SqlCredential凭据、对象 providerInfo、字符串 newPassword、SecureStringnewSecurePassword, bool redirectedUserInstance, SqlConnectionStringuserConnectionOptions, SessionData reconnectSessionData, boolapplyTransientFaultHandling

SqlException: Login failed for user 'DOMAINMACHINENAME$' for the SQL Server with .NET Core 2.1
...
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, object providerInfo, string newPassword, SecureString newSecurePassword, bool redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, bool applyTransientFaultHandling

推荐答案

出现错误的原因是 iis 应用程序池在本地机器帐户下运行.此帐户没有任何权限访问您的 SQL Server.

The reason behind the error is iis application pool is running under the local machine account. This account does not have any permission to access your SQL Server.

要解决此问题,您可以尝试以下解决方案:

To resolve this issue you could try the below solutions:

1) 打开 iis 管理器.选择您的应用程序池.

1)open iis manager. Select your application pool.

2)点击操作面板中的高级设置.

2)click on advance setting from the action pane.

3)在流程模型下,单击身份"值并选择自定义帐户"或使用网络服务帐户.

3)Under Process Model, click on the "Identity" value and select "Custom account" or use network service account.

4) 输入您的域用户名和密码,然后单击确定以应用更改.

4)enter your domain user name and password and click ok to apply the changes.

5) 应用更改后,选择应用程序池并单击回收".

5)after applying changes select the application pool and click on the "Recycle".

6) 重新启动您的网站.

6)restart your site.

授予 DOMAINSERVERNAME$ 用户 ID 对 SQL Server 数据库的读取和写入权限.应用程序池需要以NetworkService 的身份运行.那么现在的问题是如何在 SQL Server 中添加 DOMAINSERVERNAME$ 用户名作为新登录名?这对你们中的许多人来说可能很明显,但它让一些人绊倒,包括这里的一些 DBA.关键是在登录名:文本框中键入 DOMAINSERVERNAME$ 而不进行搜索.立即单击确定"按钮.然后,您应该可以完成剩下的工作,将角色等添加到新登录名中.

Grant DOMAINSERVERNAME$ user-id read and write to the SQL Server database. The application pool needs to run under the identity of NetworkService. So now the question is how do you add DOMAINSERVERNAME$ username as a new login in SQL Server? This may be obvious to many of you, but it tripped a few people including some DBAs here. The key is just to type the DOMAINSERVERNAME$ in the Login name: text box without searching it. Click OK button right away. Then you should be able to do the rest to add the roles, etc to the new login.

这篇关于SqlException:使用 .NET Core 2.1 的 SQL Server 的用户“DOMAINMACHINENAME$"登录失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆