question

nicolfishn86-4332 avatar image
1 Vote"
nicolfishn86-4332 asked nicolfishn86-4332 published

IIS Worker Process using computer account as Identity when Identity set to specific user

.NET webforms app & Sql Server database.

We have a fairly typical setup in our local develop environments. We run the worker process as ourselves and use "Integrated Security=True" on our Sql connection strings. In our dev databases, we have full access. Our production systems run under App Pool identities.

Recently, some developers have been having an issue that results in the following stack trace which indicates that the local computer is being used for database connections. We have verified that the app pool Identity is correctly set to the user and the password is correct. There are even Event Log -> Security events showing the successful login of that user and process. The same place that errors would show up if, for example, the user's password was not set correctly.

The problem persists for a while and then just seems to go away. Some devs say that one recreation of the app pool makes it go away, but for others that doesn't seem to help. On developer spent half a day recreating site/pools, rebooting, etc with nothing working and then just suddenly the problem went away.

Does anyone know of an non-obvious reasons that something would cause the worker process to act like this ASP.net?

Server Error in '/' Application.

Login failed for user '{DOMAIN}{COMPUTER NAME}'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Login failed for user '{DOMAIN}{COMPUTER NAME}'.

Source Error:

Line N
conn.Open() Line 37: Line 38:

Source File: ... APP CODE line number N Line: 36

Stack Trace:

[SqlException (0x80131904): Login failed for user '{DOMAIN}{COMPUTER NAME}'.]
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager) +1524
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +467
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +70
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +940
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +111
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1567
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +118 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +268
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) +315 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry) +128
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +265 System.Data.SqlClient.SqlConnection.Open() +133
... SNIPPED APP CODE ... System.Web.UI.Page.OnPreInit(EventArgs e) +11691288
System.Web.UI.Page.PerformPreInit() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +335

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4330.0


windows-server-iis
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

SamWu-MSFT avatar image
0 Votes"
SamWu-MSFT answered

Hi @nicolfishn86-4332

This error occurs when you have configured your application with IIS, and IIS goes to SQL Server and tries to login with credentials that do not have proper permissions. you can try this solution: Go to SQL Server >> Security >> Logins and right click on NT AUTHORITY\NETWORK SERVICE and select Properties, in newly opened screen of Login Properties, go to the “User Mapping” tab. Then, on the “User Mapping” tab, select the desired database – especially the database for which this error message is displayed. On the lower screen, check the role db_owner. Click OK.


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.