[SalesForce] Does Apex really runs in a GOD mode (System Mode)

Please help me understand if apex code really runs in a system mode or is there a technical glitch, in our scenario, we are using multiple license types based on end user need, we have almost 3k 'Full Salesforce License' & 1K 'Force.com App Subscription' license.

Our Opportunity object is fully customized and not using commonly used sales features like "Sales Quota", "Forecasting", "Opportunity Product" etc. both, Opportunity detail and edit page are visualforce pages.

We did a POC and found that user with 'Force.com App Subscription' license can also read & update Opportunity object via apex, infact we went one step ahead and tested that user with 'Chatter Free' license also have the capability to read and update Opportunity.

If this is true why would anyone with this scenario will spend dollars every year maintaining 3k users with 'Full Salesforce License' when I can achieve everything with little bit more customization than we have today and converting all users to either 'Force.com App Subscription' or 'Chatter Free' license

Best Answer

Apex Code has two modes of operation: "sharing" and "without sharing" modes. While in sharing mode, the user's permissions will have an effect on what they're allowed to do. When using "without sharing," there's virtually no limitation as to what the code can do, including modifying records on an object the user can't even access, etc, as you've found with your POC.

What's stopping you from doing your own custom platform using Chatter Free license is that you're violating the Master Service Agreement and/or related agreements. You could be charged for full licenses retroactively, and failure to pay is breach of contract that will result in a lawsuit for damages, plus the loss of data that could result.

There are few technical limits in place that prevent some abuses, such as creating a custom user object, custom session object, etc, and proxying a sharing model through a single Sites user, either. The agreements even spell out that there are known abuses that are possible, and that they monitor such abuses.

While you might get away with abusing a few licenses (and I'm not in any way condoning the behavior, as the risk isn't worth the payoff), it's likely salesforce.com would find your account with 3,000+ free users that should be full licenses, and they will make you pay for them or forcefully terminate your account.

Related Topic