← Sentinel query library

Identity · Microsoft Sentinel

Find interactive sign-in returns after a 30-day observed gap

Require older successful history and no successful interactive events in the intervening 30-day window before flagging a recent return.

Before you run

Data & scope

Required tables
SigninLogs
Time window
91 days: 60-day history, 30-day gap, 1-day review
  • Microsoft Entra ID connector with 91 days of accessible SigninLogs and verified collection continuity.
  • Microsoft Entra ID P1 or P2 for ingestion and an Analytics table/query experience supporting joins.

Documentation review by Codex (AI). No live-tenant execution or detection-performance claim. Validate schema, data coverage and expected results in your workspace.

Kusto Query Language
Download .kql
// Hunting starter. Documentation checked 2026-11-13; not tenant-tested.
let recentStart = ago(1d);
let gapStart = recentStart - 30d;
let historyStart = gapStart - 60d;
let oldHistory = SigninLogs
    | where TimeGenerated >= historyStart and TimeGenerated < gapStart
    | where IsInteractive == true and ResultType == "0"
    | where isnotempty(AADTenantId) and isnotempty(UserId)
    | summarize PriorLastSeen = max(TimeGenerated) by AADTenantId, UserId;
let activeDuringGap = SigninLogs
    | where TimeGenerated >= gapStart and TimeGenerated < recentStart
    | where IsInteractive == true and ResultType == "0"
    | distinct AADTenantId, UserId;
SigninLogs
| where TimeGenerated >= recentStart and TimeGenerated <= now()
| where IsInteractive == true and ResultType == "0"
| where isnotempty(AADTenantId) and isnotempty(UserId)
| summarize ReturnFirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated),
    SignInRows = count(), Names = make_set(UserPrincipalName, 3),
    Apps = make_set(AppDisplayName, 10), SourceIPs = make_set(IPAddress, 10)
    by AADTenantId, UserId
| join kind=inner oldHistory on AADTenantId, UserId
| join kind=leftanti activeDuringGap on AADTenantId, UserId
| extend ObservedGap = ReturnFirstSeen - PriorLastSeen
| project AADTenantId, UserId, Names, PriorLastSeen, ReturnFirstSeen,
    ObservedGap, LastSeen, SignInRows, Apps, SourceIPs
| order by ObservedGap desc
| take 200

Read-only query. Run in your own authorized workspace after checking prerequisites.

This hunt identifies identities with a particular observed history: older successful interactive activity, no such activity in a full 30-day gap, and a successful interactive return during the last day. It is useful when reviewing long-absent operators, contractors or accounts with access to sensitive AI administration. It does not determine employment status, account enablement or overall dormancy.

Require evidence on both sides

The historical window covers 60 days before the quiet interval. The middle window spans 30 days immediately before the review day. A recent identity must join to older history and then pass a left-anti join against activity during the quiet interval. New identities with no older evidence are deliberately excluded.

ObservedGap is the difference between the oldest recent return and the last historical success available to this query. It is an observation within retained telemetry, not a claim about the account’s entire life. The three windows are disjoint, so a recent sign-in cannot become its own baseline. Anti-join semantics.

Investigate the return

Resolve the directory and user object ID to the current account. Check lifecycle records, leave or contract status, assigned privileges and the expected application owner. Follow an established verification process when contacting the person. Inspect the return event’s device, source network, authentication and policy evidence before deciding whether access is expected.

Seasonal duties, extended leave, emergency accounts and infrequent project work can all produce legitimate matches. An attacker using an account regularly can avoid this pattern entirely. A user active only through noninteractive token refreshes could appear quiet here because this hunt measures successful interactive events only.

Protect the comparison from missing data

A 30-day collection outage can manufacture an apparent gap. Confirm source coverage across all 91 days, including the workspace time picker, retention and any ingestion transformation that removed events. Do not run the query with a shorter interface range and interpret the result as a complete comparison.

Test a returning identity with old history, a genuinely new identity, an identity active in the middle interval and a missing-history case. The new identity must be excluded rather than labelled dormant. This documentation-checked query has not been tenant-tested. Use the result as an account-review lead; it is not sufficient grounds by itself to disable a user or assert account takeover.

Verify the source

Microsoft references

  1. Microsoft Learn — SigninLogs table schema ↗
  2. Microsoft Learn — Microsoft Entra ID connector ↗
  3. Microsoft Learn — Kusto leftanti join ↗
  4. Microsoft Learn — Security operations for user accounts ↗
Before turning a hunt into an alert

Measure normal activity, validate known test cases, account for ingestion delays, choose a threshold and entity mapping, and assign an owner. Results require investigation.

Follow the detection learning path →