Questions tagged [with-sharing]
Use the with sharing or without sharing keywords on a class to specify whether or not to enforce sharing rules.
24
questions
0
votes
1
answer
44
views
Validate OWD, with sharing, Profile, Permission Sets as Non - ADMIN user
I am trying to validate the OWD for an object that is Public/Read Write without Read permission at the object level for a specific profile user. To validate the results I created a new profile by ...
0
votes
1
answer
142
views
Not getting access related errors while updating records from LWC and with sharing apex
I am trying to update records which I don't have update access on. I am expecting to get errors for such records but it updating successfully.
my org object owd is public read only and profile access ...
0
votes
1
answer
102
views
Unable to pass checkmarx security review
When I use 'Without Sharing' Keyword with class in a managed package and install it in a destination org or sandbox, the code works fine but get error in the checkmarx report.
If I replace 'without' ...
3
votes
0
answers
550
views
With Sharing appears to be enforcing object level security and field level security
We ran into a strange issue today. We have an Apex trigger that is calling an Apex service class. The service class was using with sharing and in our testing, users were able to create records even ...
0
votes
1
answer
240
views
Changing Case Owner in With sharing class
I have few question on "with Sharing" and "without Sharing" keyword in apex,
In my Org the OWD for case is Public read only. I have one class where i am updating owner id of the ...
0
votes
1
answer
1k
views
Identify in which mode(System/User mode) the class is running
From the Salesforce security review point of view for the the app exchange app, we need to add the access checks while querying and doing DML operations.
If we have a requirement that the SOQL/DML ...
3
votes
1
answer
5k
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
1
answer
510
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
1
answer
88
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
2
answers
3k
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
1
answer
152
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
1
answer
746
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
2
answers
695
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 ...
12
votes
2
answers
539
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
1
answer
94
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
2
answers
275
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
1
answer
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
1
answer
670
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
2
answers
540
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
1
answer
417
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
0
answers
153
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
1
answer
144
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!
10
votes
1
answer
277
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
3
answers
3k
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 ...