tags:

views:

568

answers:

1

I am trying to set the Authorize for my controllers can do the following:

[Authorize(Roles = "Approver")]

How ever the names of the roles are held in the database, and therefore I would like to try and do the following:

[Authorize(Roles =Settings.Instance.RoleEmployee)]

but I get the following error:

An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type

Any way around this?

+1  A: 
eu-ge-ne
Both those links imply it's very difficult or impossible. it's relatively easy (5 total lines) to do this by creating your own authorization attribute (e.g. [AuthorizeApprover]) and using that instead. Not very scalable, though.
James S