This is a migrated thread and some comments may be shown as answers.

[Solved] Security Trimming using Site Map in Hybrid Web Forms / MVC Application

1 Answer 114 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Brett
Top achievements
Rank 1
Brett asked on 21 Nov 2011, 04:36 PM
Hello Telerik Team,

We're currently migrating to MVC technology.  Our application has legacy pages using web forms and new pages using MVC.  I was able to use the MVC menu with our legacy site maps; however, security  trimming is not applied to nodes pointing to web form pages.  For example, the Telerik MVC menu will not trim the following node from the site map, even though the user does not have these roles:

      <siteMapNode
        url="~/Sources/ServiceManager.aspx"
        title="Services"
        description="Services"
        roles="StudyManager,System"/>

Note that the link is to a web form.  Is there any way to apply security trimming to such nodes?  In this case, there is no controller / action to decorate with the [Authorize] attribute.

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Brett
Top achievements
Rank 1
answered on 10 Dec 2011, 05:47 PM
I solved this problem by inspecting the roles during data binding:

@(Html.Telerik().Menu()
  .Name("Menu1")
  .BindTo("smds", (item, node) =>
  {
    // images
    item.ImageUrl = node.Attributes["imageUrl"] as string;
    // security trimming
    string roles = node.Attributes["roles"] as string;
    if (!@User.IsInRoles(roles))
      item.Visible = false;
    })
)
Tags
Menu
Asked by
Brett
Top achievements
Rank 1
Answers by
Brett
Top achievements
Rank 1
Share this question
or