3

Is there a way to identify / get the user Id of the actual user who is logged in as another user using the login as button? The best I can do today is to run the audit trail which gives info on who logged in as someone else, this is not a big help.

I want to block access to an external site and want to know the base user's id who has logged in as the another user. The actual user's personal data is getting exposed to the logged in user.

Its a web tab so I cannot apply sharing rules, I have delegate enabled thereby hiding a tab or any other setting on the actual user would have no effect.

3

Not sure if this is used everywhere BUT,

Since it is a web tab, if you have control over it and can access cookie information you can check for the cookie matching the salesforce instance i.e: na1.salesforce.com and look for the

RRetURL and if it is set to a user ID then you can assume they are logged in as another user.

Here is an example of that value in a recent session

RRetURL "/005A0000001oLiF?noredirect=1" cs8.salesforce.com  /   Session 38 B

Now, I am not sure if that is set elsewhere for some other purpose as well but in this case when logged in as another user this is what appears in the cookie.

Another value in the cookie is login:

login   xxx.xxx@xxx.com.stage   .salesforce.com /   October 20, 2014 at 5:32:35 PM EDT  36 B        

And if that value does not match the current value of userInfo.getUserName() then you can tell they are logged in as another user

As context for my answer I am no expert is accessing cookies and if it is not possible to access this cookie in the context in which you are limited to then maybe this information, knowing it exists in a cookie, may help point you to a place where the information is more easily accessible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.