How to execute EventHub code under full permissions?
I'm new to Sitefinity. I've built out an EventHub handler to react to items submitted to the Forms module that creates new items in a content type within a module built with Module Builder using the CreateDataItem method of the DynamicModuleManager class. This works OK if I submit the form data while logged in as an administrator. However, if I submit form data as an anonymous user, I get a System.UnauthorizedAccessException when my code hits the SaveChanges method of the DynamicModuleManager class.
How can I ensure that my EventHub-triggered code will run with full permissions, even if it is triggered by an anonymous user's action?
Hi Bryan,
Can you please add the following line after you get the dynamic module manager (and before you call SaveChanges()):
DynamicModuleManager dynamicManager = DynamicModuleManager.GetManager();
dynamicManager.Provider.SuppressSecurityChecks =
true
;
Thank you, Sabrie. That suggestion solved my problem.