Developer forum

Forum » Integration » Impersonation - detecting when switching between users

Impersonation - detecting when switching between users

Sigurður Hergeirsson
Reply

Hi, I need to perform action when already logged in user selects another he can impersonate - using full impersonation.

I can not find event in NotificationSubscribers that explicitly fires for this case.
OnExtranetLogin fires both when user logs  and also when user  swithces to another user.

Caching previous userId and making compare at OnExtranetLogin  could be solution, but I find that a bit dirty,  Is there any better way ?

Best regards, Siggi


Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Sigurður,

 

I don't know that there is such a notification, but you should be able to get this to work.

 

Maybe a way is to subscribe to the Standard.Application.AfterBeginRequest (or some better applicable Request notification) and check if the querystring parameter for the secondary login exists AND a secondary user is not null. If so, save a new request parameter with the new user id to impersonate.

 

That will tell you that there's an attempt to impersonate another user. Then in the OnExtranetLogin, check your request params, and if the new login user matches the new impersonated user, you know it's been successful.

 

Best Regards,

Nuno Aguiar

 

You must be logged in to post in the forum