Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent impersonation

Status
Not open for further replies.

haddaway

Programmer
Jul 6, 2005
172
SE
I have impersonated a thread with success. What I would like to do is either keep the impersonation to that thread (the impersonation must not be inherited) or if I can specify somewhere that a certain class can't be impersonated.

In my example I am watching a folder with the filesystemwatcher. I need certain credentials for that folder. The filesystemwatcher is running during the lifetime of the app. I have other functions that are called when the filesystemwatcher triggers (from the filesystemwatcher). I want those threads to run as the original user (local system account).

How can I perform and control this behaviour?

Thanks!
 
I found this method which solves my problem. It prevents the impersonation being inherited to new threads that are created within the impersonated thread:

Threading.ExecutionContext.SuppressFlow()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top