Re: Building SQL connection string in code-behind file. Works on my machine, not on server.
- From: "sloan" <sloan@xxxxxxxxx>
- Date: Wed, 30 Jul 2008 00:30:00 -0400
Then you need to show the connection string that was built to get help.
www.connectionstrings.com
Go there, and take a look.
You say you're using sql server authentication.
But the messages look like you're trying to use integrated security.
Post your connection string, or look at the samples at the site above, and
match a Sql Authentication.
My guess is that you have "integrated security=true" or something like that.
...
"Brett" <brettlf@xxxxxxxxxxxxxxxx> wrote in message
news:uUKFr1b8IHA.2348@xxxxxxxxxxxxxxxxxxxxxxx
The windows identity that is returned is "Domain\MyUsername on MyPC" when
I run it on localhost. When I run it on the server, it is
"Domain\MyUsername on ServerName"
I am using a SQL Server login, so I didnt think it would matter if the
domain user had SQL Server credentials. I do have the necessary SQL
Server permissions, though.
The odd thing is that it works fine with the user and password in the
connection string in web.config. If I build the same connection string in
the code-behind file, login fails. I set a session variable and turned on
trace to see if the connection string was getting set properly, and it
WAS. I don't understand.
"sloan" <sloan@xxxxxxxxx> wrote in message
news:ufnyBYb8IHA.1200@xxxxxxxxxxxxxxxxxxxxxxx
You always need to know and be aware of the account you're running under:
Here is some crappy debugging code.
I think the issue is you don't have sql server credentials for the user
the
program is running under.
Go to Control Panel / Users and you can see a list of "built in" users
that
a windows machine has.
private string FindIIdentity()
{
try
{
string returnValue = string.Empty;
WindowsIdentity ident = WindowsIdentity.GetCurrent();
returnValue = ident.Name;
try
{
returnValue += " on " + System.Environment.MachineName;
}
catch (Exception ex)
{
}
return returnValue;
}
catch (Exception ex)
{
return "Error Finding Identity";
}
}
"Brett" <brettlf@xxxxxxxxxxxxxxxx> wrote in message
news:OfvJ1Nb8IHA.4608@xxxxxxxxxxxxxxxxxxxxxxx
I wrote an ASP.NET application that queries a SQL Server database (on a
different box from the web server) and displays the result in a GridView.
The datasource for the GridView is a SQLDataSource. Just to get it to
work, I hard-coded the username and password of a SQL Server account in
the connectionstring in web.config. Once I confirmed that this worked on
the web server, I wanted to remove the hard-coded password from
web.config, so I removed that portion of the connectionstring. In the
Page_Load procedure of the page's code-behind file, I then appended the
username and password to the connectionstring in web.config. It worked
perfectly on my machine in Visual Studio.NET 2008. So, I moved the
updated code to the web server, but I got the error, "Login failed for
user 'NT AUTHORITY\ANONYMOUS LOGON'." What is the problem here?
Thanks for any help you can provide.
Brett
.
- Follow-Ups:
- References:
- Building SQL connection string in code-behind file. Works on my machine, not on server.
- From: Brett
- Re: Building SQL connection string in code-behind file. Works on my machine, not on server.
- From: sloan
- Re: Building SQL connection string in code-behind file. Works on my machine, not on server.
- From: Brett
- Building SQL connection string in code-behind file. Works on my machine, not on server.
- Prev by Date: Re: Connection Pooling
- Next by Date: web.config file problem
- Previous by thread: Re: Building SQL connection string in code-behind file. Works on my machine, not on server.
- Next by thread: Re: Building SQL connection string in code-behind file. Works on my machine, not on server.
- Index(es):
Relevant Pages
|