数据库连接错误后用户'DOMAIN \ ServerName $'登录失败

问题描述 投票:0回答:1

我们的网站已发布,可以正常运行几天甚至几周。

然后没有任何更改,它突然开始引发数据库连接错误:

错误

System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Data.SqlClient.SqlException (0x80131904): Login failed for user 'DOMAIN\ServerName$'.
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser user)
at System.Data.Linq.SqlClient.SqlProvider.get_IsSqlCe()
at System.Data.Linq.SqlClient.SqlProvider.InitializeProviderMode()
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
at System.Data.Linq.DataContext.ExecuteCommand(String command, Object[] parameters)
at MyClass.Data.Linq.MYDB.MYDBDataContext.OnCreated()

在连接字符串中,我们使用的是正常运行的基本身份验证。

连接字符串

    <add name="MYDBConnectionString" connectionString="server=DBServer;database=MYDB;user=myeuser;pwd=mypassword;Persist Security Info=False;Trusted_Connection=False;Integrated Security=False" providerName="System.Data.SqlClient" />

我的怀疑是,如果出现网络错误,并且该网站下一次尝试向应用程序池用户进行身份验证时,该网站无法访问数据库,并且从那时起,它将忽略连接字符串中设置的用户。

UPDATE:值得一提的是,iisreset或应用程序池回收后,网站可以再次正常运行,但是直到它继续尝试与错误的用户连接时,它才能访问数据库。

如何预防?我希望我的网站始终使用在连接字符串中设置的用户名和密码。

我尝试用不同的方式设置Persist Security InfoTrusted_ConnectionIntegrated Security,但是我找不到正确的组合。

或者我还有其他设置或尝试阻止它退回到应用程序池用户的方法?

我将不胜感激。

linq iis linq-to-sql connection-string iis-10
1个回答
0
投票

似乎您正在使用SQL Server身份验证。在这种情况下,我将检查以下内容。使用SSMS登录到SQL Server,然后转到安全性->登录名->查找用户->属性,并检查未对正在使用的SQL Server用户设置密码过期策略。如果已设置,则您使用的密码可能已过期。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.