Showing posts with label methods. Show all posts
Showing posts with label methods. Show all posts

Wednesday, March 21, 2012

Remote SQL Server login failed for ASPNET user

This is a common problem, but none of the methods I read about in the other
posts have worked. What is a sure-fire way to get my web application to sto
p
using the ASPNET user for SQL Server authentication? I am trying to connect
to a Server on my LAN with a specified username and password. The error I
get is "Login failed for user '<computer name>\ASPNET'. I tried a standard
connection string and then one that Visual Studio generated when I dragged
the connection to a form:
"Server=<servername>;User ID=<userid>;Password=<password>Initial Catalog=<db
name>"
"workstation id=<my computer name>;packet size=4096;user
id=<user>;password=<password>;data source=<sql server name>;persist security
info=False;initial catalog=<db name>"
I have also tried putting in "Trusted_Connection=false". Also I saw
something about impersonation in the web.config, which i tried but it would
not compile.
The login works fine from inside the Visual Studio IDE and also through
Enterprise Manager.
Thanks for your help
SteveIn my experience this happens when you have the following conditions true...
1. You're using a connection string that's using Integrated Windows
authentication
2. Your web server is configured for anonymous access only
3. <identity impersonate="true" /> is set in your web config (system.web
section)
If your connection string uses a sql login:
User ID=<user>;password=<pwd>;Initial Catalog=<database>;Data Source=<server
>
You should never get this error if your using a SQL login, you're telling
the connection with what credentials to use to connect to the database, why
would it not use what you specified...? I'd double check the connection
string in the config file... You have to have "Integrated Security=True"
specified in your connect string otherwise you would not be attempting to
authenticate to the database using a windows account.
"Steve P" wrote:

> This is a common problem, but none of the methods I read about in the othe
r
> posts have worked. What is a sure-fire way to get my web application to s
top
> using the ASPNET user for SQL Server authentication? I am trying to conne
ct
> to a Server on my LAN with a specified username and password. The error I
> get is "Login failed for user '<computer name>\ASPNET'. I tried a standar
d
> connection string and then one that Visual Studio generated when I dragged
> the connection to a form:
> "Server=<servername>;User ID=<userid>;Password=<password>Initial Catalog=<
db
> name>"
> "workstation id=<my computer name>;packet size=4096;user
> id=<user>;password=<password>;data source=<sql server name>;persist securi
ty
> info=False;initial catalog=<db name>"
> I have also tried putting in "Trusted_Connection=false". Also I saw
> something about impersonation in the web.config, which i tried but it woul
d
> not compile.
> The login works fine from inside the Visual Studio IDE and also through
> Enterprise Manager.
> Thanks for your help
> Steve|||Thank you for responding, Alien2_51. I'll just go down your list:
1) I have made sure that my connection string does not include Integrated
Security=true"
2) I'm not sure about this. I'm just serving out the pages my my computer
(localhost). If I right-click on the default web site and go to directory
security, then to Edit anonymous access, the items that are checked are
"anonymous access", "allow IIS to control password", and "Integrated Windows
authentication". The user name in this dialog box is set to "IUSR_<my
computer name>". If I try to uncheck "integrated windows authentication", I
have to log in when I run the page and then the page won't even display.
3) In my machine.config file, impersonate="false". In the web.config of the
application, the value is not set.
Finally, I don't use the connection string that is in the web.config file
(sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes") I'm not
sure why it's in there; I just put the connection string in global.asax as a
n
application variable. I have also tried just hard-coding the connection
string into the code. I tried commenting out the connection string in
web.config to no avail.
Anyone please let me know if you have any other suggestions; your help is
certainly appreciated.
Thanks,
Steve
"Alien2_51" wrote:
> In my experience this happens when you have the following conditions true.
.
> 1. You're using a connection string that's using Integrated Windows
> authentication
> 2. Your web server is configured for anonymous access only
> 3. <identity impersonate="true" /> is set in your web config (system.w
eb
> section)
> If your connection string uses a sql login:
> User ID=<user>;password=<pwd>;Initial Catalog=<database>;Data Source=<serv
er>
> You should never get this error if your using a SQL login, you're telling
> the connection with what credentials to use to connect to the database, wh
y
> would it not use what you specified...? I'd double check the connection
> string in the config file... You have to have "Integrated Security=True"
> specified in your connect string otherwise you would not be attempting to
> authenticate to the database using a windows account.
>
>
>
> "Steve P" wrote:
>|||Figured out my problem...though the error message is misleading. Apparently
asp.net won't let you have 2 connections open at the same time (one to local
database and one to remote). I removed the local connection to test it and
it worked. Does anyone know how to have 2 simultaneous connections open? I
can use a dataset but the potential problem there is the amount of memory it
could use...
Thanks, Steve
"Steve P" wrote:

> This is a common problem, but none of the methods I read about in the othe
r
> posts have worked. What is a sure-fire way to get my web application to s
top
> using the ASPNET user for SQL Server authentication? I am trying to conne
ct
> to a Server on my LAN with a specified username and password. The error I
> get is "Login failed for user '<computer name>\ASPNET'. I tried a standar
d
> connection string and then one that Visual Studio generated when I dragged
> the connection to a form:
> "Server=<servername>;User ID=<userid>;Password=<password>Initial Catalog=<
db
> name>"
> "workstation id=<my computer name>;packet size=4096;user
> id=<user>;password=<password>;data source=<sql server name>;persist securi
ty
> info=False;initial catalog=<db name>"
> I have also tried putting in "Trusted_Connection=false". Also I saw
> something about impersonation in the web.config, which i tried but it woul
d
> not compile.
> The login works fine from inside the Visual Studio IDE and also through
> Enterprise Manager.
> Thanks for your help
> Steve|||Please disregard my last post. The error originated not from the remote
connection but from the local connection.
"Steve P" wrote:
> Figured out my problem...though the error message is misleading. Apparent
ly
> asp.net won't let you have 2 connections open at the same time (one to loc
al
> database and one to remote). I removed the local connection to test it an
d
> it worked. Does anyone know how to have 2 simultaneous connections open?
I
> can use a dataset but the potential problem there is the amount of memory
it
> could use...
> Thanks, Steve
> "Steve P" wrote:
>sql