Impersonation & SecurityEvents.Authenticate.Execute

Aaron VanMeter asked on March 15, 2017 23:40

Recently upgraded to Kentico 10 and found out that the "Impersonate user" functionality from the Admin panel now triggers the SecurityEvents.Authenicate.Execute handler I created to do additional work with the user's login.

The problem is that the AuthenticationEventArgs object passed into the handler by impersonation has its Password property set to an empty string, which means I can't also authenticate the user against our outside solution.

Is there any way to know if the authentication being processed by the handler came from a Impersonation request?

Correct Answer

Brenden Kehren answered on March 16, 2017 06:34

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).

0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.