Custom event handler and web part development often mandates the requirement to:
Access protected resources
Send an email
Impersonate users
Run code in a sandbox environment with low trust
One of the several ways to accomplish this is as shown below;
using (WindowsImpersonationContext impctx = WindowsIdentity.Impersonate(IntPtr.Zero))
{
SPUser admin = site.AllUsers[”Domain\AdminAccount”];
using (SPSite adminSite = new SPSite(site.Site.Url.ToString(), admin.UserToken)) [...]