A Salesforce permissions audit ends with a count, not a checklist.
A permissions audit asks two separate questions. What may each user do, and which records can each user open? The first is answered by queries over profiles and permission sets. The second is where data leaks between teams, and no Setup screen shows it as a number. Below: the queries, each run read only on my own Salesforce org on 23 November 2026, what they return that nobody warns you about, and the count that settles the second question.
Every query on this page was run on my own developer org, never on a client’s. The access fix it draws on is written up in a shared org case.
Which two questions does a Salesforce permissions audit answer?
Two layers that fail in different ways. Profiles, permission sets and permission set groups decide what a user may do with an object or field. The organisation wide default, the role hierarchy, sharing rules and the View All and Modify All grants decide which records that user can open. Most published checklists cover the first layer well. Exposure between teams nearly always sits in the second.
| Layer | What it settles | Where to read it |
|---|---|---|
| Profile and permission sets | Which objects and fields a user may read, create or edit | PermissionSetAssignment, ObjectPermissions, FieldPermissions |
| Organisation wide default | The starting point for every record of an object | EntityDefinition, one row per object |
| Role hierarchy and sharing rules | Who is lifted above that starting point | The share object of each record, such as AccountShare |
| View All and Modify All | Every record of one object, whatever the sharing says | ObjectPermissions, two checkboxes |
| The result for one person | Whether this user can open this record now | UserRecordAccess, or a report run as that user |
Which queries show who holds the powerful permissions, and through what?
Start from the assignment, not the permission set, because the assignment names a person. The first query lists every active user holding Modify All Data and whether it arrives through a profile or a permission set. The second does the same for View All or Modify All on one object. Swap Opportunity for any object that should be separated between teams, and run it once per object.
SELECT Assignee.Name, PermissionSet.Name, PermissionSet.IsOwnedByProfile
FROM PermissionSetAssignment
WHERE PermissionSet.PermissionsModifyAllData = true
AND Assignee.IsActive = trueSELECT Assignee.Name, Assignee.UserType, PermissionSet.IsOwnedByProfile
FROM PermissionSetAssignment
WHERE Assignee.IsActive = true
AND PermissionSetId IN (
SELECT ParentId FROM ObjectPermissions
WHERE SobjectType = 'Opportunity'
AND (PermissionsViewAllRecords = true OR PermissionsModifyAllRecords = true))On my own org the second query returned eight assignments, held by seven active users who can read every opportunity. One of them is me. The other six are users Salesforce creates itself, with names such as Integration User, Security User and Platform Integration User. An audit that counts them as people overstates the risk; one that deactivates them without asking what each is for may stop a feature. Asked from the other side, ObjectPermissions returned 43 permission sets and profiles holding that grant on opportunities, and filtering to no namespace and not owned by a profile left none: every one of the 43 was a profile or a Salesforce package set in the force namespace.
Queries run read only on 23 November 2026 on my own Salesforce developer org, which holds no client data.
How do you find out which records one team can actually open?
Count them as that team. Log in as one user from team A, run a report on the records that should belong only to team B, and read the number of rows. A report returns only what its user may open, so that number is the exposure. For a single record, UserRecordAccess answers the same question directly: give it a user and a record, and it returns read, edit and the highest level that user holds.
SELECT RecordId, HasReadAccess, HasEditAccess, MaxAccessLevel
FROM UserRecordAccess
WHERE UserId = '005...' AND RecordId = '006...'The report count comes first because it is the one figure a business owner understands without a lecture on sharing. Settings are read afterwards, to explain the count. On my own org UserRecordAccess answered read access yes, edit access no, for one of the integration users above against an account, with MaxAccessLevel Read.
UserRecordAccess query run read only on my own org on 23 November 2026. The report method is how the exposure in the shared org case was found.
Why do separate record types not keep two teams apart?
Because a record type chooses the page layout and the picklist values a user sees, and nothing else. Whether that user can open the record is decided by the default, the sharing rules and the View All and Modify All grants. In a shared org I worked on, each business had its own record types and everybody believed the split was done. Yet another sales team could open a residential developer’s deals and payments.
01Two causes for one complaint
The deals were open through a View All permission on a profile. The payments were open because their default was public read and write. Closing one door would have produced a report saying the work was finished, with half of it still exposed.
02The same four questions for every object
What is its default? Who holds View All or Modify All on it? Which sharing rules lift people above the default? And what does the report count say when run as the other team?
03Share rows only exist where there is something to share
On my own org, with accounts set to public read and write, AccountShare held no rows at all. Counting share rows tells you something only on objects whose default is private or read only.
SELECT QualifiedApiName, InternalSharingModel, ExternalSharingModel
FROM EntityDefinition
WHERE QualifiedApiName IN ('Account', 'Opportunity', 'Lead', 'Case')The org where both doors were open is described in the shared org case; the share row observation and the default query are from my own org on 23 November 2026.
In what order should over broad access be taken away?
Dependencies first, defaults before rules, and production last. In my experience Salesforce will not take View All away while a permission resting on it is still granted, so part of the order is fixed for you. A changed default starts a recalculation of access that can take a while, and a sharing rule deployed during it fails. Every step needs a query that proves it, and a written way back.
01Remove the dependent grants first
On that shared org, View All came off the sales profile in the only order the platform accepted: Modify All on quotes, then View All on quotes, then View All on opportunities.
02Change the default, then wait
Setting the payments default to private started a recalculation. A sharing rule deployed while it ran failed with ALREADY_IN_PROCESS, and the whole deployment rolled back, leaving payments private with no rules, so each person saw only their own.
03Deploy rules only after the recalculation is confirmed
Rules went in once a check confirmed the recalculation had finished, never on a timer.
04Run it on development and staging first
The same sequence on each environment, identically, before production. Then a runbook that holds each change, the query that proves it and how to undo it.
What does the Setup Audit Trail show, and how far back?
Who changed what in Setup, and when: new validation rules, profile edits, sharing changes, each with the user who made it. It does not keep history forever. On my own org on 23 November 2026, the oldest row returned was from the end of May 2026, 178 days earlier. So export it every quarter if you want to know, a year from now, who granted an access and when.
SELECT CreatedDate, CreatedBy.Username, Section, Action, Display
FROM SetupAuditTrail
WHERE CreatedDate = LAST_N_DAYS:180
ORDER BY CreatedDate DESCOne trap. Filtering on Section, the column that says which part of Setup changed, fails in a query with the error that the field cannot be filtered in a query call. Filter on the date, export, and sort by Section in the spreadsheet.
Query and error read on my own org on 23 November 2026.
Permissions audit: what admins ask next
QCan our own admin run this audit?
Yes. Every query here is read only and works from the Developer Console or the Salesforce CLI. What takes judgement is deciding which grants a team needs, and that takes the people who do the work in the room.
QShould the system users Salesforce created be deactivated?
Not on the strength of a query. Find out what each one serves first. They show up in every list of users with broad access, and they are the reason a raw count looks worse than the org is.
QWhat about permission set groups?
Add PermissionSetGroupId to the assignment queries: it is filled when a grant arrives through a group. PermissionSetGroupComponent then lists which sets each group bundles. On my own org it returned the sets inside the groups Salesforce ships for its assistant, which nobody there had assigned.
QDoes tightening access lock people out?
It can, which is why the order above matters. Test as each affected user on staging before production, and keep the runbook open while it runs.
Serhii Skrypnyk, Senior Salesforce Administrator, Salesforce certified, on the platform since 2018. Reviewed 23 November 2026.
Send me the two counts
Run the report test as one user from each team on the object that worries you. If a count comes back above zero where you expected zero, send me the object, the team you tested as and both numbers. My written reply says which of the four questions above points to the open door, what closing it involves and what it would cost, within one working day.
