Is there a simple out of the box way to impersonate a user in .NET?
So far I\'ve been using this class from code project for all my impersonation requirements.
This is probably what you want:
using System.Security.Principal;
using(WindowsIdentity.GetCurrent().Impersonate())
{
//your code goes here
}
But I really need more details to help you out. You could do impersonation with a config file (if you're trying to do this on a website), or through method decorators (attributes) if it's a WCF service, or through... you get the idea.
Also, if we're talking about impersonating a client that called a particular service (or web app), you need to configure the client correctly so that it passes the appropriate tokens.
Finally, if what you really want do is Delegation, you also need to setup AD correctly so that users and machines are trusted for delegation.
Edit:
Take a look here to see how to impersonate a different user, and for further documentation.