3

Please Note :

Not for Current Logged in User

How to find a particular user A has what access on particular object (Read or Create access) say on Account Via Apex Class.

2
  • Are you asking how to do this in the Test context or outside of the Test context.
    – Eric
    Aug 22, 2014 at 13:10
  • @eric, not in test context. that we can do I guess using system.runAs. But I want to know outside of Test Context. Aug 22, 2014 at 13:16

1 Answer 1

3

I believe this information is what you want:

How to access profile permissions via API

Basically you will need to query the ObjectPermissions sObject since every profile has at least one underlying Permission set

SELECT Id, SObjectType, PermissionsRead, PermissionsCreate
FROM ObjectPermissions
WHERE parentid in (select id from permissionset where
PermissionSet.Profile.Name = 'System Administrator')
7
  • It will not work out as I can have an user associated with a profile and that profile is having read access to say Account. Now I created a permission set and associated with user which gives Create access to user. So only by profile we wont be able to find out if user as access to an Object(Account) or not. Correct me if I am wrong. Aug 22, 2014 at 13:36
  • You do not create a profileset Every profile has a system underlying profile set according to the post. Read the blog entry in the post and you will see.
    – Eric
    Aug 22, 2014 at 14:00
  • I am not talking about Profile Set. I am talking about "Permission Set" which can be associated at any user. With the "Permission Set" user can have access to Object even if they do not have the access at profile level. Aug 22, 2014 at 14:03
  • k, then you will have to cycle through both the profile and permission set to see in total what access they have....This is the only way to currently do it outside of test methods
    – Eric
    Aug 22, 2014 at 14:06
  • ,Thanks for your support. Let me check if it works. I will update on my findings. Aug 22, 2014 at 14:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .