← Back to SOC feed Coverage →

Detect-Not-Active-AD-User-Accounts

kql MEDIUM Azure-Sentinel
IdentityLogonEvents
huntingmicrosoftofficial
This rule was pulled from an open-source repository and enriched with AI. Validate in a test environment before deploying to production.
View original rule at Azure-Sentinel →
Retrieved: 2026-05-09T11:00:00Z · Confidence: medium

Hunt Hypothesis

Inactive Active Directory service accounts with last logon dates exceeding 14 days may indicate dormant or abandoned accounts that could be exploited by adversaries to maintain persistence or escalate privileges. Proactively hunting for such accounts in Azure Sentinel helps identify potential attack vectors and reduce the attack surface within the environment.

KQL Query

IdentityLogonEvents 
| project Timestamp, AccountName, DeviceName, LogonType
| where AccountName startswith "XXX" 
| summarize LastLogon = max(Timestamp) by AccountName, LogonType, DeviceName
| where LastLogon < ago(14d)

Analytic Rule Definition

id: 9131b716-334f-416e-a50f-809927d63b42
name: Detect-Not-Active-AD-User-Accounts
description: |
  // Detect Active Directory service accounts that are not active because their last logon was more than 14 days ago
  // Replace XXX on line 4 with the naming convention start of your Active Directory service accounts
requiredDataConnectors:
- connectorId: MicrosoftThreatProtection
  dataTypes:
  - IdentityLogonEvents
query: |
  IdentityLogonEvents 
  | project Timestamp, AccountName, DeviceName, LogonType
  | where AccountName startswith "XXX" 
  | summarize LastLogon = max(Timestamp) by AccountName, LogonType, DeviceName
  | where LastLogon < ago(14d)

Required Data Sources

Sentinel TableNotes
IdentityLogonEventsEnsure this data connector is enabled

References

False Positive Guidance

Original source: https://github.com/Azure/Azure-Sentinel/blob/main/Hunting Queries/Microsoft 365 Defender/Discovery/Detect-Not-Active-AD-User-Accounts.yaml