I'm getting the following error in my ASP.NET web application in IIS when running in Windows XP. I'm using Windows Authentication within the web application. I would normally use SQL Server Authentication (with mixed mode), but I do not have access to this database server, except read permissions. They only allow Trusted Connections (or Integrated Security=SSPI;) meaning using our Windows network authentication user.
Error:
Login failed for user ''. The user is not associated with a trusted SQL Server connection.
.NET Code:
SqlConnection conn = new SqlConnection(
"server=server_name;" +
"Integrated Security=SSPI;" +
"database=db_name;" +
"connection timeout=30;");
SqlDataReader rdr = null;
List<Ticket> list = new List<Ticket>();
try
{
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT TOP 10 [HEATSeq],[AssignedBy] FROM [dbo].[Asgnmnt]", conn);
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
Ticket record = new Ticket();
record.ticket_id = rdr[0].ToString();
record.assigned_by = rdr[1].ToString();
}
}
catch (Exception e)
{
string x = "";
}
finally
{
if (rdr != null)
{
rdr.Close();
}
if (conn != null)
{
conn.Close();
}
}
It's the same type of issue that I answered in Jon Skeet's first question here. In Windows 7, you'd normally set the application pool to run using LOCAL MACHINE or NETWORK SERVICE (if you choose not to use SQL Server Authentication). Except I don't know where to change the user of the application pool in IIS 6.
User permission error when accessing "user instance" database from ASP.NET
I read this article, but this applies to IIS in Windows 7, not Windows XP. How can I resolve this in Windows XP. Note that when I run this code in a console application, it connects fine.