public static void EndImpersonation(WindowsImpersonationContext impersonatedUser) { if ((object)impersonatedUser != null) { impersonatedUser.Undo(); impersonatedUser.Dispose(); } }