随着公司发展,越来越多的企业在使用SharePoint时,不仅仅满足于使用Windows AD的认证方式,在同时也配置了基于表单的Form-based认证使用。那我们就来看下在SharePoint环境中如何一步步的完成对Form-based Authentication的配置。
下面以SharePoint2010为例,呈现FBA的配置步骤:
在配置FBA认证时,一般分为下面三个步骤:
我们来具体看下每一步都如何设置:
Note:此处填写的值和config文件填写的值需要一致。如果此处没有按图中内容填写,请在设置配置文件时候根据此处填写的内容更新配置文件对应的值。
命令:cd c:\Windows\Microsoft.NET\Framework64\v2.0.50727
Note:此处填写的Server和Database Name要记住,稍后填写配置文件时候要填一样的信息。
此处需要修改三处配置文件:Central Administration web config文件、Web Application Web Config文件和Security Token Service webconfig文件。
<connectionStrings>
<clear />
<!-- FBA ClaimsAuth-->
<addname="AspNetSqlFBADBConnStr" connectionString="data source=[Server Name];Integrated Security=SSPI;Initial Catalog=[FBA Database Name]"providerName="System.Data.SqlClient" />
<!-- FBA ClaimsAuth-->
</connectionStrings>
<roleManager>
<providers>
</providers>
</roleManager>
<membership>
<providers>
</providers>
</membership>
用下面字段覆盖替换:
<roleManager enabled="true"cacheRolesInCookie="false" cookieName=".ASPXROLES"cookieTimeout="30" cookiePath="/"cookieRequireSSL="false" cookieSlidingExpiration="true"cookieProtection="All"defaultProvider="AspNetWindowsTokenRoleProvider"createPersistentCookie="false" maxCachedResults="25">
<providers>
<clear />
<addconnectionStringName="AspNetSqlFBADBConnStr"applicationName="/" name="AspNetSqlRoleProvider"type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0,Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<addapplicationName="/" name="AspNetWindowsTokenRoleProvider"type="System.Web.Security.WindowsTokenRoleProvider, System.Web,Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</roleManager>
<membershipdefaultProvider="AspNetSqlMembershipProvider"userIsOnlineTimeWindow="15" hashAlgorithmType="">
<providers>
<clear />
<addconnectionStringName="AspNetSqlFBADBConnStr"enablePasswordRetrieval="false" enablePasswordReset="true"requiresQuestionAndAnswer="true" passwordAttemptWindow="10"applicationName="/" requiresUniqueEmail="false"passwordFormat="Hashed" maxInvalidPasswordAttempts="5"minRequiredPasswordLength="1"minRequiredNonalphanumericCharacters="0" passwordStrengthRegularExpression=""name="AspNetSqlMembershipProvider"type="System.Web.Security.SqlMembershipProvider, System.Web,Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</membership>
<connectionStrings>
<clear />
<!-- FBA ClaimsAuth-->
<addname="AspNetSqlFBADBConnStr" connectionString="data source=[Server Name];Integrated Security=SSPI;Initial Catalog=[FBA Database Name]"providerName="System.Data.SqlClient" />
<!-- FBA ClaimsAuth-->
</connectionStrings>
<membershipdefaultProvider="i">
<providers>
<addname="i"type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthMembershipProvider,Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
</providers>
</membership>
<roleManagerdefaultProvider="c" enabled="true"cacheRolesInCookie="false">
<providers>
<addname="c"type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthRoleProvider,Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
</providers>
</roleManager>
并将其替换成下面字段:
<membershipdefaultProvider="i" userIsOnlineTimeWindow="15"hashAlgorithmType="">
<providers>
<clear />
<addconnectionStringName="AspNetSqlFBADBConnStr"enablePasswordRetrieval="false" enablePasswordReset="true"requiresQuestionAndAnswer="true" passwordAttemptWindow="10"applicationName="/" requiresUniqueEmail="false"passwordFormat="Hashed" maxInvalidPasswordAttempts="5"minRequiredPasswordLength="1"minRequiredNonalphanumericCharacters="0" passwordStrengthRegularExpression=""name="AspNetSqlMembershipProvider"type="System.Web.Security.SqlMembershipProvider, System.Web,Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add name="i"type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthMembershipProvider,Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
</providers>
</membership>
<roleManagerenabled="true" cacheRolesInCookie="false"cookieName=".ASPXROLES" cookieTimeout="30"cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true"cookieProtection="All" defaultProvider="c"createPersistentCookie="false" maxCachedResults="25">
<providers>
<clear />
<addconnectionStringName="AspNetSqlFBADBConnStr"applicationName="/" name="AspNetSqlRoleProvider"type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0,Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<addapplicationName="/" name="AspNetWindowsTokenRoleProvider"type="System.Web.Security.WindowsTokenRoleProvider, System.Web,Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<add name="c"type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthRoleProvider,Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
</providers>
</roleManager>
<connectionStrings>
<clear />
<!-- FBA Claims Auth-->
<add name="AspNetSqlFBADBConnStr"connectionString="data source=qujing2010-sql\panda;IntegratedSecurity=SSPI;Initial Catalog=FBA_Database"providerName="System.Data.SqlClient" />
<!-- FBA Claims Auth-->
</connectionStrings>
<system.web>
<membership>
<providers>
<add connectionStringName="AspNetSqlFBADBConnStr"enablePasswordRetrieval="false" enablePasswordReset="true"requiresQuestionAndAnswer="true" passwordAttemptWindow="10"applicationName="/" requiresUniqueEmail="false"passwordFormat="Hashed" maxInvalidPasswordAttempts="5"minRequiredPasswordLength="1"minRequiredNonalphanumericCharacters="0"passwordStrengthRegularExpression="" name="AspNetSqlMembershipProvider"type="System.Web.Security.SqlMembershipProvider, System.Web,Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</membership>
<roleManager enabled="true">
<providers>
<add connectionStringName="AspNetSqlFBADBConnStr"applicationName="/" name="AspNetSqlRoleProvider"type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0,Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</roleManager>
</system.web>
DECLARE @now datetime SET @now = GETDATE() EXECaspnet_Membership_CreateUser '/', 'User1', '123456', '', '[email protected]','PasswordQuestion?', 'PasswordAnswer', 1, @now, @now, 0, 0, NULL
其中User1是要添加的user name,123456是此user的 password。
此时,在SharePoint中配置FBA就已经完成了,下面我们创建site collection,使用上面添加的user1登录看下效果:
已上就是SharePoint2010中Form-based Authentication的全部搭建过程和使用效果,希望对大家有帮助,感谢阅读!