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

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

问题描述

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

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的用户'DOMAIN \ MACHINENAME $'登录失败
...
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity身份,SqlConnectionString connectionOptions,SqlCredential凭证,对象providerInfo,字符串newPassword,SecureStringnewSecurePassword,布尔重定向用户实例,SqlConnectionStringuserConnectionOptions,SessionData reconnectSessionData,布尔applyTransientFaultHandling

SqlException: Login failed for user 'DOMAIN\MACHINENAME$' 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.

授予DOMAIN \ SERVERNAME $用户ID读写SQL Server数据库.应用程序池需要以NetworkService的身份运行.因此,现在的问题是,如何在SQL Server中将DOMAIN \ SERVERNAME $用户名添加为新登录名?这对于你们中的许多人来说可能是显而易见的,但是它使包括数据库管理员在内的一些人绊倒了.关键是仅在登录名:"文本框中键入DOMAIN \ SERVERNAME $,而不进行搜索.单击确定按钮.然后,您应该能够完成剩下的工作,以将角色等添加到新的登录名中.

Grant DOMAIN\SERVERNAME$ 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 DOMAIN\SERVERNAME$ 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 DOMAIN\SERVERNAME$ 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用户"DOMAIN \ MACHINENAME $"的登录失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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