How to execute EventHub code under full permissions?

Posted by Community Admin on 04-Aug-2018 23:33

How to execute EventHub code under full permissions?

All Replies

Posted by Community Admin on 06-Nov-2014 00:00

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?

Posted by Community Admin on 11-Nov-2014 00:00

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;

When the SuppressSecurityChecks property is set to true the permissions check of the provider should be skipped and you will be able to execute the code with anonymous identity.

Regards,
Sabrie Nedzhip
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 11-Nov-2014 00:00

Thank you, Sabrie.  That suggestion solved my problem.

This thread is closed