Investigation · Data access
Who accessed, downloaded or shared this SharePoint or OneDrive file?
Reconstruct one SharePoint or OneDrive file's history from the unified audit log: views, downloads, syncs, sharing links, guests and anonymous use.
When you would ask thisA sensitive document may have been exposed: shared outside the organization, opened by someone who should not have it, or downloaded by a compromised account. You need a defensible list of who accessed it, how, and through which sharing path, for impact assessment and notification.
Steps
- 1
Pin down the file's identifiers
Unified audit log records for SharePoint and OneDrive identify the file by its full URL in ObjectId (OfficeObjectId in Sentinel's OfficeActivity), with SourceFileName, SourceRelativeUrl and SiteUrl alongside, and a ListItemUniqueId for the list item. The URL changes when the file is renamed or moved, so collect every name and location the file has had (version history and FileRenamed or FileMoved records help) and search for each. A file in someone's OneDrive lives under that user's -my.sharepoint.com personal site, which matters when the file was shared from a personal OneDrive rather than a team site.
- 2
Pull every audit record for the file
Search the unified audit log for all operations on the file across the full retention window. Audit (Standard) keeps records for 180 days for records created after October 2023, longer with Audit (Premium) or retention policies, so an exposure discovered late may already have lost the earliest sharing events; check your tier. Search-UnifiedAuditLog accepts the file URL in -ObjectIds and returns at most 5,000 records per call, so split long windows. Sentinel's OfficeActivity holds the same SharePoint and OneDrive records from the point the Office 365 connector was enabled.
All audit records for one file (Exchange Online PowerShell)# Connect-ExchangeOnline first. Repeat for each earlier URL of the file. $url = "https://contoso.sharepoint.com/sites/Finance/Shared Documents/Payroll 2026.xlsx" Search-UnifiedAuditLog -StartDate 2026-05-01 -EndDate 2026-11-01 -ObjectIds $url -ResultSize 5000 | ForEach-Object { $d = $_.AuditData | ConvertFrom-Json [pscustomobject]@{ Time = $_.CreationDate; Operation = $_.Operations; User = $_.UserIds IP = $d.ClientIP; Agent = $d.UserAgent; Target = $d.TargetUserOrGroupName } } | Sort-Object Time - 3
Separate views, downloads and syncs
Classify each record by what it proves. FileAccessed (and FilePreviewed) means the file was opened or rendered in the browser or an Office client. FileDownloaded means a copy was downloaded through the browser. FileSyncDownloadedFull and FileSyncDownloadedPartial mean the OneDrive sync client copied it to a device, which is easy to miss if you only search for FileDownloaded. FileCopied, FileMoved and FileUploaded show the file being duplicated or relocated. For each record keep the UserId, ClientIP, UserAgent and time. Only downloads and syncs show that a copy left the service; an access record alone does not.
Access, download and sync records per user (Sentinel KQL)let fileUrl = "https://contoso.sharepoint.com/sites/Finance/Shared Documents/Payroll 2026.xlsx"; OfficeActivity | where TimeGenerated > ago(180d) | where OfficeWorkload in ("SharePoint", "OneDrive") | where OfficeObjectId =~ fileUrl | where Operation in ("FileAccessed", "FileAccessedExtended", "FilePreviewed", "FileDownloaded", "FileSyncDownloadedFull", "FileSyncDownloadedPartial", "FileCopied", "FileMoved") | summarize Records = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated), IPs = make_set(ClientIP, 20), Agents = make_set(UserAgent, 10) by UserId, Operation | order by FirstSeen asc - 4
Understand the limits of FileAccessed
FileAccessed is the weakest of these records. Office clients, previews and thumbnails can generate it without a person reading the document, and when the same user keeps working in a file for an extended period the service records FileAccessedExtended rather than a FileAccessed for every open, so the number of records is not a number of reads. System and service identities (for example app@sharepoint, and search or scanning services) also produce access records and should be separated from people. Access by an application through Microsoft Graph may appear under the app's identity. Treat FileAccessed as evidence that a person or process had the file open, and lean on downloads, syncs and sharing records to describe exposure.
- 5
Reconstruct how the file was shared
Sharing operations show who widened access and to whom. SharingSet records a permission granted directly to a user or group. SharingInvitationCreated records an invitation to someone outside the organization, and SharingInvitationAccepted records it being redeemed. Links have their own pairs: AnonymousLinkCreated and AnonymousLinkUsed for anyone-with-the-link links, CompanyLinkCreated and CompanyLinkUsed for people-in-your-organization links, and SecureLinkCreated, SecureLinkUsed and AddedToSecureLink for links limited to specific people. SharingRevoked records access being removed. The target of a direct share appears in TargetUserOrGroupName and TargetUserOrGroupType (for example Guest or Member) in the AuditData; confirm how your workspace exposes those fields. If the URL filter returns nothing, broaden to SourceFileName, because some sharing records reference the item by a slightly different path.
Sharing and link activity on the file (Sentinel KQL)OfficeActivity | where TimeGenerated > ago(180d) | where OfficeObjectId =~ "https://contoso.sharepoint.com/sites/Finance/Shared Documents/Payroll 2026.xlsx" | where Operation in ("SharingSet", "SharingInvitationCreated", "SharingInvitationAccepted", "AnonymousLinkCreated", "AnonymousLinkUsed", "CompanyLinkCreated", "CompanyLinkUsed", "SecureLinkCreated", "SecureLinkUsed", "AddedToSecureLink", "SharingRevoked") | project TimeGenerated, Operation, UserId, ClientIP, UserAgent, Target = column_ifexists("TargetUserOrGroupName", ""), TargetType = column_ifexists("TargetUserOrGroupType", "") | order by TimeGenerated asc - 6
Identify guests and anonymous users
Guest accounts appear with #EXT# in the UserId (for example partner_fabrikam.com#EXT#@contoso.onmicrosoft.com). For each guest, find the Entra B2B invitation and redemption (Invite external user and Redeem external user invite in AuditLogs) to learn who invited them and when they first signed in. Anonymous link use carries no identity: the UserId is a placeholder for an anonymous user rather than a person, so the ClientIP and UserAgent on AnonymousLinkUsed and the related access and download records are all you have, and anyone who obtained the link could have used it. Check whether the link still exists in the file's Manage access panel; its creation event may have aged out of retention while the link is still live.
- 7
Report who could access versus who did
Close by separating two lists. Who could access: the current permissions and live links (Manage access, or the drive item's permissions through Microsoft Graph), plus any access that existed during the window but has since been revoked. Who did access: the identities, IPs and devices with FileAccessed, FileDownloaded or FileSyncDownloadedFull records, with anonymous use counted by IP. If a compromised account is involved, attribute only the records that match the attacker's IPs and sessions, and continue with the exfiltration playbook for any copies that left the tenant.
Where it goes wrong
- FileAccessed is not a reliable count of reads: clients and previews generate it, long sessions are recorded as FileAccessedExtended, and system identities add noise.
- Renaming or moving the file changes the URL in ObjectId, so a search on the current URL alone misses the file's earlier history.
- Anonymous links record no identity; AnonymousLinkUsed gives an IP and user agent, and anyone who received the link could be behind it.
- Sync client copies are FileSyncDownloadedFull or FileSyncDownloadedPartial, not FileDownloaded; filter only on FileDownloaded and you miss bulk copies to devices.
- Audit (Standard) retention is 180 days for current records; sharing that happened earlier may be gone from the log while the link is still live, so check current permissions as well as the log.
- Audit records can arrive hours after the activity and Search-UnifiedAuditLog caps each call at 5,000 records; re-run searches and split long windows before closing scope.
Beyond event logs
Manage access panel and sharing links
The file's Manage access panel in SharePoint or OneDrive; sharing reports in the SharePoint admin center where available
Shows who can access the file now and which links exist, including links whose creation has aged out of the audit log.
Entra B2B guest objects
Entra admin center: Users filtered to guests; AuditLogs Invite external user and Redeem external user invite
Ties a guest UserId to the person who invited them and the date they first redeemed the invitation.
File version history
The file's version history in its document library
Shows who modified the file and when, and its earlier names, which helps you find audit records filed under old URLs.
Microsoft Graph activity logs
MicrosoftGraphActivityLogs in Log Analytics, if enabled before the incident
Captures application access to drive items through Graph, which matters when an OAuth app rather than a person read the file.
Keep going
- InvestigationDid data leave, how much, and to where?
- InvestigationWhat did the attacker read, send and change in this mailbox?
- InvestigationWhich files were accessed or staged over SMB shares?
- InvestigationDid a user consent to a malicious OAuth application?
- Field valueFileAccessed
- Field valueFileDownloaded
- Field valueFileSyncDownloadedFull
- Field valueAnonymousLinkCreated