ASP.NET C # - Настройка безопасности проверки подлинности с помощью форм - PullRequest
0 голосов
/ 10 марта 2011

Какой самый простой способ сделать проверку подлинности с помощью форм? Нужно ли мне настроить IIS / Active Directory? Если да, то как бы вы это закодировали?

Я смотрел этот урок, но он немного длинный, сложный и запутанный: http://msdn.microsoft.com/en-us/library/ms464040.aspx

Вот моя информация о web.config:

<configuration>
<connectionStrings>
    <add name="OleConnectionStringSource" connectionString="Data Source=dev-sql01; Integrated Security=SSPI; Initial Catalog=PriceFinder;Integrated Security=false"
     providerName="System.Data.SqlClient" />
    <add name="OleConnectionStringTarget" connectionString="Data Source=dev-sql01; Integrated Security=SSPI; Initial Catalog=PriceFinder;Integrated Security=false"
     providerName="System.Data.OleDb;" />
    <add name="PriceFinderConnectionString" connectionString="Data Source=dev-sql01; Integrated Security=SSPI; Initial Catalog=PriceFinder;Integrated Security=True"
     providerName="System.Data.SqlClient" />
    <add name="PriceFinderConnectionString2" connectionString="Data Source=dev-sql01;Integrated Security=SSPI; Initial Catalog=PriceFinder;Integrated Security=True"
     providerName="System.Data.SqlClient" />

    <!--run aspnet_regsql.exe on alg-sql01 when I get write access to alg-sql01, add Data Source=alg-sql01;User ID=PriceFinderUser;Password=speg#st!9e8_#as; 
        delete Integrated Security=SSPI; line -->

</connectionStrings>

<system.web>
<compilation debug="true" targetFramework="4.0" />

<authentication mode="Forms">
  <forms loginUrl="~/default.aspx" timeout="2880" />
</authentication>

  <membership>
  <providers>
    <clear/>
      <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="OleConnectionStringSource"
         enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
         maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
         applicationName="/" />  
  </providers>
</membership> 

<profile>

Спасибо! :)

<roleManager enabled="false">
  <providers>
    <clear/>
      <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
    <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" /> 
  </providers>
</roleManager>

1 Ответ

0 голосов
/ 11 марта 2011

После того, как вы установили режим аутентификации на Forms, вам нужно обработать FormsAuthentication.GetAuthCookie и SetAuthCookie.

Возможно, вы захотите проверить учебник, например: Обзор проверки подлинности форм (VB)

...