ASP.NET Tutorial/Configuration/authentication — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 11:57, 26 мая 2010

Allowing a single user through the web.config file

<configuration> 
    <system.web>
       <authentication mode="Windows" />
          <allow users="DomainName\Bill" />
          <deny users="*" />
       </authorization>
    </system.web>
</configuration>


Denying all users through the web.config file

<configuration> 
    <system.web>
       <authentication mode="Windows" />
       <authorization>
          <deny users="*" />
       </authorization>
    </system.web>
</configuration>


Modifying the web.config file to add username/password values

<system.web>
   <authentication mode="Forms">
      <forms name="Wrox" loginUrl="Login.aspx" path="/">
         <credentials passwordFormat="Clear">
            <user name="userName" password="Bubbles" />
         </credentials>
      </forms>
   </authentication>
   
   <authorization>
      <deny users="?" />
   </authorization>
</system.web>


Specify all users with the use of the asterisk (*)

<configuration> 
    <system.web>
       <authentication mode="Windows" />
            <allow roles="*" />
       </authorization>
    </system.web>
</configuration>


The <authentication> Node

<configuration> 
    <system.web>
        <authentication mode="Windows|Forms|Passport|None">
            
        </authentication> 
    </system.web>
</configuration>


To allow more than one user

<configuration> 
    <system.web>
       <authentication mode="Windows" />
            <allow users="MyDomain\User1" /> 
            <allow users="MyDomain\User2" />
       </authorization>
    </system.web>
</configuration> 

or you can use the following:
<configuration> 
    <system.web>
       <authentication mode="Windows" />
            <allow users="MyDomain\User1, MyDomain\User2" />
       </authorization>
    </system.web>
</configuration>


web.config file for forms-based authentication

<system.web>
   <authentication mode="Forms">
      <forms name="formName" loginUrl="Login.aspx" path="/" />
   </authentication>
    
   <authorization>
      <deny users="?" />
   </authorization>
</system.web>