SecurityDemandFailException when calling CreateProductTypePe

Posted by Community Admin on 05-Aug-2018 12:39

SecurityDemandFailException when calling CreateProductTypePersistance

All Replies

Posted by Community Admin on 14-Jan-2016 00:00


I am using the Create Product Type example from docs.sitefinity.com/for-developers-create-product-types but it fails at the line

ecommerceManager.CreateProductTypePersistance(productType, metadataManager, out productClrType);

with the following exception. Is there a security policy suppress as a work around?

Telerik.Sitefinity.Security.SecurityDemandFailException was unhandled by user code
  HResult=-2146232832
  Message=Telerik.Sitefinity.Security.Data.StaticRoot, Telerik.Sitefinity was not granted ChangeConfigurations in Backend for principals with IDs 00000000-0000-0000-0000-000000000000
  Source=Telerik.Sitefinity
  StackTrace:
       at Telerik.Sitefinity.Security.SecurityExtensions.Demand(ISecuredObject item, String permissionSet, Guid[] principals, Int32 actions, IOwnership actualOwnerObject)
       at Telerik.Sitefinity.Security.SecuredObjectExtensions.Demand(ISecuredObject securedObject, String permissionSetName, String[] actions)
       at Telerik.Sitefinity.Configuration.ConfigProvider.DemandManagePermission()
       at Telerik.Sitefinity.Configuration.Data.XmlConfigProvider.SaveSection(ConfigSection section)
       at Telerik.Sitefinity.Configuration.ConfigManager.SaveSection(ConfigSection section)
       at Telerik.Sitefinity.Modules.Ecommerce.Catalog.CatalogDefinitionManager.AddProductTypeDefinition(ProductType productType, String providerName)
       at Certas.Sitefinity.Application.SitefinityCms.Repositories.SitefinityProductTypeRepository.CreateProductType(String titleSingular, String titlePlural, ProductDeliveryType deliveryType) in C:\Workspaces\GitHub\Certas\Certas.Sitefinity.Application.SitefinityCms\Repositories\SitefinityProductTypeRepository.cs:line 38
       at Certas.Sitefinity.Application.SitefinityCms.Repositories.SitefinityProductRepository.MakeProduct(FullProductModel makeProduct) in C:\Workspaces\GitHub\Certas\Certas.Sitefinity.Application.SitefinityCms\Repositories\SitefinityProductRepository.cs:line 100
       at Certas.Sitefinity.Application.SitefinityCms.Repositories.SitefinityProductRepository.CreateProduct(FullProductModel fullProduct) in C:\Workspaces\GitHub\Certas\Certas.Sitefinity.Application.SitefinityCms\Repositories\SitefinityProductRepository.cs:line 22
       at SitefinityWebApp.Mvc.Controllers.ProductController.UpdateProduct(FullProductModel data) in C:\Workspaces\GitHub\Certas\CertasWeb\Mvc\Controllers\ProductController.cs:line 58
       at lambda_method(Closure , ControllerBase , Object[] )
       at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
  InnerException: 

Posted by Community Admin on 19-Jan-2016 00:00

Hello Tim, 

Thank you for sharing your stack trace. The issue that you mentioned could be caused because the current principal with which you are trying to create the product types does not have proper rights for this action. What you can do is either log in with user that has these permissions and try to execute the code again, or elevate the security context and skip the security checks of the provider with the following:

using(new ElevatedModeRegion(ecommerceManager))
     //Create the product type here


Regards,
Elena Ganeva
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 19-Jan-2016 00:00

Hello Elena,

Thank you for the reply. I have traced it down to the server having not completed the start-up before my tests ran. 

Thanks.

This thread is closed