Questions tagged [with-sharing]

Use the with sharing or without sharing keywords on a class to specify whether or not to enforce sharing rules.

Filter by
Sorted by
Tagged with
1
vote
1answer
38 views

WITH SECURITY_ENFORCED and Security.stripInaccessible in a single SOQL

Premise: I followed WITH SECURITY_ENFORCED, Security.stripInaccessible and comparison before designing my Apex class for querrying a few records. Doubt: I implemented my SOQL as Security....
2
votes
1answer
93 views

Aura Controller "with sharing" is still acting as without sharing and allows deletion

Current Setup: I have an Aura controller which uses "with sharing" and a method deletes a lead using the Id. I set up a user with profile with no Delete access. I have also revoked "...
0
votes
1answer
25 views

Class declared as With Sharing then why Permission check?

Can anyone please explain if the class is declared as With Sharing then why do we still need to check if the User has permission for SOQL or not or the object creatable/editable etc? Please clarify. ...
1
vote
2answers
825 views

User without CRUD permission is able to create record in 'With Sharing' class

I have a patient object , related to Account (lookup relationship). Profile 'Standard User' doesn't have CRUD permissions on the patient object. In Account trigger, I call call 'accounthandler.cls' ...
1
vote
1answer
46 views

With sharing class and update record

I have a visual force page and its controller as follows: <apex:page controller="OpportunityBusinessService" tabStyle="Opportunity"> <apex:form> <apex:...
0
votes
1answer
88 views

is omitted sharing in a class the same as with sharing?

I am bit confused about with sharing and without sharing in Apex. I have set OWD to private for Contacts and created sharing rules. If I login as an Admin, I see all the contacts. If I login with a ...
0
votes
2answers
64 views

Get records as per role heirarchy

I have a requirement of getting accounts with respect to role heirarchy. For eg. Lets say there are 3 roles A,B,C. Now when A user logins i want to fetch all the records of A,B,C user, similarly if B ...
11
votes
2answers
326 views

Clean way to vary sharing at runtime in Apex?

I may need to make many @RestResource Apex classes run either with sharing or without sharing where that option is selected at runtime. But this approach (that I am using at present): /** * Allow ...
2
votes
1answer
70 views

Do we have to force all FFLIB classes with `with sharing` keywords to pass security review?

I'm using FFLIB classes in my managed package and i just wanted to know if i should mark FFLIB classes use in my package with with sharing keyword to follow security review requirements ? Thanks,
3
votes
2answers
146 views

with and without sharing with innerclass

I'm working on a project that needs to change a lot of data that the user shouldn't see in the backoffice. So I'm wondering if I should put my entire class "without sharing". For now I'm creating a "...
0
votes
1answer
3k views

INVALID_CROSS_REFERENCE_KEY: Record Type ID: this ID value isn't valid for the user: (RecordTypeId)

I do know that we can use "without sharing" when we dont want to apply the sharing rules of the current user to set the values, but my class has nothing after access modifiers, just public class ...
1
vote
1answer
276 views

`sharing` / `without sharing` keywords inheritance behaviour

I have a doubt regarding sharing mechanism in Salesforce. If we have these classes: public without sharing class Ctrl1 { } public with sharing class Ctrl2 extends Ctrl1 { } By reading the ...
2
votes
1answer
432 views

Sharing Setting - Contact - Controlled by Parent - Community - SOQL -Apex With Sharing

In my org, we have 5 contact matching 'dummy record'. When we use SOQL in community pages. It shows only one records. Sharing setting Contact : Controlled by Parent Account : Public read/write ...
0
votes
1answer
364 views

Limit SOQL results using 'with sharing' in Controller does not limit returned data for Pricebooks

I am running a SOQL query in a controller where I have declared 'with sharing' at the class level. The returned results are not following the sharing rules setup for the current user. The sharing ...
2
votes
0answers
121 views

Community Plus User - Contact sharing via SOQL does not match List View

In my Visualforce Page, I just use the following code to get a name list of contacts that the current user can visit. public with sharing class TestClass{ public String getAllContactNames(){ ...
0
votes
1answer
112 views

Not able to access CronJobDetail object when class is With sharing mode

I am not able to access CronJobDetail object when my class is in with sharing mode. Getting the below error: sObject type 'CronJobDetail' is not supported. Any idea? Thanks!
9
votes
1answer
200 views

Read access denied: getQueryLocator(soql) vs. query(soql)

I am attempting to add pagination, and I followed this great article by Jeff Douglas. I am an admin so when I run the page it runs great, I can navigate forwards, back. When I log in as a user my ...
15
votes
3answers
2k views

What's It Called: Inner Class Without Sharing?

I believe I have heard a specific term for this pattern, but I am not able to retrieve it from the foggy banks of my memory: public with sharing class OuterClass { public without sharing class ...