Trouble setting security for new thread in web app.

  • Thread starter Bo Campbell via .NET 247
  • Start date
B

Bo Campbell via .NET 247

Hello,

I have a web app that is being used to restore sql databases. Iam using a new thread to do the sql restores so I can keep theweb page from timing out (it checks a database to see thestatus, etc.) My problem is that I have tried just abouteverything to give that thread the domain username and passwordthat is setup for it on the network. As soon as the threadstarts, it goes straight to the machine name for the login.

I have read things that are very close to what I need on here butnothing that really pinpoints it. I thought about making thefunction into a service but feel i'm very close. Here is my codewhere I call the thread:

tDBRestore = New Thread(AddressOf RestoreDB)
tDBRestore.Name = "tRestoreDB"
tDBRestore.Start()

.NET is impersonating the logged in user, which is great, untilit hits the new thread.

Thanks,
Bo
 
H

Hernan de Lahitte

Unfortunately v1.1 does not transmit the security context (i.e. , principal,
thread token, etc) to the newly created thread. If you don't want to use a
thread from the .NET thread pool (as I guess is your scenario), you would
have to pass the security context (principal object might be suffice) to
your callback method like any other parameter that might receive your
method. On your callback method, you may impersonate with
yourprincipal.Identity.Impresonate() (and don't forget to "Undo" on your
finally section) or just attach this principal to the thread's principal
with Thread.CurrentPrincipal = yourprincipal.

--
Hernan de Lahitte
Lagash Systems S.A.
http://weblogs.asp.net/hernandl


This posting is provided "AS IS" with no warranties, and confers no rights.

Hello,

I have a web app that is being used to restore sql databases. I am using a
new thread to do the sql restores so I can keep the web page from timing out
(it checks a database to see the status, etc.) My problem is that I have
tried just about everything to give that thread the domain username and
password that is setup for it on the network. As soon as the thread starts,
it goes straight to the machine name for the login.

I have read things that are very close to what I need on here but nothing
that really pinpoints it. I thought about making the function into a service
but feel i'm very close. Here is my code where I call the thread:

tDBRestore = New Thread(AddressOf RestoreDB)
tDBRestore.Name = "tRestoreDB"
tDBRestore.Start()

..NET is impersonating the logged in user, which is great, until it hits the
new thread.

Thanks,
Bo
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top