Export (0) Print
Expand All
Expand Minimize

Login failed for user <user>

Visual Studio .NET 2003

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 SQL Server. The specific error or exception that is thrown depends on whether the SQL Server is on the same computer as the Web server or on a separate computer. This problem arises because the Web application is not passing proper credentials to the SQL Server. In general, the solution is to:

  • If the SQL Server is on the same computer as the Web server, give the local ASPNET user login privileges on the SQL Server.
  • Set IIS or ASP.NET to impersonate a Windows domain user who has login privileges on the SQL Server.
  • Use a connection string with an explicit user ID and password.

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

Note   The solutions to this problem can introduce security exposure on your Web server computer. For more information, see Access Permissions for Web Applications.

See Also

Database Security

Show:
© 2014 Microsoft