Trusted connection won't work...

P

Paul M

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
 
S

Sam Fields

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/d...tml/gngrfASPNETConfigurationSectionSchema.asp
with particular attention to the <authentication>, <authorization>, and
<identity> elements.

Hope that helps.
Sam
 
M

Miha Markic [MVP C#]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,089
Latest member
Ketologenic

Latest Threads

Top