Sunday, February 19, 2012

ASPNET account can't connect to MSSQLSERVER

When I try to access my PasswordRecovery.aspx page I get an error. I've also added the Event Warning and the Failure Audit. I've tried deleting the ASPNET user account and recreating it using aspnet_regiis.exe. I still get the same error message. Should I add the ASPNET account to the Administrators group? Currently it is with the Users group.

Login failed for user 'PC325862970629\ASPNET'.

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 'PC325862970629\ASPNET'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[SqlException (0x80131904): Login failed for user 'PC325862970629\ASPNET'.]

System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734979

System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188

System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838

System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33

System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +628

System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +170

System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +359

System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28

System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424

System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66

System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +496

System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82

System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105

System.Data.SqlClient.SqlConnection.Open() +111

System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) +84

System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +197

System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate) +1121

System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat) +105

System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved) +42

System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password) +83

System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +160

System.Web.UI.WebControls.Login.AttemptLogin() +105

System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +99

System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35

System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +115

System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +163

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7

System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11

System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

When I check my Events log I see this warning:

-

Event Type: Warning
Event Source: ASP.NET 2.0.50727.0
Event Category: Web Event
Event ID: 1309
Date: 8/24/2006
Time: 5:13:54 PM
User: N/A
Computer: PC325862970629
Description:
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 8/24/2006 5:13:54 PM
Event time (UTC): 8/25/2006 12:13:54 AM
Event ID: b3b1e4fbbd634d04a5acd3de09a4df88
Event sequence: 22
Event occurrence: 7
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1/Root/Aidms-1-128009374139687500
Trust level: Full
Application Virtual Path: /Aidms
Application Path: C:\aidms\
Machine name: PC325862970629
Process information:
Process ID: 5128
Process name: aspnet_wp.exe
Account name: PC325862970629\ASPNET
Exception information:
Exception type: SqlException
Exception message: Login failed for user 'PC325862970629\ASPNET'.
Request information:
Request URL: http://localhost/Aidms/Default.aspx
Request path: /Aidms/Default.aspx
User host address: 127.0.0.1
User:
Is authenticated: False
Authentication Type:
Thread account name: PC325862970629\ASPNET
Thread information:
Thread ID: 1
Thread account name: PC325862970629\ASPNET
Is impersonating: False
Stack trace: at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate)
at System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation)
at System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate)
at System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat)
at System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved)
at System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password)
at System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e)
at System.Web.UI.WebControls.Login.AttemptLogin()
at System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Custom event details:

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

And then I see this Failutre Audit

--

Event Type: Failure Audit
Event Source: MSSQLSERVER
Event Category: (4)
Event ID: 18456
Date: 8/24/2006
Time: 5:13:54 PM
User: PC325862970629\ASPNET
Computer: PC325862970629
Description:
Login failed for user 'PC325862970629\ASPNET'. [CLIENT: <local machine>]

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Data:
0000: 18 48 00 00 0e 00 00 00 .H......
0008: 0f 00 00 00 50 00 43 00 ....P.C.
0010: 33 00 32 00 35 00 38 00 3.2.5.8.
0018: 36 00 32 00 39 00 37 00 6.2.9.7.
0020: 30 00 36 00 32 00 39 00 0.6.2.9.
0028: 00 00 07 00 00 00 6d 00 ......m.
0030: 61 00 73 00 74 00 65 00 a.s.t.e.
0038: 72 00 00 00 r...

The security folks may be able to answer this more quickly.

Thanks,
Sam

|||Is your ASP.NET app and SQL Server both in the same machine?|||Yes both ASP and SQLSERVRER are running on the same machine.|||

Can you have a look at the errorlog file of SQL Server and copy the error logged there? It should be under the LOG directory of your installation. A new log is created after each restart, so you may have to look at several files to find the one that contains this error.

Also, have you allowed the ASPNET account to access your SQL Server installation? Did this connection ever work or is it the first time you tried it?

Thanks
Laurentiu

|||I didn't have to allow the ASNET account access to my SQL Server installation before because it was working fine. Can you please give me the instructions to allow access to my SQL server?

Below is the log file from SQL server that I believe ties in to the above problem.
-
2006-08-24 16:55:27.06 Server Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)
Oct 14 2005 00:33:37
Copyright (c) 1988-2005 Microsoft Corporation
Standard Edition on Windows NT 5.1 (Build 2600: Service Pack 2)

2006-08-24 16:55:27.06 Server (c) 2005 Microsoft Corporation.
2006-08-24 16:55:27.06 Server All rights reserved.
2006-08-24 16:55:27.06 Server Server process ID is 2636.
2006-08-24 16:55:27.06 Server Logging SQL Server messages in file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'.
2006-08-24 16:55:27.06 Server This instance of SQL Server last reported using a process ID of 476 at 8/24/2006 4:53:33 PM (local) 8/24/2006 11:53:33 PM (UTC). This is an informational message only; no user action is required.
2006-08-24 16:55:28.46 Server Registry startup parameters:
2006-08-24 16:55:28.54 Server -d C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\master.mdf
2006-08-24 16:55:28.54 Server -e C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG
2006-08-24 16:55:28.54 Server -l C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\mastlog.ldf
2006-08-24 16:55:29.46 Server SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2006-08-24 16:55:29.46 Server Detected 1 CPUs. This is an informational message; no user action is required.
2006-08-24 16:55:33.07 Server Using dynamic lock allocation. Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node. This is an informational message only. No user action is required.
2006-08-24 16:55:35.20 Server Attempting to initialize Microsoft Distributed Transaction Coordinator (MS DTC). This is an informational message only. No user action is required.
2006-08-24 16:55:37.06 Server The Microsoft Distributed Transaction Coordinator (MS DTC) service could not be contacted. If you would like distributed transaction functionality, please start this service.
2006-08-24 16:55:37.15 Server Database Mirroring Transport is disabled in the endpoint configuration.
2006-08-24 16:55:37.37 spid5s Starting up database 'master'.
2006-08-24 16:55:37.82 spid5s Recovery is writing a checkpoint in database 'master' (1). This is an informational message only. No user action is required.
2006-08-24 16:55:38.37 spid5s SQL Trace ID 1 was started by login "sa".
2006-08-24 16:55:38.46 spid5s Starting up database 'mssqlsystemresource'.
2006-08-24 16:55:38.92 spid9s Starting up database 'model'.
2006-08-24 16:55:38.93 spid5s Server name is 'PC325862970629'. This is an informational message only. No user action is required.
2006-08-24 16:55:39.26 Server A self-generated certificate was successfully loaded for encryption.
2006-08-24 16:55:39.28 Server Server is listening on [ 'any' <ipv4> 1433].
2006-08-24 16:55:39.28 Server Server local connection provider is ready to accept connection on [ \\.\pipe\SQLLocal\MSSQLSERVER ].
2006-08-24 16:55:39.28 Server Server named pipe provider is ready to accept connection on [ \\.\pipe\sql\query ].
2006-08-24 16:55:39.28 Server Server is listening on [ 127.0.0.1 <ipv4> 1434].
2006-08-24 16:55:39.28 Server Dedicated admin connection support was established for listening locally on port 1434.
2006-08-24 16:55:39.32 Server The SQL Network Interface library could not register the Service Principal Name (SPN) for the SQL Server service. Error: 0x54b. Failure to register an SPN may cause integrated authentication to fall back to NTLM instead of Kerberos. This is an informational message. Further action is only required if Kerberos authentication is required by authentication policies.
2006-08-24 16:55:39.34 Server SQL Server is now ready for client connections. This is an informational message; no user action is required.
2006-08-24 16:55:39.87 spid9s Clearing tempdb database.
2006-08-24 16:55:41.20 spid9s Starting up database 'tempdb'.
2006-08-24 16:55:42.79 spid12s The Service Broker protocol transport is disabled or not configured.
2006-08-24 16:55:42.79 spid12s The Database Mirroring protocol transport is disabled or not configured.
2006-08-24 16:55:42.92 spid12s Service Broker manager has started.
2006-08-24 16:55:45.23 spid14s Starting up database 'msdb'.
2006-08-24 16:55:45.23 spid16s Starting up database 'Aidms'.
2006-08-24 16:55:48.67 spid5s Recovery is complete. This is an informational message only. No user action is required.
2006-08-24 16:57:16.43 Logon Error: 18456, Severity: 14, State: 11.
2006-08-24 16:57:16.43 Logon Login failed for user 'PC325862970629\ASPNET'. [CLIENT: <local machine>]
2006-08-24 16:57:31.57 Logon Error: 18456, Severity: 14, State: 11.
2006-08-24 16:57:31.57 Logon Login failed for user 'PC325862970629\ASPNET'. [CLIENT: <local machine>]
2006-08-24 16:58:41.96 Logon Error: 18456, Severity: 14, State: 11.
2006-08-24 16:58:41.96 Logon Login failed for user 'PC325862970629\ASPNET'. [CLIENT: <local machine>]
2006-08-24 17:06:49.76 Logon Error: 18456, Severity: 14, State: 11.
2006-08-24 17:06:49.76 Logon Login failed for user 'PC325862970629\ASPNET'. [CLIENT: <local machine>]
2006-08-24 17:09:40.25 Logon Error: 18456, Severity: 14, State: 11.
2006-08-24 17:09:40.25 Logon Login failed for user 'PC325862970629\ASPNET'. [CLIENT: <local machine>]
2006-08-24 17:13:54.57 Logon Error: 18456, Severity: 14, State: 11.
2006-08-24 17:13:54.57 Logon Login failed for user 'PC325862970629\ASPNET'. [CLIENT: <local machine>]
2006-08-24 17:23:59.60 Logon Error: 18456, Severity: 14, State: 11.
2006-08-24 17:23:59.60 Logon Login failed for user 'PC325862970629\ASPNET'. [CLIENT: <local machine>]
2006-08-24 17:36:26.00 Server SQL Server is terminating because of a system shutdown. This is an informational message only. No user action is required.
2006-08-24 17:36:28.03 spid12s Service Broker manager has shut down.
2006-08-24 17:36:28.04 spid12s Error: 17054, Severity: 16, State: 1.
2006-08-24 17:36:28.04 spid12s The current event was not reported to the Windows Events log. Operating system error = 31(A device attached to the system is not functioning.). You may need to clear the Windows Events log if it is full.
2006-08-24 17:36:31.17 spid5s SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.
2006-08-24 17:36:33.01 Server The SQL Network Interface library could not deregister the Service Principal Name (SPN) for the SQL Server service. Error: 0x54b. Administrator should deregister this SPN manually to avoid client authentication errors.|||

You can execute:

CREATE LOGIN [PC325862970629\ASPNET] FROM WINDOWS

to create a SQL login for the ASPNET account. Let us know if this doesn't solve the login failure. I am not sure about the additional permissions that you need to grant to the ASPNET account for your application to work. A better forum for such further inquiries would be the ASP.Net forum at: http://forums.asp.net/default.aspx.

Thanks
Laurentiu

|||Aspnet_regiis.exe creates the ASPNET account for windows. I've deleted and recreated the account twice but I still get the same above error. Any help from a Microsoft representative would help in addition to the suggestions that have been given to far.|||

The command I mentioned in my previous post needs to be executed within SQL Server. You need to connect to SQL Server using a tool like sqlcmd or Management Studio, and issue that command to allow the ASPNET account to connect to SQL Server.

Thanks
Laurentiu

|||Thank you very much. Your previous post was te solution to my problem.

No comments:

Post a Comment