Alon M
Alon M

Reputation: 1683

Using roles in Asp.Net MemeberShip?

Well, the question is simple.

how can i use the roles in asp.net memebership,

i know i can do something like that :

<authorization>
<allow roles="Admin"/> //Allows users in Admin role

<deny users="*"/> // deny everyone else
</authorization>

</system.web>
</location>

but, where can i say user 'admin' is Role : Admin..?

Upvotes: 1

Views: 276

Answers (2)

Win
Win

Reputation: 62260

It is just a tip of the ice berg. You need ASP.Net Membership and Role Providers, and configure few settings. You can implement your own providers, but it is easier to use the default ones.

http://www.codeproject.com/KB/aspnet/SQL-Membership.aspx

http://odetocode.com/articles/427.aspx

<system.web>

    <membership>
        <providers>
            <remove name="AspNetSqlMembershipProvider"/>
            <add applicationName="YOURAPPNAME" name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ASPNETDBConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
        </providers>
    </membership>
    <roleManager enabled="true" cacheRolesInCookie="false">
        <providers>
            <remove name="AspNetSqlRoleProvider"/>
            <add applicationName="YOURAPPNAME" connectionStringName="ASPNETDBConnectionString" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
        </providers>
    </roleManager>

</system.web>

Upvotes: 1

Madhur Ahuja
Madhur Ahuja

Reputation: 22661

You need to have RoleProvider http://msdn.microsoft.com/en-us/library/8fw7xh74.aspx

If you are using Windows Authentication, the roles will be your AD groups.

If you are using Form Authentication, you can implement your own RoleProvider or use SQL Role Provider.

http://msdn.microsoft.com/en-us/library/system.web.security.sqlroleprovider.aspx

Upvotes: 1

Related Questions