I have an intranet MVC 5 C # web application that uses over 30 Active Directory roles and permissions often change due to business culture.
To make things easy for myself, I thought I would try something like this to determine who is allowed access to the controller action or child action.
private static string _approvedRoles = Helpers.QueryableExtensions.GetApprovedRoles("FourCourseAudit");
Unfortunately, I get this compile-time error: An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type .
Here I am trying to use other approaches with the _approvedRoles variable like public const string and public string . I put the GetApprovedRoles function in the model, in the repository (where it is now) and in the body of the controller.
I know that roles are good because if I use this: [Authorize(Roles="DOMAIN\Role1,DOMAIN\Role2")] , it works. And this is not a feasible option for me, because the roles are changing, and this is a very large MVC site. Is there any way that I can let Roles be variable?
c # asp.net-mvc
user4864716
source share