function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RIteshMRIteshM 

How to know the Logged in user accessing visualforce page is Admin or not

How to know the Logged in user accessing visualforce page is Admin or not using apex. i want to do this using my custom controller .i know in visualforce we can do like this $Profile.Name =='System Administrator' but how to accomplish it in apex code ??

souvik9086souvik9086

public class GetProfile {

List<Profile> PROFILE = [SELECT Id, Name FROM Profile WHERE Id=:userinfo.getProfileId() LIMIT 1];

if(PROFILE.get(0).name == 'System Administrator') {

// Do your work

}

}

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks