locked
security trimming with no roles RRS feed

  • Question

  • User179062990 posted

    hi all,

    I have a master page and a mySite.sitemap. I don't know what is wrong with my sql database setup, nevertheless the securityTrimmingEnabled in my web.config file does not do anything. Because I'm in a rush I would like to just hide/show menu items progarmatically based on my 2 possible roles my users can have. There is just one menu, two levels deep with just a few items each. For one role I need to show only two sub-items in the first item, all of them for the rest.

    It is somewhat strange that Roles.Provider.GetRolesForUser("user1") is giving me the right value ...

    Any idea how I hide menu items in my master page?

            <form id="form1" runat="server">
            <asp:SiteMapDataSource SiteMapProvider="WebSitemapProvider" ID="SiteMapDataSource1" runat="server" />
            <div id="header"> 
            </div>
            <div id="breadcrumbs">  
                <asp:SiteMapPath SiteMapProvider="reloWebSitemapProvider" ID="SiteMapPath1" runat="server">
                </asp:SiteMapPath>
            </div>
            <div id="menu">  
                <asp:Menu ID="Menu1" DataSourceID="SiteMapDataSource1" runat="server" DynamicMenuItemStyle-CssClass="btn"
                    BackColor="#B5C7DE" DynamicHorizontalOffset="2" Font-Bold="True" 
                    Font-Names="Arial" Font-Size="Small" ForeColor="Black" 
                    StaticSubMenuIndent="30px" StaticDisplayLevels="2">
                    <StaticSelectedStyle BackColor="#507CD1" />
                    <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="20px" />
                    <DynamicHoverStyle BackColor="#284E98" ForeColor="White" />
                    <DynamicMenuStyle BackColor="#B5C7DE" />
                    <DynamicSelectedStyle BackColor="#507CD1" />
                    <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="20px" />
                    <StaticHoverStyle BackColor="#284E98" ForeColor="White" />
                </asp:Menu>
            </div>
            <div id="content" 
                style="; width: auto; height: auto; top: auto; right: auto; bottom: auto; left: auto; z-index: auto;">
                <asp:ContentPlaceHolder id="Main_ContentHolder" runat="server">
                
                </asp:ContentPlaceHolder>
                
    
            </div>
            
            <div id="footer">  
            </div>
    
            </form>


     

     

    Friday, July 18, 2014 7:19 PM

Answers

  • User465171450 posted

    Do you have CacheRolesInCookie set on the roleprovider? 

    When it's set to true, the RolePrincipal manages the roles and looks at the cached role list instead. 

    If it's set to false, then it looks it up using the default role provider.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 18, 2014 9:31 PM