+ Start a Discussion
DCSDCS 

Execution mode of controller extension - Please clarify

Can some one please clarify  execution mode of controller extension. In Visual force reference, it is documented as below.

My understanding is controller extension enforces the sharing rules of the user. but the line in blue below is misleading. 

Does this mean that custom methods in the extension controller will execute in system mode? Some one please clarify.

 


• A controller extension is a class written in Apex that adds to or overrides behavior in a standard or custom controller.
Extensions allow you to leverage the functionality of another controller while adding your own custom logic.
Because standard controllers execute in user mode, in which the permissions, field-level security, and sharing rules of the
current user are enforced, extending a standard controller allows you to build a Visualforce page that respects user permissions.

Although the extension class executes in system mode, the standard controller executes in user mode. As with custom
controllers, you can specify whether a user can execute methods in a controller extension based on the user's profile.

TehNrdTehNrd

DCS wrote:

Does this mean that custom methods in the extension controller will execute in system mode? Some one please clarify.

 



 

Correct. Yyou can alwasy add the 'with sharing' keywords to your extension classes to respect permissions.

Message Edited by TehNrd on 06-17-2009 02:14 PM
DCSDCS
 I had written the controller for a search functionality. I was doing some testing without using the 'with sharing' keyword. Still I could confirm that records are returned depending on user privilege. Say if a record is owned by another person that the user is not supposed to see, search results does not show that. Any inputs on this?
TehNrdTehNrd
If that is the case either the docs or wrong or the extension is not executing in system mode when it should be. I'd open a case if you can.