Monday, August 28, 2006

Impersonation in .Net

There are scenarios when you may want to impersonate in .Net. What this means is you want to execute a part of your code with different authentication information. There are numerous scenarios when you may want to do it. An example: suppose you want to write a file to shared location where the user authentication running the application doesn't have write permissions. So what do you do? Impersonate your piece of code as the user who has rights to write file.

Here's the Microsoft kb article to how to impersonate your piece of code:
http://support.microsoft.com/kb/306158/