469,579 Members | 1,157 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,579 developers. It's quick & easy.

Web forms and data access

I've been trying to connect to SQL Server 2000 through a web form created in
c#. As I created my connection object the data source test succeeded. I've
even tried the datapage wizard and I get the following message:

Login failed for user '\'.

I can successfully connect when creating a Windows application, just not
from a web form app.

Can anyone help? Thanks
Nov 15 '05 #1
1 1199
Ed,

The reason for this is that by default, ASP.NET runs under the local
ASPNET user account. This account doesn't have any rights to the network,
and I imagine that is the problem.

In order to get around this, you will have to change the user that this
page runs under (or even the operation). You have three options:

- Elevate the rights of the ASPNET user so that it can access the database
(not a preferred option).

- Change the user that the web app runs under (through the web.config file)
so that it runs under a user that has rights. You have to be careful
though, because all pages in the directory that the web.config file is in
will run under that user context.

- Imitate the user. Check the documentation for the Impersonate method on
the WindowsIdentity class to see how you can impersonate a user at will.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ed B" <eb********@rehabchicago.org> wrote in message
news:uZ**************@TK2MSFTNGP10.phx.gbl...
I've been trying to connect to SQL Server 2000 through a web form created in c#. As I created my connection object the data source test succeeded. I've even tried the datapage wizard and I get the following message:

Login failed for user '\'.

I can successfully connect when creating a Windows application, just not
from a web form app.

Can anyone help? Thanks

Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Brad L. Meyer | last post: by
reply views Thread by Anonieko Ramos | last post: by
6 posts views Thread by William F. Zachmann | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.