Query Details
let _ExpectedDomain = toscalar(
_GetWatchlist("Activity-ExpectedSignificantActivity")
| where Activity == "DomainJoinedLDAP"
| summarize make_list(Auxiliar)
);
let _Identities =
IdentityInfo
| where TimeGenerated > ago(14d)
| summarize arg_max(TimeGenerated, *) by AccountUPN
;
IdentityLogonEvents
| where TimeGenerated > ago(1h)
| where ActionType == "LogonSuccess" and Protocol in ("Adfs", "NTLM") and isnotempty(DeviceName) and not(DeviceName has_any (_ExpectedDomain))
| summarize hint.shufflekey=TimeGenerated
Protocols = array_sort_asc(make_set(Protocol)),
DeviceNames = array_sort_asc(make_set(DeviceName)),
LogonTypes = array_sort_asc(make_list(LogonType))
by AccountUpn, TimeGenerated
| where Protocols has_all ("Adfs", "NTLM") and LogonTypes has_all ("Logon with ADFS authentication", "Resource access")
| lookup kind=leftouter _Identities on $left.AccountUpn == $right.AccountUPN
| where SourceSystem has "ActiveDirectory" or UserAccountControl has "PasswordNeverExpires"
| project
TimeGenerated,
AccountUpn,
DeviceNames,
LogonTypes,
Protocols,
UserAccountControl,
AccountDisplayName,
JobTitle,
Manager,
Department,
OnPremisesDistinguishedName,
Tags,
GroupMembership,
AssignedRoles,
SourceSystem,
AccountSID,
AccountObjectId
This query retrieves information about identity logon events. It first gets a list of expected domains for significant activity. Then, it retrieves identity information for the past 14 days. Next, it filters logon events that occurred within the past hour and meet certain criteria, such as successful logons with specific protocols and device names that are not in the expected domain list. It then summarizes the results by account UPN and time generated. It further filters the results to include only logon events with specific protocols and logon types. It performs a left outer join with the identity information and filters the results based on certain conditions, such as the source system being Active Directory or the user account having a password that never expires. Finally, it projects specific fields from the results.

Jose Sebastián Canós
Released: August 16, 2023
Tables
Keywords
Operators