title: Resolve "Login failed for user ''. The user is not associated with a trusted SQL Server connection." in IIS within Windows XP
body: <p>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.</p>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>Login failed for user ''. The user is not associated with a trusted SQL Server connection.
  </code></pre>
  
  <p><strong>.NET Code:</strong></p>
  
  <pre><code>SqlConnection conn = new SqlConnection(
      "server=server_name;" +
      "Integrated Security=SSPI;" +
      "database=db_name;" +
      "connection timeout=30;");
  SqlDataReader rdr = null;
  List&lt;Ticket&gt; list = new List&lt;Ticket&gt;();
  
  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();
      }
  }
  </code></pre>
  
  <p>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. </p>
  
  <p><a href="https://stackoverflow.com/questions/1134151/user-permission-error-when-accessing-user-instance-database-from-asp-net">User permission error when accessing &quot;user instance&quot; database from ASP.NET</a></p>
  
  <p>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.</p>
  
  <p><a href="http://blogs.msdn.com/b/sql_protocols/archive/2008/05/03/understanding-the-error-message-login-failed-for-user-the-user-is-not-associated-with-a-trusted-sql-server-connection.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/b/sql_protocols/archive/2008/05/03/understanding-the-error-message-login-failed-for-user-the-user-is-not-associated-with-a-trusted-sql-server-connection.aspx</a></p>