【问题标题】:ASP.NET C# - Setting up Forms Authentication SecurityASP.NET C# - 设置表单身份验证安全性
【发布时间】:2011-07-13 01:18:57
【问题描述】:

使表单身份验证起作用的最简单方法是什么?我需要设置 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>

【问题讨论】:

  • 链接指向“我如何创建自定义网络服务”...网络服务与成员资格和身份验证无关

标签: asp.net security active-directory forms-authentication


【解决方案1】:

将身份验证模式设置为 Forms 后,您需要处理 FormsAuthentication.GetAuthCookie 和 SetAuthCookie。

您可能想查看以下教程:An overview of forms authentication (VB)

【讨论】:

  • 感谢您的回复和链接!
  • 我认为 cookie 的使用已经过时且形式不佳?
猜你喜欢
  • 2012-08-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-24
  • 2012-06-20
  • 1970-01-01
  • 1970-01-01
  • 2014-04-30
  • 2015-09-15
相关资源
最近更新 更多