Thursday, January 06, 2005
ASP.NET, IIS6 and SQL Server 2000
If you are trying to connect to SQL server using a SQL login/password in the connection string, and you receive the following error:
Login failed for user ''. Reason: Not associated with a trusted SQL Server connection.
Do the following:
Login failed for user '
Do the following:
- Check the security settings on the SQL Server registration. Right click the server (local), choose the security tab and make sure that the 'SQL Server and Windows' radio button is selected. If it is not, select it, then restart SQL Server.
- If that doesn't work, check if ASP.NET is doing any kind of impersonation by looking for an impersonation tag in web.config. If the
authentication tag is set to "Windows" and the impersonation tag is set to "true", then ASP.NET will impersonate the logged in user, which is the user that IIS authenticated (If IIS is set to use Windows authentication). So If my user is DOMAIN\USER, IIS would first perform authentication and then forward the request as well as my security token to the ASP.NET process. If the authentication tag is "Windows" and the impersonation tag is "true", the ASP.NET process will impersonate the logged in user (DOMAIN\USER). Any requests (file, network, database) from the ASP.NET process will operate under the identity of this logged in user. If impersonation is not set to true, and IIS authntication is set to anonymous, the ASP.NET process will run as ASPNET for IIS5 or the application pool identity, NT Authority\NetworkService for IIS6.