+ Start a Discussion
ciccic 

cannot use apex code that references object to which user has no access

I have a set of Apex Code.  It references various custom objects.  I want a low-level user profile to be able to access those Apex Code classes.   One of the custom objects is marked as not accessible by that profile (it contains my system config data).  The user cannot use any of the Apex Code classes because one of the dependant classes references the hidden custom object.
 
This seems to violate the Apex Code design principal that the Apex Code writer is resonsible for security of objects i.e. the code all runs at the system administrator level of priviledge.  The code would run if it would compile.  It drops out with an Exception because it can't compile the dependant class.  The only way I can get it to work is to switch on Read access to that custom object in the profile.
 
As a side query on this I'm not sure why the code is compiling?  It says it is because one of the dependant classes is invalid.  However I've tried recompiling them all as a system administrator and trying again.  I still get the same error message.  Does Apex Code compile every time a user calls it.
 
PS The Apex Classes are being called via AJAX and webservice methods.  I've enabled the class-level security of those to all profiles.
 
 
mtbclimbermtbclimber
This is a known issue in Summer '07 which has been fixed in Winter '08 which is due to be released in November.