To show an auditor who opened a Windows file share last week, how do events 5140 and 5145 differ and which audit subcategories must be on?
answer
- one event per session versus per file
- two subcategories, both named File Share
- no per-share SACL to set
- a Relative Target Name field
- Get-SmbSession shows only the present
basics
~20 sEvent 5140, from Audit File Share, is written once per session at the first access to a share. Event 5145, from Audit Detailed File Share, is written per file or folder and adds the Relative Target Name.
solid answer
~40 s**5140** ("A network share object was accessed") comes from the `Audit File Share` subcategory and is generated once per session, at the first access attempt: it gives the account, the source IP address and port and the share name. **5145** comes from `Audit Detailed File Share` and is generated each time a file or folder on a share is accessed, adding the `Relative Target Name` and the access check results. Shares have no SACLs, so enabling either subcategory audits all shares on the system, and 5145 volume is high on file servers. Failures in 5145 are logged only for share-level denials. `Get-SmbSession` shows who is connected now, not last week.
go deeper
Recall that events 5140 and 5145 record share access and that auditing must be switched on in advance.
Say which audit subcategory writes each event, how often it writes it, and which fields each event carries.
Choose settings for the volume, state what the log cannot show (file-system denials, history before enabling) and answer the auditor honestly.
Balance the evidence value of per-file auditing against Security log volume and retention across the file-server estate.
## The question behind the question "Who opened the `Finance` share last week?" is a request for **evidence**, and a log only holds what it was told to record before the event. So the answer has three parts: which events, which settings produce them, and what they do and do not show. ## 5140 and 5145 side by side | | **5140** | **5145** | |---|---|---| | Title | A network share object was accessed | A network share object was checked to see whether client can be granted desired access | | Audit subcategory | `Audit File Share` | `Audit Detailed File Share` | | When | Once per session, at the first access attempt | Every time a file or folder on a share is accessed | | Share fields | Share Name (for example `\\*\Finance`), Share Path | Share Name, Share Path, **Relative Target Name** | | Access detail | Access Mask always `0x1` (ReadData or ListDirectory) | Access Mask, the requested rights, and the access check results | | Failure events | Yes | Only when access is denied at the share level | | Log | Security | Security | Both record the account, the logon ID, and the **source address and port** of the client, which is what ties a request to a machine. The `Audit File Share` subcategory also covers 5142, 5143 and 5144 (a share added, modified and deleted) and 5168 (an SMB SPN check failure), which answers "who created or changed this share". ## Settings and volume - Microsoft's pages say there are **no system access control lists for shares**, so once a subcategory is enabled, access to all shares on the system is audited. You cannot pick shares. - **Volume is high on file servers.** Microsoft recommends success and failure auditing for `Audit File Share` on servers, while for `Audit Detailed File Share` it recommends failure auditing and success only if you really need every file access. - The `Audit File System` subcategory can also record successful file access, but Microsoft notes it excludes some information `Audit Detailed File Share` has, such as the client IP address. ## What the events do not show 1. **A file-system denial.** A 5145 failure appears only for a share-level denial. 2. **Last week, if auditing was off.** Nothing is recorded retroactively. 3. **Who is connected now.** `Get-SmbSession` on the server lists current sessions with client computer name, user name and open-file count; `Get-SmbConnection` is the client-side view of connections to servers. Neither is history. 4. **A pipe's identity, without checking.** For `IPC$` events, confirm on a real event what the Relative Target Name holds. An example of the fields in a 5145 event (values reserved): ```xml <EventData> <Data Name="SubjectUserName">alice</Data> <Data Name="SubjectDomainName">EXAMPLE</Data> <Data Name="IpAddress">192.0.2.25</Data> <Data Name="IpPort">56926</Data> <Data Name="ShareName">\\*\Finance</Data> <Data Name="RelativeTargetName">budget-2026.xlsx</Data> <Data Name="AccessMask">0x100081</Data> </EventData> ``` ## Retention and sizing Per-file events on a busy file server can fill a Security log quickly, and an event that has been overwritten answers nothing. Before enabling `Audit Detailed File Share`, decide how long the auditor needs history, size the Security log or forward events to central storage to match, and test the volume on one server. Microsoft's own pages call the volume high on file servers, which is why its guidance leans on failure auditing for the detailed subcategory. ## A reasonable procedure 1. Turn on `Audit File Share` for success and failure on the file server. 2. Decide whether per-file evidence is worth the volume; if so enable `Audit Detailed File Share`, sizing the Security log for it. 3. Filter 5140 by share name and time to answer "who opened it" at session level, then use 5145 for which files. 4. Tell the auditor the history starts from the day the setting was enabled.
- Why not simply enable Audit Detailed File Share with success auditing on every file server?Because per-file events are high volume on file servers and shares have no SACLs to narrow them. Microsoft recommends failure auditing for that subcategory and success only where you really need every file access, with the Security log sized for it.
- Which fields in a 5140 event let you tie the access to a client machine?The source address and source port, along with the subject account and logon ID. The share name and share path say what was reached. 5140 is written once per session, so it gives who and from where, not each file.
- 5140 records every file opened on the share
- You can choose shares to audit with a SACL on each share
- A file-system denial always produces a 5145 failure
- Get-SmbSession shows who opened the share last week
- Enabling auditing now fills in last week's history