System.Data.SqlClient.SqlException error when running a project
search cancel

System.Data.SqlClient.SqlException error when running a project

book

Article ID: 176919

calendar_today

Updated On:

Products

Workflow Solution

Issue/Introduction

Getting the following error message when running a project after it has been published to the Workflow Server.  The project appears to run fine in the debug utility.

Error Message:
Login failed for user '$ComputerName'.
  

or

Message Stack:
 System.Exception: Execution Engine Exception  ---> System.Exception: Execution Exception ---> System.Data.SqlClient.SqlException: Cannot open database 'Altiris' requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
   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)
   .....

Cause

The connection strings used for SQL components in this project were using a connection string that utilized SSPI.  SSPI uses the current context for authentication, which for a process published to IIS is Network Service by default. 

Resolution

To resolve this error message, you can use SQL Authentication in your connection string, configure the Application Identity to a user that has access to SQL, or add an impersonation account for a user that has access to SQL. 

You may use the sample connection string below changing the items in bold:
Data Source=ServerAddress;Initial Catalog=DatabaseName;User Id=Username;Password=Password

To add an impersonation account, modify the web.config and add the following information after the <system.web> tag:
<identity impersonate="true" userName="Domain\Username" password="Password" />

Applies To
Workflow Solution 6.5