Impersonation in a New Thread?

A

amy g

I have an ASP.NET application using impersonation, and ran into the issue where if I start a new thread, that thread runs as the ASP.NET user instead of the impersonated user

I found this post, http://groups.google.com/[email protected], which discusses how to handle this using an asynchronous method call by passing System.Security.Principal.WindowsIdentity.GetCurrent() into the asynchronous method and then calling Impersonate on the passed identity

In that post, the author says they wouldn't know how to do this if they were creating their own thread, but doesn't explain why

The code I have (inherited) does create its own thread, using new Thread, new ThreadStart, etc. I tried using the info in "Passing Data to Threads" here, http://msdn.microsoft.com/library/d...y/en-us/cpguide/html/cpconcreatingthreads.asp, to pass the WindowsIdentity to the new thread and call Impersonate on it, and it seems to work

But I'm not terribly familiar with either impersonation or threading, so I wanted to check if someone could verify that I'm not missing anything, and this should work?
 

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
474,136
Messages
2,570,797
Members
47,346
Latest member
Jason Calder

Latest Threads

Top