1

I have a generic question in my mind. Suppose that we have an apex controller that is doing DML operations on a custom object. Now my questions are

  1. Does context user's profile affect DML operations?

  2. Does context user's license affect DML operations?

  3. What if context user doesn't even have read permission to the object. Can he still do DML operation using apex controller?

4
  1. Yes - if the class uses the with sharing keywords. The data the user can see and manipulate will be tied to their profile permissions for the object(s) in question.

  2. The licence will affect the results if it prevents access to particular objects. The user will not be able to see data from such objects or create/update them.

  3. If a user doesn't have read permission then he can not see data stored in that object, unless the class being used specifies without sharing. These keywords have their place but should always be used with caution and only when absolutely necessary.

  • I had created one VF page which was a associated with an apex controller. Then I enabled this VF page for sites. Now from sites, I was able to create account and contact with using "with sharing" and I wasn't even having read permission to both account and contact on guest user profile. Please correct me if I am wrong. – doga Apr 8 '13 at 5:46
  • Were you still logged in to the org at the same time? Are you sure you were using the sites guest user (logs would be a good way to check). – Matt Lacey Apr 8 '13 at 6:21
  • 3
    You should mention that "with sharing" does nothing to enforce either CRUD or FLS permissions, they have to be checked manually if needed within Apex (standard VF components enforce them). – jkraybill Apr 8 '13 at 6:23
  • @LaceySnr Yes, I was using different browser. You can check at your end as well. and let me also confirm from my end. – doga Apr 8 '13 at 6:25
  • @LaceySnr I found one statement "Apex generally runs in system context; that is, the current user's permissions, field-level security, and sharing rules aren’t taken into account during code execution." According to this user's permissions and FLS are not enforced. salesforce.com/us/developer/docs/apexcode/Content/… – doga Apr 12 '13 at 7:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.