Check out a pretty awesome method introduced in v10! I could have used this in previous versions without hesitation.
CMS.Membership.MembershipContext.GetImpersonatingUser()
Should be able to do some comparing to see if that is null or not (returns UserInfo
object).