How do I design the retrieval and processing of all user roles?

旧街凉风 提交于 2019-12-11 18:09:15

问题


I am building an intranet with ASP.NET core 2.0 MVC. All users are part of an active directory. Additionaly I have a MSSQL database with the following tables:

Users (Id, FirstName, UserNameAd (unique), ...)
Roles (Id, RoleName)
UserRoles (User_Id, Role_Id)

In my web application I now want to retrieve the roles of a user and store them in the Authentication/Identity Classes of Microsoft in order to use [Authenticate(Roles="Admin")] stuff. I am not sure where I shall put this role-request and what is the best practice. It is possible that a user gets a new role during the day or that a role is removed during the day and I actually do not want the user to click something specific or need him to restart the browser in order to get the new roles applied - thats why I think that the roles need to be requested with each server-action (POST, GET) from the server.

Any idea or link to a good tutorial would be highly appreciated.

Also if you think my approach is not good practice and you have a better idea I would be happy to know.


回答1:


After a lot of discussions and researches in the internet i came to the conclusion to chose pure windows authentication.

It works out of the box and you can already use the active directory groups as roles with [Authorize(Roles = "ADGroupName")] which is really straightforward and nice.



来源:https://stackoverflow.com/questions/49922390/how-do-i-design-the-retrieval-and-processing-of-all-user-roles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!