Vulnerability in EPiServer.Forms
I get this error when a job I created runs automatically. It works fine when I run it manually. The job creates and updates blocks. Do I need to do anything to set the permissions for whatever service account the job runs under?
When you run manually, the job uses your principal - which usually is the admin. When you run it automatically it will use either the anonymous principal, or the principal you assign to it. so the solution could be either
For the second option mentioned by Quan, you could add a dependency of IPrincipalAccessor in the constructor and then assign as below.
_principalAccessor.Principal = new GenericPrincipal(new GenericIdentity("RoleNameGoeshere"), null);
Can you try this :
Based on the MS documentation, it looks like you also need to assign the principal to current thread https://learn.microsoft.com/en-us/dotnet/standard/security/how-to-create-genericprincipal-and-genericidentity-objects
var myPrincipal = new GenericPrincipal(new GenericIdentity("RoleNameGoeshere"), null);
_principalAccessor.Principal = myPrincipal
Thread.CurrentPrincipal = myPrincipal;
You might need to share your code here (removal of any sensitive information of course). You can also reach out to developer support service if confidential access is required.