2011-03-10 80 views
0

什么是使表单身份验证功能最简单的方法?我需要设置IIS/Active Directory吗?如果是这样,你会如何编码?ASP.NET C# - 设置表单身份验证安全性

我一直在寻找这个教程,但它是一个有点长,硬,和混乱: 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> 

+0

的链接导致“我如何创建自定义Web服务” ...... Web服务有什么待办事项与会员和认证 – MUG4N 2011-03-10 21:01:51

回答

0

一旦你设置身份验证模式窗体,你需要处理FormsAuthentication.GetAuthCookie和SetAuthCookie。

你可能想看看教程,如:An overview of forms authentication (VB)

+0

感谢您的答复和链接! – 2011-03-11 16:41:04

+0

我以为cookies的使用过时了,表现不佳? – 2011-03-15 18:56:15