[SalesForce] How to check Administrative Permissions in Apex class

I wanted to access the administrative permissions in the apex controller for e.g. want to check that the "API Enabled" checkbox is enabled or not.

Please let me know if there is a way to do this.

Thanks in advance!!!

Best Answer

Below is a code to check the "API Enabled" status for logged in user profile. You can query from other profiles in similar way. Hope this will help.

    User user_temp = [SELECT ProfileId FROM User where Id = :UserInfo.getUserId()]; 
    Profile temp_profile = [SELECT PermissionsApiEnabled FROM Profile Where Id = :user_temp.ProfileId];
    Boolean api_permission= temp_profile.PermissionsApiEnabled;
    System.debug('api_permission '+api_permission);
Related Topic