Connecting Database in thread

G

Guest

Hi all Gurus

I have asp.net application where I am creating background process using
Threading.
My threading involves invoking method which in turn gets some data from SQL
server using Windows Authentication.

But when I run my app, connection error comes as "{"Login failed for user
'(null)'. Reason: Not associated with a trusted SQL Server connection." }".
When I check the System.Threading.Thread.CurrentPrincipal properties it
comes correctly.
I have tried with setting both <identity impersonate="false"/> and <identity
impersonate="true"/>, but did not work.

When I used SQL user iD and Password in my connection string it works very
well.

Any help is appreicated.
Makarand

Kindly help.
 
G

Guest

The anonymous access should be disabled in IIS in order to authenticate the
user using windows authentication.
Go to IIS, right-click on your application name and select properties.
Go to Directory security tab-> click on Edit... button.
Uncheck the Anonymous access check box and press Ok.

Now, the user should be authenticated using windows authentication..

HTH
 
B

bruce barker

a thread inherits its security context from the process (asp.net), not the
thread that creates it so <identity impersonate> has no effect. the thread
will also run as the asp.net machine account you have a couple options:

1) have the thread logon as a known user.
2) change the machine account to one that can access sqlserver
3) pass credentials from creating thread to the new thread and have the new
thread do an impersonate (this requires the machine account have the 'act as
part of os' permission, and the credentials must be a primary token.)

-- bruce (sqlwork.com)


| Hi all Gurus
|
| I have asp.net application where I am creating background process using
| Threading.
| My threading involves invoking method which in turn gets some data from
SQL
| server using Windows Authentication.
|
| But when I run my app, connection error comes as "{"Login failed for user
| '(null)'. Reason: Not associated with a trusted SQL Server
connection." }".
| When I check the System.Threading.Thread.CurrentPrincipal properties it
| comes correctly.
| I have tried with setting both <identity impersonate="false"/> and
<identity
| impersonate="true"/>, but did not work.
|
| When I used SQL user iD and Password in my connection string it works very
| well.
|
| Any help is appreicated.
| Makarand
|
| Kindly help.
 
G

Guest

No, that is not the case. I have "Unchecked" anonymous access in IIS, still
it is giving an error. In fact when I don't use threading my connection with
database is working fine.

Makarand
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top