<% Html.Telerik().Menu()
.Name("tmNav")
.Items(menu =>
{
menu.Add()
.Text("Home")
.Action("Index", "GreenHome", new { area = "" });
menu.Add()
.Text("Perform QA")
.Action("Index", "PerformQa", new { area = "PerformQa" });
menu.Add()
.Text("My Pending Actions")
.Action("MyPendingActions", "PerformQa", new { area = "PerformQa" });
menu.Add()
.Text("Form Manager")
.Action("Index", "Form", new { area = "Admin" });
})
.HtmlAttributes(new { style = "zoom:1;float:left;" })
.Render();
%>
Then my controllers and/or actions have AD Security on them for example
[ADGroupAuthorize(Roles = "QA TECH,QA MANAGER,ADMIN")]
However, What I want the menu to do is just not show the links that the people aren't able to access instead right now if they don't have access to any one of them they get a Not Authorized attribute.
How can I make it just show what they have access to?
10 Answers, 1 is accepted
Thank you for contacting us. I suppose that the "ADGroupAuthorize" attribute is custom authorization attribute,
which overrides the OnAuthorization method. If this is the case, note that you will need to return
HttpUnauthorizedResult object. Thus the menu will know that the url is not allowed and the menu item will not shown. If you return a regular ActionResult, then the menuwill show the items.Kind regards,
Georgi Krustev
the Telerik team
I am not sure where could be the problem. I will need a simple test project, which replicates the issue. Thus I will be able to observe the issue locally and advice you further.
Georgi Krustev
the Telerik team
Updated the code showing it's not working when going to another area.
Thank you for the test projects. Unfortunately I was not able to see where you are using the Menu for ASP.NET MVC. Also I noticed that the action methods of the Home controller are not decorated with any authorization attributes. Let me know if I am missing something.
Georgi Krustev
the Telerik team
Thank you for the test project. It seams that the issue is related with the AuthorizationContext, which we generate when call the attribute's onAuthorization method. After further investigation, I believe that we was able to address the problem. I will suggest you try the next internal build of Telerik Extensions for ASP.NET MVC. I also updated your Telerik points for the bug report.
Georgi Krustev
the Telerik team