customize Roleprovider without using Membership or ASP.NET Identit

Asked

Viewed 149 times

1

Good morning. My doubt and the following I have the authentication part of my system made without using Membership or ASP.NET Identit. and wanted to make or use the method [Authorize] already picked up an example on google where I did the following

PermissoesFiltro PermissaoProvider erro web.config

  • 1

    It will be easier if you provide snippets of code, and exemplify your doubt, than just putting prints from your screen. That way, there are more chances that someone will understand your problem and can help you.

  • in case I wanted to know whether to use the Roleprovider class for authorization if to use Membership or ASP.NET Identit. Just using the simple authentication I’d already done. pq I want to define levels of access to certain user groups and already used the [Authorize] in the controller but then I can’t define a user for each local type admin and user. In my case every authenticated user accesses everything. and I want to limit this but do not know how...

  • in the excerpt "authorization to use Membership" is without using wrong!

  • The code is correct, but there is something strange in the configuration. I will try an answer.

  • if you want more information ... I place...

1 answer

0

Apparently the implementation code is ok, but there is something weird in the configuration. You are using parameters from MembershipProvider to set up a RoleProvider.

I would do so:

<configuration>
  ...
  <system.web>
    ...
    <roleManager enabled="true" defaultProvider="PermissaoProvider">
      <providers>
        <clear />
        <add name="PermissaoProvider" type="Site.Security.PermissaoProvider" connectionStringName="conexao" applicationName="/" />
      </providers>
    </roleManager>
    ...
  <system.web>
  ...
<configuration>
  • tried the way you put it but couldn’t get as to the "Membershipprovider parameters" that you put would be the authentication parameters?

  • Yes. EnablePasswordRetrieval and EnablePasswordReset are not parameters of RoleProvider.

  • No I implemented a simple authentication "own", and I’ve been using it because in my applications I only had one type of user the admin then decorated my controller with the tag [Authorize] and only authenticated users were using and now I will have user and admin profiles but I don’t know how to limit or user profile without changing the whole authentication scheme I had already created for Membership authentication

  • [Authorize] accepts a parameter called Roles. Stay like this: [Authorize(Roles = "Usuario")]. As for your problem, it is something relative to the configuration. I understand what you want, but there is a problem of understanding the concept. A RoleProvider manages the roles and permissions, and the Membership manage users. You’re putting the two things together.

  • So there is no way to use roles if you are not using the correct Membership Tool? I found that example I showed on google and I thought I could use one thing independent of the other... you know what I should look for to solve the problem of permissions?

  • You can write only the RoleProvider. It works with the implementation default of MembershipProvider. Just watch the settings. The configuration of one is different to the other.

  • ok I’ll keep trying thanks for the attention.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.