Newer Version Available
LoginAsEvent
Tracks when an admin logs in as another user in your
org. In Real-Time Event Monitoring, only events for org admins and
communities are captured. LoginAsEvent is a big object that stores the event
data of LoginAsEventStream. This object is available in API version 46.0 and
later.
Supported Calls
describeSObjects(), query()
Special Access Rules
Accessing this object requires either the Salesforce Shield or Salesforce Event Monitoring add-on subscription and the View Data Leakage Detection Events user permission.
Fields
Standard SOQL Usage
Currently, the only supported SOQL function on LoginAsEvent is WHERE, and you can only use comparison operators (=, <, >, <=,
and >=) on the final expression in a WHERE
clause. The != operator isn’t supported.
LoginAsEvent allows filtering over two ordered
fields: EventDate and EventIdentifier.
There’s a catch here; your query won’t work unless you use the correct order and
combination of these fields. The following list provides some examples of valid and
invalid queries:
-
Unfiltered
-
Valid—Contains no WHERE clause, so no special rules
apply.
-
Valid—Contains no WHERE clause, so no special rules
apply.
-
Filtered on EventDate
-
Valid—You can filter solely on
EventDate, but single filters on other
fields fail. You can also use a comparison operator in this query
type.
-
Valid—You can filter on EventDate
using date
literals.
-
Valid—You can filter solely on
EventDate, but single filters on other
fields fail. You can also use a comparison operator in this query
type.
-
Filtered on EventDate and
EventIdentifier
-
Valid—Successful queries on LoginAsEvent filter over
both
fields.
-
Invalid—Queries on LoginAsEvent with
EventDate and standard date
literals.
-
Invalid—Filtering only on
EventDate with <= or >= operator and
EventIdentifier field isn’t
supported.
-
Valid—Successful queries on LoginAsEvent filter over
both
fields.
Async SOQL Usage
With Async SOQL, you can filter on any field in LoginAsEvent and use any comparison operator in your query.
Example: Get yesterday's LoginAs events where an Org Admin is logging into the portal as another user.
SELECT DelegatedUsername, DelegatedOrganizationId, EventDate, LoginAsCategory, LoginHistoryId, LoginType, SourceIp, TargetUrl, UserId, Username, UserType FROM LoginAsEvent WHERE EventDate=Yesterday AND LoginAsCategory=’OrgAdmin’