PDA

View Full Version : کلاس RoleManager در ASP.NET



minoooooo
جمعه 24 اسفند 1386, 14:49 عصر
man yek web site(asp.net (http://asp.net/) ba estefade az c#) daram ke chand no karbar login
mikonand.
baraye in ke har yek az karbaran faghat be safhey khodeshan vared
shavand.
az class "RleManager" estefade kardam.va (http://kardam.va/) karbaran ra be Role ha
ezafe
kardam.
agar shoma mesali dar in mored darid lotfan befrestid.
zamne in ke man nemidonam rahe behtar va asontari hast ya na.

achilles
یک شنبه 04 فروردین 1387, 18:25 عصر
برای کنترل دسترسی کاربر ها به منابع از عنصر location توی web.config استفاده کنید. مثال های خیلی خوبی هم توی msdn پیدا میشه.
توی پست بعدی یه نمونه از Web.config رو برات میذارم...

achilles
یک شنبه 04 فروردین 1387, 18:27 عصر
<?xml version="1.0"?>
<configuration>
<appSettings configSource="App.config"/>
<connectionStrings>
<add name="ConnStr" connectionString="Server=****;UId=sa;Pwd=****;Database=****;"/>
<add name="Membership" connectionString="Server=****;UId=sa;Pwd=*****;Database=Membership;"/>
</connectionStrings>
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/login/" defaultUrl="~\" protection="All" timeout="60"/>
</authentication>
<authorization>
<deny users="?"/>
<allow roles="admin"/>
</authorization>
<customErrors mode="Off" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm"/>
<error statusCode="404" redirect="FileNotFound.htm"/>
</customErrors>
<membership defaultProvider="MHMP">
<providers>
<clear/>
<add name="MHMP" type="System.Web.Security.SqlMembershipProvider"
connectionStringName="Membership"
enablePasswordRetrieval="false"
enablePasswordReset="false"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
passwordFormat="Clear"
applicationName="xxx"
maxInvalidPasswordAttempts="3"
minRequiredPasswordLength="3"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""/>
</providers>
</membership>
<roleManager enabled="true" cookieTimeout="60" defaultProvider="MHRP">
<providers>
<clear/>
<add connectionStringName="Membership" applicationName="xxx"
name="MHRP"
type="System.Web.Security.SqlRoleProvider"/>
</providers>
</roleManager>
</system.web>
<location path="login">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
</configuration>