1. Resources
  2. Detection sources
  3. Event ID 5140

Event ID 5140: A network share object was accessed

Written on the computer that hosts a share when a session first reaches it, with the account, source address and share. One event per session and share, where 5145 logs each file: the connection behind the accesses the share rules read.

Log source
Windows Security log
Detection value
Context
Volume
High
Last updated
Audit subcategory
Audit File Share (Object Access, Success and Failure)
Logged on
All Windows computers
Event versions
0, 1
Detects
Not read by our detection rules yet

When it is written

Windows writes 5140 on the computer that hosts a shared folder when a client's session first accesses one of its shares, if Audit File Share is on. Microsoft says it is written once per session, at the first access attempt; the checks on each file, folder or named pipe that follow are 5145, a different subcategory (Audit Detailed File Share). Shares have no SACLs, so every share of the computer is covered, including the administrative shares such as C$ and ADMIN$, and IPC$, through which named pipes are reached.

Microsoft lists success and failure for the event and recommends Failure auditing to see failed access attempts to shares; its event page does not describe the failure case further.

How to turn it on

Advanced audit policy subcategory Audit File Share, Success and Failure. Set it in a Group Policy object linked to the computers that write the event:

Computer Configuration > Policies > Windows Settings > Security Settings > Advanced Audit Policy Configuration > Audit Policies > Object Access > Audit File Share
Microsoft's recommendation per computer role
ComputerAuditNote
Domain controllersSuccess and FailureRecommended in both baselines. Success tracks shares being created, changed and deleted; Failure tracks failed SMB SPN checks and failed access attempts to shares.
Member serversSuccess and FailureRecommended in both baselines. Success tracks shares being created, changed and deleted and access attempts to them; Failure tracks failed SMB SPN checks and failed access attempts to shares.
WorkstationsSuccess and FailureRecommended in both baselines. Success tracks shares being created, changed and deleted and access attempts to them; Failure tracks failed SMB SPN checks and failed access attempts to shares.
Check the current setting
auditpol /get /subcategory:"File Share"
Based on vendor documentation.
Turn it on (local policy; a domain GPO overrides it)
auditpol /set /subcategory:"File Share" /success:enable /failure:enable
Based on vendor documentation.
The same on a Windows in another display language
auditpol /get /subcategory:"{0CCE9224-69AE-11D9-BED3-505054503030}"
Based on vendor documentation.

Run the commands in an elevated prompt on a computer that writes the event. Subcategory settings take effect only when the security option Audit: Force audit policy subcategory settings (Windows Vista or later) to override audit policy category settings is enabled (the default), and a Group Policy object that sets advanced audit policy replaces local changes at its next refresh. Microsoft's advanced audit policy reference

Fields

In Event Viewer order. The field names are those of the event XML, from the event template that ships with Windows.

FieldWhat it holdsSince
Security IDSubjectUserSidSubjectSID of the account that accessed the share. Event Viewer shows it resolved to an account name when it can.v0
Account NameSubjectUserNameSubjectName of that account. Computer accounts, such as computers applying Group Policy, end with $.v0
Account DomainSubjectDomainNameSubjectDomain of the account, usually as a NetBIOS name, the computer name for a local account, or NT AUTHORITY for well-known principals.v0
Logon IDSubjectLogonIdSubjectHexadecimal ID of the network logon session. It matches the Logon ID of the 4624 event on the same computer and of the 5145 events of the same session.v0
Object TypeObjectTypeNetwork InformationType of object. Microsoft says it is always File for this event. Version 1.v1
Source AddressIpAddressNetwork InformationAddress of the client (shown as Source Address). IPv6, or an IPv4 address in either plain or ::ffff:a.b.c.d form; ::1 or 127.0.0.1 means the computer itself.v0
Source PortIpPortNetwork InformationSource port of the client connection. 0 for local access.v0
Share NameShareNameShare InformationName of the share, as \\NAME, for example \\SYSVOL, \\C$ or \\IPC$.v0
Share PathShareLocalPathShare InformationLocal path of the share on the server (shown as Share Path), as ??\C:\path. Empty for shares without a folder, such as IPC$. Version 1.v1
Access MaskAccessMaskAccess Request InformationRights asked for, in hexadecimal. Microsoft says it is always 0x1 (ReadData) for this event. Version 1.v1
AccessesAccessListAccess Request InformationThe same rights as message codes (shown as Accesses). Microsoft says it always holds ReadData (or ListDirectory), %%4416, for this event. Version 1.v1

Event versions

The template has two versions. Version 0 has the account, the source address and port, and the share name. Version 1 adds Object Type, Share Path, Access Mask and Accesses. Microsoft's event page lists only version 0 (Windows Server 2008 and Windows Vista) under its event versions, yet its sample event is version 1 and its field descriptions cover the version 1 fields.

  • Version 0: 7 fields
  • Version 1: 11 fields, adds ObjectType, ShareLocalPath, AccessMask, AccessList

Values to know

Share Name ShareName

ValueMeaningSignal
\\*\C$ or \\*\ADMIN$Administrative sharesReserved for administrators. Microsoft gives C$ on domain controllers as an example of a share whose every access is worth monitoring.Worth knowing
\\*\IPC$Named pipesRemote programs reach RPC interfaces through it. The pipe names are in 5145, where the coercion rule reads them.Worth knowing
\\*\SYSVOL or \\*\NETLOGONGroup Policy and logon script shares of a domain controllerMost of the volume on domain controllers.Expected

Source Address IpAddress

ValueMeaningSignal
An address outside your internal rangesA session from outsideMicrosoft suggests monitoring it, and sessions from hosts that should not connect to this computer.Worth knowing
::1 or 127.0.0.1This computerA local access, with source port 0.Worth knowing

Access Mask AccessMask

ValueMeaningSignal
0x1ReadData (or ListDirectory)Microsoft says the event always carries this value, with %%4416 in Accesses.Expected

Volume and noise

Microsoft rates Audit File Share High on file servers, High on domain controllers because Group Policy reads SYSVOL over the network, and Low on other member servers and workstations. Because 5140 is written once per session and share, it is lighter than 5145 on the same computer. On a domain controller most of it is computers and users opening SYSVOL and NETLOGON for Group Policy and logon scripts, and IPC$ sessions of programs that call the server over named pipes.

Keeping it manageable

  • No rule of the library reads 5140. It is the session-level view of the share accesses that the 5145 rules read (named pipes on IPC$, writes to SYSVOL and NETLOGON, reads of a database file named ntds.dit): join the two through SubjectLogonId on the same computer.
  • On domain controllers and other Tier 0 servers, keep every 5140 for C$ and ADMIN$: Microsoft suggests monitoring all access to shares such as C$ on domain controllers.
  • Keep events whose IpAddress is outside your internal ranges, or comes from a host that should not connect to this computer, as Microsoft suggests.
  • Where volume is the limit, the SYSVOL and NETLOGON sessions of computer accounts (SubjectUserName ending with $) are Group Policy processing and are the safest to leave out.
  • The subcategory also writes 5142, 5143 and 5144 when a share is added, changed or deleted, and 5168 when an SMB SPN check fails. Keep those: Microsoft recommends both Success and Failure on every role.

Sample event

Version 1, with made-up values.

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-Windows-Security-Auditing" Guid="{54849625-5478-4994-a5ba-3e3b0328c30d}" />
    <EventID>5140</EventID>
    <Version>1</Version>
    <Level>0</Level>
    <Task>12808</Task>
    <Opcode>0</Opcode>
    <Keywords>0x8020000000000000</Keywords>
    <TimeCreated SystemTime="2026-11-18T09:30:12.4567890Z" />
    <EventRecordID>1048576</EventRecordID>
    <Correlation />
    <Execution ProcessID="712" ThreadID="2408" />
    <Channel>Security</Channel>
    <Computer>DC01.corp.example.com</Computer>
    <Security />
  </System>
  <EventData>
    <Data Name="SubjectUserSid">S-1-5-21-1004336348-1177238915-682003330-1104</Data>
    <Data Name="SubjectUserName">alice</Data>
    <Data Name="SubjectDomainName">CORP</Data>
    <Data Name="SubjectLogonId">0x5d3a41</Data>
    <Data Name="ObjectType">File</Data>
    <Data Name="IpAddress">::ffff:10.20.30.41</Data>
    <Data Name="IpPort">50412</Data>
    <Data Name="ShareName">\\*\SYSVOL</Data>
    <Data Name="ShareLocalPath">\??\C:\Windows\SYSVOL\sysvol</Data>
    <Data Name="AccessMask">0x1</Data>
    <Data Name="AccessList">%%4416</Data>
  </EventData>
</Event>

Attacks this event reveals

No detection rule or detection logic in our library reads this event yet. It is documented here because it sits next to the events they read: it explains them, follows from them or is the trace a defender looks for around them (see Related events).

Frequently asked questions

What is the difference between events 5140 and 5145?

5140 (Audit File Share) is written once per session and share, when the session first reaches the share. 5145 (Audit Detailed File Share) is written for each access check on a file, folder or named pipe in the share. Use 5140 to see who connected to which share from where, and 5145 to see what they opened; both carry the Logon ID of the session.

Why does 5140 appear only once when a user opened many files?

Microsoft says it is written once per session, at the first access to the share. The files opened afterwards appear only in 5145, if Audit Detailed File Share is on.

Which 5140 events deserve a look on a domain controller?

Microsoft suggests monitoring all access to shares such as C$ on domain controllers, sessions from addresses outside your internal ranges, and sessions from hosts that should not connect to the computer. Administrative shares are how files are often copied to and from a server, so their sessions on domain controllers are worth reading with the 5145 events of the same session.

References