Very often, developers need to execute some code in the context of another user. This article explains how to do SharePoint user impersonation with C# using the Server-Side Object Model (SSOM).
This article provides a managed wrapper for the LogonUser function of the Win32 API. It allows you to perform active directory user impersonation using C#. You just need to have the credentials of the user.