Activity Forums Salesforce® Discussions How to apply Security of logged in user on Apex & VF in Salesforce page

  • How to apply Security of logged in user on Apex & VF in Salesforce page

  • zahraa wahsh

    Member
    June 9, 2019 at 1:08 pm

    Hello Everyone !

    While going through manuals, it was mentioned Many times that  apex classes will not consider security of logged in user but it will run in system mode and we should add custom controller extension to apply security of logged  in user  .

    At the same time it is mentioned that  every class has the value with sharing, which means that sharing keyword will  apply security of logged in user

     

    what is correct ? does apex classes apply security of logged in user ????

  • ABHISHEK SHAHI

    Member
    June 18, 2019 at 8:25 pm

    Apex class can be written in two category:-

    1. With sharing keyword:- If you declare a class as a With Sharing, Sharing rules given to the current user will be taken into the consideration and the user can access or perform the operations based on the permissions given to him on object and fields (Field Level Security, Sharing rules).
    2. Without sharing keyword:- If you declare a class as a Without Sharing, then this Apex class runs in system mode which means Apex code has access to all the objects and field irrespective of current users sharing rules, field level security and Object Permissions.

    Ideally, for visualforce page, apex classes should run in with sharing to enable permission applicable for a user based on their profile.

    Thanks

    Abhishek shahi

Viewing 1 - 2 of 2 posts

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos