apex – How to access the “User” object permissions for a profile via Soql?

I want to know how can we fetch the “User” object permissions for a specific profile via soql query. I tried to obtain one using the ObjectPermissions Object but that resulted in 0 results.

Query I ran:

SELECT Id, SObjectType, PermissionsRead, Parent.Id, Parent.Name, Parent.ProfileId, PermissionsCreate, PermissionsEdit, PermissionsDelete, Parent.PermissionsModifyAllData
FROM ObjectPermissions
WHERE SObjectType="User" and Parent.Profile.Name="XYZ"

This query resulted in zero results.
Can we not fetch the ‘User’ object permissions or is there a way to fetch that programatically?

I also tried the solution as mentioned in soql on object permissions on a profile but that also resulted in returning the zero results.

Read more here: Source link