Login failed for user <user>

This error can take a variety of forms, including:

  • Login failed for user '(null)'

  • Login failed for user domain\username

  • Login failed for user computer\ASPNET

The likely cause is that you are working with a Web application and are trying to access a computer running Microsoft SQL Server. The specific error or exception that is raised depends on whether the Web server is also running SQL Server. This problem arises because the Web application is not passing valid credentials to SQL Server. In general, you can resolve this issue by doing the one of the following:

  • If the Web server is also running SQL Server, give the local ASPNET user login privileges (Windows 2000 and Windows XP) or give the NT AUTHORITY\NETWORK SERVICE login privileges (Windows Server 2003) on the server.

  • If SQL Server is running on a remote computer and the Web server is running IIS 6.0, give the Web server's machine account login privileges on the remote computer. The machine account is referenced as DOMAIN\MACHINENAME$.

  • Set up ASP.NET to run as a Windows domain user who has login privileges on the computer running SQL Server.

  • Use a connection string to use SQL Server standard security. To do this, you must configure the connection string with an explicit user ID and password.

For more information, see Accessing SQL Server from a Web Application.

Security Note   These actions can increase the attack surface of your Web server. For more information to help you increase security, see Security (How Do I in Visual Web Developer).

See Also

Concepts

Securing Data Access