How to execute EventHub code under full permissions? - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

How to execute EventHub code under full permissions?

  • 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;

    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.

    Sabrie Nedzhip
    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
  • Thank you, Sabrie.  That suggestion solved my problem.