+1-888-365-2779
Try Now
More in this section

Forums / Sitefinity SDK / SecurityDemandFailException when calling CreateProductTypePersistance

SecurityDemandFailException when calling CreateProductTypePersistance

3 posts, 0 answered
  1. tim
    tim avatar
    8 posts
    Registered:
    30 Nov 2015
    14 Jan
    Link to this post

    I am using the Create Product Type example from http://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: 

  2. Elena Ganeva
    Elena Ganeva avatar
    36 posts
    Registered:
    20 Jul 2016
    19 Jan
    Link to this post

    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
     
  3. tim
    tim avatar
    8 posts
    Registered:
    30 Nov 2015
    19 Jan in reply to Elena Ganeva
    Link to this post

    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.

3 posts, 0 answered