Link to home
Start Free TrialLog in
Avatar of RyanAndres
RyanAndresFlag for United States of America

asked on

ASP.NET Menu Control (Security Trimming)

Here I am using the ASP.NET Menu control with Security Trimming enabled to show/hide nodes to users to certain roles.

There are 2 roles: administrator and projectdirectors.

The problem is that for the "Print Checks" node, it is appearing for users in the projectdirectors role when clearly it is assigned the administrator role.

It is weird because it works for the Reports node and will hide the "By Date" node to projectdirectors.

I don't know if this is relevant but the /Checks/ and /Reports/ urls are using ASP.NET routing.

I am using C# with .NET 3.5 SP1.

Any ideas?
Web.sitemap:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
  <siteMapNode url="~/Default.aspx" title="Home">
    <siteMapNode title="Reports" roles="*">
      <siteMapNode url="~/Reports/View/ByDate" title="By Date" roles="administrator" />
      <siteMapNode url="~/Reports/View/ByStudy" title="By Study" roles="projectdirectors" />
    </siteMapNode>
    <siteMapNode title="Checks" roles="*">
      <siteMapNode url="~/Checks/View" title="View Checks" roles="*" />
      <siteMapNode url="~/Checks/Print" title="Print Checks" roles="administrator" />
      <siteMapNode url="~/InvalidChecks.aspx" title="Invalid Checks" roles="administrator" />
    </siteMapNode>
    <siteMapNode title="User" roles="*">
      <siteMapNode url="~/User/Profile.aspx" title="Profile" />
      <siteMapNode url="~/User/ChangePassword.aspx" title="Change Password" />
    </siteMapNode>
    <siteMapNode title="Admin" roles="administrator">
      <siteMapNode url="~/Admin/AddUser.aspx" title="Add User" roles="administrator" />
      <siteMapNode url="~/Admin/ViewUsers.aspx" title="View Users" roles="administrator" />
    </siteMapNode>
  </siteMapNode>
</siteMap>

Open in new window

menu.jpg
Avatar of RyanAndres
RyanAndres
Flag of United States of America image

ASKER

This is how the Menu control is placed in my .master page.
        <asp:LoginView ID="NavigationLoginView" runat="server">
            <LoggedInTemplate>
                <div id="nav" style="background-color: #DDDDDD; width: 100%; float: left;">
                    <div style="float: left; display: block;">
                        <asp:Menu ID="MenuMain" runat="server" BackColor="#DDDDDD" DataSourceID="SiteMapDataSource1"
                            DynamicHorizontalOffset="2" StaticSubMenuIndent="10px" DynamicEnableDefaultPopOutImage="False"
                            StaticDisplayLevels="2" StaticEnableDefaultPopOutImage="False" Orientation="Horizontal">
                            <StaticSelectedStyle BackColor="#DDDDDD" />
                            <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                            <DynamicHoverStyle BackColor="#DDDDDD" ForeColor="White" />
                            <DynamicMenuStyle BackColor="#DDDDDD" />
                            <DynamicSelectedStyle BackColor="#DDDDDD" />
                            <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                            <StaticHoverStyle BackColor="#DDDDDD" ForeColor="White" />
                        </asp:Menu>
                    </div>
                    <div style="float: right; display: block; background-color: #DDDDDD; padding-top: 2px; padding-bottom: 2px;
                        padding-left: 5px;">
                        Logged in as:
                        <asp:LoginName ID="LoginName" runat="server" />
                        <asp:LoginStatus ID="LoginStatus" runat="server" OnLoggedOut="LoginStatus1_LoggedOut"
                            LogoutAction="RedirectToLoginPage" />
                        <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
                    </div>
                </div>
            </LoggedInTemplate>
        </asp:LoginView>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of RyanAndres
RyanAndres
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial