Y
Y
Yuri2017-10-12 09:36:44
ASP.NET
Yuri, 2017-10-12 09:36:44

How to attach roles to asp.net?

I have an asp.net application running on an intranet. Forms authentication system is used

<authentication mode="Forms">
      <forms loginUrl="~/Account/Login.aspx"  />
</authentication>

It is required to switch to authentication mode="Windows"
But my application uses roles to differentiate access to certain pages. The question is how to connect "external" logins taken from AD with self-made roles (there is own storage in the form of a database for roles and other things)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri, 2017-10-13
@bRUtality

In general, the casket just opened. The built-in membership still gets into the user-role table, and the account is available by Profile.UserName and Role.UserInRole().
Here is one of the implementations that I have tested. We create all the roles in regular ways + the role that we assign when the user's AD first enters the site. I called her guest. On the master page, I added code that assigns the guest role to the logged-in user. This creates entries in the "users" and "user-role" tables. That. we get an external user to our database and its connection with the role. It remains only to assign a role with the desired access level. All.

V
V Sh., 2017-10-12
@JuniorNoobie

The answer is simple: write your own role provider that will take Windows logins, check them against the database table and issue assigned roles.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question