468,556 Members | 2,192 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Trusted connection won't work...


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 : Not associated with a
trusted connection".

I'm using integrated security and it works from the IIS server I have set up
on my local machine. The connection string I'm using is
strCN = "data source='DIVCS-SQL2\SQL2K';Trusted_Connection=true;initial
catalog=HelpdeskDevelopment;User Id='" & objCurrentUser.Name & "'"

Where objCurrentUser is a WindowsIdentity object. This object is returning
the correct username.

I've done everything according to the book (ASP.NET unleashed) and I've
checked the knowledge base.

Thanks in advance....Paul
Nov 18 '05 #1
2 1460
With a trusted connection, you don't need to pass the User Id ... it will
use the current windows user credentials. In ASP.NET, this is typically the
asp worker process account. Does this account have access to your
helpdeskdevelopment database? If not, it will need access and you'll need
to handle any extra security with custom login forms and back-end tables.

If you need to impersonate a windows user and use windows security instead,
you'll need to setup web.config correctly.

See
http://msdn.microsoft.com/library/de...tionSchema.asp
with particular attention to the <authentication>, <authorization>, and
<identity> elements.

Hope that helps.
Sam

"Paul M" <ma****@trials.bham.ac.uk> wrote in message
news:O1**************@TK2MSFTNGP09.phx.gbl...

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 : Not associated with a
trusted connection".

I'm using integrated security and it works from the IIS server I have set up on my local machine. The connection string I'm using is
strCN = "data source='DIVCS-SQL2\SQL2K';Trusted_Connection=true;initial
catalog=HelpdeskDevelopment;User Id='" & objCurrentUser.Name & "'"

Where objCurrentUser is a WindowsIdentity object. This object is returning the correct username.

I've done everything according to the book (ASP.NET unleashed) and I've
checked the knowledge base.

Thanks in advance....Paul

Nov 18 '05 #2
Hi Paul,

Asp.net applications run under local windows aspnet account.
Thus, trusted connections will
a) ignore User Id
b) use aspnet account to log in to sql server.

You have at least tow options at this point:
a) run your app under different windows account (that is trusted to sql
server)
Example:
Just put a line into web.config file somewhere under
<system.web> node:

<identity impersonate="true" userName="USER" password="PASSWORD"/>

b) use sql server authentication

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"Paul M" <ma****@trials.bham.ac.uk> wrote in message
news:O1**************@TK2MSFTNGP09.phx.gbl...

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 : Not associated with a
trusted connection".

I'm using integrated security and it works from the IIS server I have set up on my local machine. The connection string I'm using is
strCN = "data source='DIVCS-SQL2\SQL2K';Trusted_Connection=true;initial
catalog=HelpdeskDevelopment;User Id='" & objCurrentUser.Name & "'"

Where objCurrentUser is a WindowsIdentity object. This object is returning the correct username.

I've done everything according to the book (ASP.NET unleashed) and I've
checked the knowledge base.

Thanks in advance....Paul

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Ray Valenti | last post: by
2 posts views Thread by Paul M | last post: by
3 posts views Thread by Kevinp | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by UniDue | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.