need clear example of threading + impersonation

J

jyjohnson

My asp.net application needs to allow the user (via basic authentication) to
execute a long running process (new thread) that writes files out to a share
on another server.

This works if I just use impersonation without creating a new thread. I'm
using XP Pro + IIS 5. I think I have access to a Win 2003 server if that
makes things easier.

Thanks....
 
D

Dominick Baier [DevelopMentor]

Hello jyjohnson,

i assume that you first impersonate and start the thread afterwards....

impersonation tokens are not copied to new threads in .net 1.1 (they will
in 2.0)

do it like this

start the thread
impersonate the user on the new thread

something like (only compiled in the newsreader :)


Worker worker = new Worker();
worker.user = Page.User;

Thread t = new Thread(new ThreadStart(worker.DoWork);

class Worker
{
public WindowsPrincipal user;

public void DoWork()
{
WindowsImpersonationContext ctx;
try
{
user.Impersonate();
}
finally
{
ctx.Undo();
}
}
}
 
J

jyjohnson

I think I've tried that.... I've tried many code snips, etc, ! I understand
the problem (i.e., new threads use the aspnet account identity, not the
impersonated identity)...

I get an error on this line ---> user.Impersonate 'not a member of
WindowsPrinciple

Thanks!
 

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,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top