Microsoft Technologies » .Net Framework » ASP.Net

ID #1001

When I try to connect to a sql server database using Windows Authentication, I get a message that the login failed. What's going wrong?

When SQL Server is installed, it grants two logins all privileges.

The first user is 'sa' that can be used if and only if the authentication mode is mixed. The second user is the group 'BUILTIN\Administators'.

The ASP.Net runtime runs under the privileges of the user '<MACHINE-NAME>\ASPNET', an account created during installation of ASP.Net.

Since this user is not a member of the Administrators group, the account cannot be used to access SQL Server.

There are two solutions to the problem.

One, make the user ASPNET a part of the Administrators group. But never do that. It may do more harm than good.

The other solution, the one that should always be used, is to enable mixed-mode authentication so that non-Windows-account users (i.e., database-only users) can login to the database.

Look at this article at Eduzine© on how to configure SQL Server for mixed-mode authentication. The article is available here.

Then use the following connection string to connect to the database:

"server=<instance-name>; user=<username>;
password=<password>; database=<database-name>"

Categories for this entry

Last update: 2007-03-31 12:49
Author: Edujini
Revision: 1.3

Print this record Print this record
Send to a friend Send to a friend
Show this as PDF file Show this as PDF file
Export as XML-File Export as XML-File

Please rate this entry:

Average rating: 0 from 5 (0 Votes )

completely useless 1 2 3 4 5 most valuable

You cannot comment on this entry