I've got a Web Setup project installing a web app. In a Custom Action, I'm executing a SQL script to build a database.
Simple, mostly MS sample code. Works fine.
private void ExecuteSql(string serverName, string dbName, string Sql)
{
System.Data.SqlClient.SqlConnection masterConnection = new System.Data.SqlClient.SqlConnection();
masterConnection.ConnectionString = "Server=" + serverName + "; Database=" + dbName + ";Integrated Security=SSPI";
System.Data.SqlClient.SqlCommand Command = new System.Data.SqlClient.SqlCommand(Sql, masterConnection);
Command.Connection.Open();
Command.Connection.ChangeDatabase(dbName);
try
{
Command.ExecuteNonQuery();
}
finally
{
Command.Connection.Close();
}
}
The problem is that the user that is being sent over to the SQL Server is "DOMAIN\MACHINENAME$", like "AMBER\CHAOS$" rather than "AMBER\corwin".
If I add "AMBER\CHAOS$" as a login on the SQL Server and give the user sufficient rights, everything works fine. That's not possible in the final environment.
So, what do I need to do to make my web setup connect to SQL server as "AMBER\corwin" rather than "AMBER\CHAOS$"?