ASP.NET Membership Verification if User is in User Class Role

In my VS solution, I have two projects. One for the web interface, the other for DataAcess and BusinessLogic. I know that I can check if the current input user is an Employee in Web Interface project as follows:

Dim isEmployee = User.IsInRole("Employee")

The problem is that I have UserManagement to call the class in my DA and BL project, which I also want to test in the role of the user who is currently logged in. I can not use Dim isEmployee = User.IsInRole("Employee")because it does not have an aspx page.

What do I need to do to check the user role in my custom class?

Thank.

+3
source share
2

System.Web -. :

    Dim context As System.Web.HttpContext = System.Web.HttpContext.Current
    Dim isRole As Boolean = context.User.IsInRole("Admin")

#

System.Web.HttpContext context = System.Web.HttpContext.Current;
bool isRole = context.User.IsInRole("Admin");
+4

-, () , - , . , - - (.. - -), .

0

Source: https://habr.com/ru/post/1728813/


All Articles