More in this section

Forums / Developing with Sitefinity / Getting permissions for modules

Getting permissions for modules

2 posts, 0 answered
  1. Shane
    Shane avatar
    28 posts
    27 Jul 2008
    23 Mar 2009
    Link to this post

    Hi team,

    I have a question I am hoping you can help me with.

    Is there a way I can loop thru all modules in a sitefinity solution and check what permissions they have. I want to list all modules with CrudRights.View.

    Is there a consistant why to provide this for both generic content module based approach, and other modules that implement ISecuredModule?

    We have some modules that derive from GenericContentModule and we now have another module that isn't. Currently there isn't any permissions set for second approach, we are looking at implementing permissions so I guess this is a good time to also ask what is the best approach there?

    This site is currently running 3.5 framework.


  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    24 Mar 2009
    Link to this post
    Hi Shane,

    Thank you for using our services.

    Please check out the code below that returns all permissions that have been set for a user.

            // get list of all modules. then looping 
            List<IWebModule> webModules = new List<IWebModule>(); 
            foreach (IWebModule module in ModuleManager.GetWebModulesValues()) 
                bool showPermissions = true
                if (module is IModule) 
                    // get permissions for each module 
                    showPermissions = Util.CheckPermissions(module, CrudRights.View); 
                    if (showPermissions) 
                        // write username, module name, permissions. 
                        Response.Write(UserManager.GetCurrentUserName() + "<br />"); 
                        Response.Write(module.Name.ToString() + "<br />"); 
                        Response.Write("View right :"  + Util.CheckPermissions(module, CrudRights.View) + "<br />"); 
                        Response.Write("Create right :" + Util.CheckPermissions(module, CrudRights.Create) + "<br />"); 

    As for the second question, please take a look at the following posts Products module: Implementing permissions. Generally,permissions implementation for not GC based modules is the same.

    I hope this helps.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
2 posts, 0 answered