Query Details
let query_frequency = 1h;
let query_period = 14d;
let _DomainControllers = toscalar(
_GetWatchlist("Service-PrivateCorporateServices")
| where Service == "DomainController"
| summarize make_list(HostName)
);
SecurityEvent
| where TimeGenerated > ago(query_period)
| where EventID == 5140 and Computer has_any (_DomainControllers) and not(ShareName in (@"\\*\SYSVOL", @"\\*\IPC$", @"\\*\NETLOGON"))
| summarize arg_min(TimeGenerated, *) by Computer, Account, IpAddress, ShareLocalPath, ShareName
| where TimeGenerated > ago(query_frequency)
| project
TimeGenerated,
Computer,
AccountType,
Account,
IpAddress,
Activity,
ShareName,
ShareLocalPath,
ObjectType,
SubjectLogonId,
AccessList,
AccessMask,
EventData
This KQL query is designed to monitor and identify specific network share access events on domain controllers within a corporate environment. Here's a simplified breakdown of what the query does:
Define Parameters:
query_frequency is set to 1 hour, meaning the query will focus on events that occurred in the last hour.query_period is set to 14 days, indicating the overall time range for data analysis.Identify Domain Controllers:
Filter Security Events:
SecurityEvent table for events generated within the last 14 days.EventID 5140, which indicates a network share object was accessed.SYSVOL, IPC$, and NETLOGON from the results.Summarize Events:
arg_min) of each event by computer, account, IP address, share local path, and share name.Filter Recent Events:
Select Relevant Data:
In essence, this query helps in monitoring unauthorized or unusual access to network shares on domain controllers, excluding standard administrative shares, and focuses on recent activities to quickly identify potential security issues.

Jose Sebastián Canós
Released: April 30, 2025
Tables
Keywords
Operators