Thursday, February 9, 2012

access denied for user <machine name>\ASPNET

Hi!

I've just started to learn to use Visual Studio, and has come to database access.
I ran into this errormessage:

access denied for user <machine name>\ASPNET

The book I'm using just only say that I have to grant the ASPNET user account permissions before the Web application will have access to a SQL database. ... Seems clear at first glance ... but I lack a "how to" ...!

--

I've tried to search the net for solutions ... several thousands of pages came up ... indicating that I'm far from the first who have this problem. ... So after I now have spend hours reading, without finding any useful ansver to the question. ...

So let me just tell the most popular answers. (So You don't repeat something I allready have read hundreds of times.):
This question has been asked before
Yes, true answer, but it doesn't help.

See the FAQ
If it was stated were in the FAQ to look it could have been useful.

Use something called "enterprise manager" (WIN XP pro, don't have this, though.)
I use WIN XP pro, so that answer dosn't help me either.

--

Hope some one can help.Do you have SQL Server installed on the machine in question? If so, Enterprise Manager will be there (it will run fine on XP pro). You will not have Enterprise Manager if you have MSDE, in which case you need to use osql.exe:

This article explains various ways to work with MSDE. Note that the "Grant permissions to the ASPNET account" is the section to do what you need to do, given your current connection string.|||Yes, I have this osql.exe program. But when I try to use it, it comes up with an access denied error message.

I found another solution to the problem: Moving the ASPNET user from "Restricted user" to "Administrators".

I was a bit hesitant to do this at first (At first glance it appears a bit unsafe to do so.), but when I realized that it is commonly done that way, and when I tried it myself everything did run as it was supposed to. (So ... problem solved!)|||This is areally, really bad idea. The reason MS used the restricted account by default is to make your machine secure. Moving the ASPNET user to the Administrators group is aterrible idea.

Just cause it works, does not mean it is correct.|||Let me reiterate what Doug just said.

Moving the ASPNET user to the Administrators group is a terrible idea.

Don't do it! If someone manages to compromise your server through your website (such as through a SQL injection exploit) they will have unlimited access to run/install/ruin whatever they want on the machine.

Terri

No comments:

Post a Comment