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

Forums / Security / Custom module inherits from WebModule but user can't view it

Custom module inherits from WebModule but user can't view it

8 posts, 0 answered
  1. TedH
    TedH avatar
    4 posts
    Registered:
    11 Apr 2008
    17 Aug 2009
    Link to this post
    I've created some custom modules which I've set up to inherit from WebModule.

    According to this blog post "If module inherits from WebModule class, all users will be able to perform all operations"

    However a new user I've created, who is assigned to a new role, gets the following error when trying to view any of my custom modules in the Sitefinity admin pages.

    Thanks in advance.



    Security Exception

    Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

    Exception Details: System.Security.SecurityException: Permission denied.

    Source Error:

    Line 134:                // gets the reference of control panel and assigns it the provider name
    Line 135:                ControlPanel ctrlPnl = ((ControlPanel)base.ControlPanel);
    Line 136:                ctrlPnl.ProviderName = this.providerName;
    Line 137:
    Line 138:                // initializes control container and template

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Aug 2009
    Link to this post
    Hello Ted Hindes,

    The error seems to be related to security trust level, not to any rights in Sitefinity CMS. Can you try to add the following sample module and see whether there will be any errors.

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using Telerik; 
    using Telerik.Web; 
     
    /// <summary> 
    /// Summary description for TestModule 
    /// </summary> 
    public class TestModule : WebModule 
        public TestModule() 
        { 
     
        } 
     
        public override string Name 
        { 
            get { return "TestModule"; } 
        } 
     
        public override string Title 
        { 
            get { return "TestModule"; } 
        } 
     
        public override string Description 
        { 
            get { return "some description"; } 
        } 
     
        public override IList<Telerik.Web.IToolboxItem> Controls 
        { 
            get 
            { 
                return new List<IToolboxItem>(new ToolboxItem[]  
                                {  
                                    new TestToolboxItem(), 
                                }); 
            } 
        } 
     

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using Telerik.Web; 
     
    /// <summary> 
    /// Summary description for TestToolboxItem 
    /// </summary> 
    public class TestToolboxItem : ToolboxItem 
        public TestToolboxItem() 
        { 
     
        } 

    web.config

    <add type="TestModule, App_Code"/> 

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. TedH
    TedH avatar
    4 posts
    Registered:
    11 Apr 2008
    17 Aug 2009
    Link to this post
    That code works just fine.

    My new user can also see the built-in modules, just not be custom ones.

    Our custom modules are in a separate project in our solution. I'm not sure if that makes a difference.



  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 Aug 2009
    Link to this post
    Hello TedH,

    The separate project should not be a problem. Do you use any network parts. Can you provide us with more information or any stack trace? The error does not seem to be thrown by our code, because I could not find source error lines as they are posted in the thread in our source.
    If you add the sample module I sent you as a separate project do you get the Security error?

    I look forward to hearing from you.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. TedH
    TedH avatar
    4 posts
    Registered:
    11 Apr 2008
    18 Aug 2009
    Link to this post
    Your code does work if I put it in a separate project.

    Stack trace follows.  I'll also start a ticket and provide more source code.

    Thanks, Ivan.

    Stack Trace:

    [SecurityException: Permission denied.]
       Telerik.Security.Permissions.ApplicationPermission.ThrowSecurityException() +102
       Telerik.Security.Permissions.ApplicationPermission.Demand() +23
       Telerik.Cms.Engine.WebControls.Admin.ControlPanel.CreateChildControls() +363
       System.Web.UI.Control.EnsureChildControls() +87
       System.Web.UI.WebControls.CompositeControl.RecreateChildControls() +24
       Telerik.Cms.Engine.WebControls.Admin.ControlPanel.set_Mode(Modes value) +891
       Telerik.Cms.Engine.WebControls.Admin.ControlPanel.set_ProviderName(String value) +54
       {OurCompanyName}.Sitefinity.CustomModules.AboutUs.WebControls.Admin.CommandPanel.CreateChildControls() in C:\Projects\{ClientName}\{ProjectName}\{OurCompanyName}.Sitefinity.CustomModules\AboutUs\WebControls\Admin\CommandPanel.cs:136
       System.Web.UI.Control.EnsureChildControls() +87
       System.Web.UI.Control.PreRenderRecursiveInternal() +44
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785
       System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +242
       System.Web.UI.Page.ProcessRequest() +80
       System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
       System.Web.UI.Page.ProcessRequest(HttpContext context) +49
       ASP.sitefinity_admin_modules_aspx.ProcessRequest(HttpContext context) in c:\Documents and Settings\{DEVELOPER.NAME}\Local Settings\Temp\Temporary ASP.NET Files\root\fc30c734\51d9efbd\App_Web_--xtom4k.10.cs:0
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
    

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 Aug 2009
    Link to this post
    Hello TedH,

    The error comes somewhere from your implementation, see the line in the stack trace

    "{OurCompanyName}.Sitefinity.CustomModules.AboutUs.WebControls.Admin.CommandPanel.CreateChildControls() in C:\Projects\{ClientName}\{ProjectName}\{OurCompanyName}.Sitefinity.CustomModules\AboutUs\WebControls\Admin\CommandPanel.cs"


    There is some control in your command panel that throws the error. It seems that The your default policy of the security system ignores assembly-provided evidence.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. Tim
    Tim avatar
    2 posts
    Registered:
    10 Apr 2008
    19 Aug 2009
    Link to this post
    Hello,

    Here's what I've determined today.  If I updated the web.config with permission="Unrestricted" for the new role we created, Editors, the security exception is not thrown.  

      <security defaultProvider="DefaultSecurityProvider" cmsProvidersName="Sitefinity">
       <roles>
        <clear/>
        <add name="Administrators" permission="Unrestricted"/>
        <add name="Editors" permission="Unrestricted"/>
       </roles>
       <providers>
        <clear/>
        <add name="DefaultSecurityProvider" connectionStringName="DefaultConnection" type="Telerik.Security.Data.DefaultSecurityProvider, Telerik.Security.Data" membershipProvider="Sitefinity" roleProvider="Sitefinity"/>
       </providers>
      </security>

    If the permission="Unrestricted" is removed, the "System.Security.SecurityException: Permission denied." error occurrs again.  It seems that Telerik.Security.Permissions.ApplicationPermission.CheckDemand is returning false for some reason that I've not been able to determine.

    The TestModule code provided earlier works in as much as it shows in the TabStrip and when you click on it you get no errors.  However, it does not have any Command Panel displayed. 

    Our custom module is based on the Generic Content module.  Our CommandPanel.CreateChildControls is where the error is being thrown.  The TestModule code does not have this code. 

    So there must be something that our custom modules are missing causing the error.  If it will help, we can send you the project file for your inspection.

    Thank you for all your help!
    Tim










  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    19 Aug 2009
    Link to this post
    Hi Tim,

    As I see you have opened a support ticket and attached the module. We will take a look at it and get back to you.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
8 posts, 0 answered