5

Is there any way to detected the user who is "Logged in as user" using Apex.

I want to be able to detected Mike Gill is Logging in as Asha Gill via Apex.

1 Answer 1

6

No - the UserInfo class has no way of telling. The UI can distinguish if you're "logged in as" a different user because Salesforce itself has visibility into the current session, but this isn't visible through Apex (besides basic information, like the Session ID). There is no way of knowing programmatically.

There's a post here somewhere that answered this exact question (or pretty close), I'll try to find it.

EDIT: of course it was sfdcfox: Can Apex code tell if you are impersonating a user vs actually being logged in as that user?

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .