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

Forums / Developing with Sitefinity / CmsSiteMapProvider

CmsSiteMapProvider

6 posts, 0 answered
  1. D
    D avatar
    3 posts
    Registered:
    06 Jun 2007
    20 Jun 2007
    Link to this post
    I would like to ask if CmsSiteMapProvider supports any type of "security trimming" - filtering site-map nodes based on security roles. As far as I can see its configuration schema doesn't support the "securityTrimmingEnabled" attribute. Is this so and if yes is there any way to achieve this otherwise standard functionality?
  2. Bob
    Bob avatar
    330 posts
    Registered:
    30 Dec 2016
    20 Jun 2007
    Link to this post
    Hi D,

    The provider it self does not support trimming but you can check SiteMapNode.IsAccessibleToUser(context) while binding. We have included ready to use sitemap controls (SiteMenu, SitePanelbar, SiteTabstrip and SiteTreeview) in SP1 that support this functionality out of the box.

    Kind regards,
    Bob
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. D
    D avatar
    3 posts
    Registered:
    06 Jun 2007
    22 Jun 2007
    Link to this post
    Hi, Bob

    Thanks for the information, but actually I found the following line in the web.config:
    <add name="CmsSiteMapProvider" description="Displays Cms Pages" type="Telerik.Cms.Web.CmsSiteMapProvider" securityTrimmingEnabled="false"/>
    which I think is exactly what I need. And if I need a provider withoud security trimming I can always add one more.
  4. Slavo
    Slavo avatar
    295 posts
    Registered:
    24 Sep 2012
    22 Jun 2007
    Link to this post
    Hi D,

    Thank you for bringing up this issue. Until now, the CmsSitemapProvider did not support the securityTrimmingEnabled property. Filtering nodes in sitemap-bound controls had to be done using the SiteMapNode.IsAccessibleToUser(context) method, as Bob mentioned. I guess that if you use the property you mention in the current release, it will hide all the pages in your site. This, however, has been fixed for the service pack and you will be able to filter nodes based solely on the securityTrimmingEnabled property.

    All the best,
    Slavo
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. derek
    derek avatar
    37 posts
    Registered:
    15 Jun 2007
    15 Apr 2010
    Link to this post
    The security trimming was causing performance and functionality issues for us with the stock Sitefinity 3.7 SP1 SiteMenu.  We ended up resolving it with a custom site map provider.  Our requirements that prompted the need for a custom site map provider were:
     
    1) SiteMenu must display menu items for "Deny Anonymous" = true pages for non-authenticated users.
    2) Remove the SiteMenu page load time performance hit that we determined to be a result of the authorization tests performed on each menu item when added to the site map by the stock Sitefinity site map provider.

    Our resolution was to override Telerik.Cms.Web.CmsSiteMapProvider.IsAccessibleToUser() in a CustomSiteMap class in /App_Code/CustomSiteMap.cs:

    using System;
    using System.Collections;
    using System.Collections.Specialized;
    using System.Web;
    using Telerik.Cms;
      
    /// <summary> 
    /// Summary description for CustomSiteMap 
    /// </summary> 
    ///  
    namespace edu.yale.som
    {
        public class CustomSiteMap : Telerik.Cms.Web.CmsSiteMapProvider
        {
            public override bool IsAccessibleToUser(HttpContext context, SiteMapNode node)
            {
                try
                {
                    return true;
                }
                catch (Exception e)
                {
                    throw new Exception("Error in CustomSiteMap.IsAccessibleToUser(): " + e.Message);
                }
            }
        }
    }


    Then set the default site map provider to the custom site map provider:

    <siteMap defaultProvider="CustomSiteMapProvider" enabled="true">
        <providers>
            <clear/>
            <add name="CmsSiteMapProvider" description="Displays Cms Pages" type="Telerik.Cms.Web.CmsSiteMapProvider"/>
            <add name="CustomSiteMapProvider" description="CustomSiteMapProvider" type="edu.yale.som.CustomSiteMap, App_Code" />
        </providers>
    </siteMap>
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    16 Apr 2010
    Link to this post
    Hi derek,

    Thank toy for joining the conversation.

    This is a nice resolution to the issue. You can also consider either exporting the your site map to an XML - for example create a service which will update the xml file every day at some time. Then you can bind the menu to xml file - this will contain already prepared data source. You can also consider using load on demand - if you have very large site map with a lot of levels the load on demand will allow you to load only one branch at a time. You can find an example here: Enable loading of CMS pages through an AJAX Web Service.

    Greetings,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
6 posts, 0 answered