473,246 Members | 1,257 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,246 software developers and data experts.

problem with trusted connection (asp.net)

I am getting the following error when trying to access a database with
a trusted connection:

"Login failed for user '(null)'. Reason: Not associated with a trusted
SQL Server connection."

My connection string is:

"Server=MyServer; Database=MyCatalog; Trusted_Connection=True;"

Note that Anonymous Access is off in IIS, and I am able to read my
Windows login with:

Textbox1.text =
System.Web.HttpContext.Current.User.Identity.Name. Substring(System.Web.HttpContext.Current.User.Iden tity.Name.IndexOf("\")
+ 1).ToLower()

Can anyone explain how to query the db using a trusted connection?

PS Is there a way to dynamically retrieve a list of databases the
current user has SQL rights on, by specifying only the server, again
using trusted connection?

Thanks...

Nov 15 '06 #1
3 5741
Hello,

Have you added the OS user into the SQL Server? If not add the particular
user into SQL Server Logins and try connecting.

Thanks
Hari


"Mad Scientist Jr" <us*************@yahoo.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
>I am getting the following error when trying to access a database with
a trusted connection:

"Login failed for user '(null)'. Reason: Not associated with a trusted
SQL Server connection."

My connection string is:

"Server=MyServer; Database=MyCatalog; Trusted_Connection=True;"

Note that Anonymous Access is off in IIS, and I am able to read my
Windows login with:

Textbox1.text =
System.Web.HttpContext.Current.User.Identity.Name. Substring(System.Web.HttpContext.Current.User.Iden tity.Name.IndexOf("\")
+ 1).ToLower()

Can anyone explain how to query the db using a trusted connection?

PS Is there a way to dynamically retrieve a list of databases the
current user has SQL rights on, by specifying only the server, again
using trusted connection?

Thanks...

Nov 15 '06 #2
Mad Scientist Jr wrote:
I am getting the following error when trying to access a database with
a trusted connection:

"Login failed for user '(null)'. Reason: Not associated with a trusted
SQL Server connection."

My connection string is:

"Server=MyServer; Database=MyCatalog; Trusted_Connection=True;"

Note that Anonymous Access is off in IIS, and I am able to read my
Windows login with:

Textbox1.text =
System.Web.HttpContext.Current.User.Identity.Name. Substring(System.Web.HttpContext.Current.User.Iden tity.Name.IndexOf("\")
+ 1).ToLower()

Can anyone explain how to query the db using a trusted connection?

PS Is there a way to dynamically retrieve a list of databases the
current user has SQL rights on, by specifying only the server, again
using trusted connection?

Thanks...
You're almost certainly encountering the "double hop" issue. This
arises when IIS and SQL Server are on separate servers. If that isn't
true in your circumstance, then ignore the rest of this post.

The problem arises because your client machine authenticates you to the
IIS server, but the IIS server has no means of authenticating you to
the SQL Server box (It can't make the second "hop" of authentication).
There was a superb MSDN Magazine article some time back that describes
this, but I can't seem to find it right now. I have found this
knowledge base article:

http://support.microsoft.com/kb/810572

which seems to cover the same areas.

Damien

Nov 15 '06 #3
Thanks for your reply...

I read up on it and fixed the problem on my local machine by adding the
following to my web.config file:

<identity impersonate="true"/>

However when I try running this on the live web server I get this
error:

Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

Any ideas?
You're almost certainly encountering the "double hop" issue. This
arises when IIS and SQL Server are on separate servers. If that isn't
true in your circumstance, then ignore the rest of this post.

The problem arises because your client machine authenticates you to the
IIS server, but the IIS server has no means of authenticating you to
the SQL Server box (It can't make the second "hop" of authentication).


Damien wrote:
Mad Scientist Jr wrote:
I am getting the following error when trying to access a database with
a trusted connection:

"Login failed for user '(null)'. Reason: Not associated with a trusted
SQL Server connection."

My connection string is:

"Server=MyServer; Database=MyCatalog; Trusted_Connection=True;"

Note that Anonymous Access is off in IIS, and I am able to read my
Windows login with:

Textbox1.text =
System.Web.HttpContext.Current.User.Identity.Name. Substring(System.Web.HttpContext.Current.User.Iden tity.Name.IndexOf("\")
+ 1).ToLower()

Can anyone explain how to query the db using a trusted connection?

PS Is there a way to dynamically retrieve a list of databases the
current user has SQL rights on, by specifying only the server, again
using trusted connection?

Thanks...

You're almost certainly encountering the "double hop" issue. This
arises when IIS and SQL Server are on separate servers. If that isn't
true in your circumstance, then ignore the rest of this post.

The problem arises because your client machine authenticates you to the
IIS server, but the IIS server has no means of authenticating you to
the SQL Server box (It can't make the second "hop" of authentication).
There was a superb MSDN Magazine article some time back that describes
this, but I can't seem to find it right now. I have found this
knowledge base article:

http://support.microsoft.com/kb/810572

which seems to cover the same areas.

Damien
Nov 15 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DMS | last post by:
am new to ASP.NET and IIS web applications, but not to SQL databases. I can successfully build Windows apps using Visual Studio that use ADO. However, for Web Forms, I created data connection and...
4
by: Brian Henry | last post by:
I an trying to connect to a sql server in asp.net with the sql connection object, and every time i try to open the connection i get this Server Error in '/' Application. Login failed for user...
4
by: Thomas | last post by:
Hi all! I have an asp.net web application that is configured for dynamic impersonation via web.config (identity impersonate=true). The corresponding virtual directory is protected by integrated...
3
by: Bobofrut | last post by:
Hi I have a problem, when I try to connect to the MS SQL SERVER from my workstation ocourr the error message: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server...
4
by: rrober07 | last post by:
Hello, My Setup is I have a Web Server machine(Devweb01), Database SQL Machine(Devsql01), a Client Machine(local machine) I have configured the SQL machine as follows: 1) Added local Aspnet...
3
by: Maellic | last post by:
Hi, The website I am working on is built with ASP.NET and connects to a SQL Server 2000 database. The web server and database are on the same machine. I have recently tried to modify the timeout...
2
by: Paul M | last post by:
Hi, I've just implemented my first application onto a test web server. When the code comes to creating a connection object it throws an error saying the "Login failed for user '(null)'. Reason...
5
by: Adam Getchell | last post by:
Hello all, I've read over: http://idunno.org/dotNet/trustedConnections.aspx I would like to use a trusted connection vice using encrypted database strings:...
5
by: LRK | last post by:
Earlier this week we set up a second application pool to be able to implement trusted connections between ASP.NET apps and a SQL Server database on a different server. The trusted connection is...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.