Reputation: 4239
I marked my controller as below:
[Authorize(Roles = "Marketing")]
[Authorize(Users = "DOMAIN\\MyUsername")]
public class ContactsController : Controller
I am not in "Marketing" role, but I added my own username to Users.
When I navigate to Contacts/Index, or any other action, I am first prompted to give credentials, and then I see error 401 - Unauthorized.
In Detailed Error Information under Logon User is DOMAIN\MyUsername.
Why my user is not authorized?
My browser is Chrome and I'm using IIS Express as development server.
Upvotes: 1
Views: 1746
Reputation: 8168
In case two attributes are used you are saying that your user has to be a DOMAIN\MyUserName AND he has also a Marketing role. You have to use only one attribute.
[Authorize(Users = "DOMAIN\\MyUsername", Roles = "Marketing")]
public class ContactsController : Controller
Upvotes: 1