Sharepoint 2010配置form認證方式(SQL賬号)
1、首先我們建立我們form認證中所需要的資料庫。
找到aspnet_regsql.exe,一般在C:\Windows\Microsoft.NET下,根據作業系統進行選擇。因為本人是win2008 R2x64,是以打開目錄為C:\Windows\Microsoft.NET\Framework64\v2.0.50727
2、輕按兩下運作後,點選下一步,然後選擇為應用程式配置sql server,如圖:
<a href="http://s3.51cto.com/wyfs02/M00/3F/76/wKiom1PJPtuQVbSdAAKTXPPss_I965.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M02/3F/76/wKiom1PJPtvwOISoAAHiO8-iqMo039.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M02/3F/76/wKioL1PJP_fgrkJGAAFOP4jSZss707.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M01/3F/76/wKiom1PJPt2h32reAAGfTj4RML4323.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M00/3F/76/wKioL1PJP_jA6LSgAAJYWzEvikI714.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M02/3F/76/wKiom1PJPt7QPVUHAAGrG1kvl1U862.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M01/3F/76/wKioL1PJP_jipQztAADAISIKL6U222.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M00/3F/76/wKiom1PJPt7ADoL3AABOYVY5M24304.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M02/3F/76/wKioL1PJP_mzySQNAANopMGE2gc752.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M01/3F/76/wKiom1PJPt7TKS3AAAMBwxRUAvA502.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M00/3F/76/wKioL1PJP_mhOZSYAAI_IHSMxCk032.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M02/3F/76/wKiom1PJPt-TR4eFAAI5a3SStPM250.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M00/3F/76/wKioL1PJP_qSMVW3AAK0GzYpJaQ643.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M01/3F/76/wKioL1PJP_uzbhV1AAS1Rg1o5QY113.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M00/3F/76/wKiom1PJPuGxmpSrAAKonL37lJE004.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M00/3F/76/wKiom1PJPuKAoAIaAAFuItxNIsE630.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M02/3F/76/wKioL1PJP_yzDiowAAEgNr9-aZU266.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M01/3F/76/wKiom1PJPuKRe-ukAAFp-f1VeU8651.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M00/3F/76/wKioL1PJP_2w_I_EAAGD3ZJ2Ca4280.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M01/3F/76/wKioL1PJP_3A836DAAHYhBokuRg978.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M02/3F/76/wKiom1PJPuPQuFfBAAHqD5jPplY642.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M01/3F/76/wKiom1PJPuPjQavQAAHhLq2hdQ0571.jpg" target="_blank"></a>
<a href="http://photo.blog.sina.com.cn/showpic.html#blogid=7778950d0100uu64&url=http://s10.sinaimg.cn/orignal/7778950dha568a59245e9" target="_blank"></a>
3、填寫,伺服器名稱及資料庫名稱,然後點選下一步
<a href="http://photo.blog.sina.com.cn/showpic.html#blogid=7778950d0100uu64&url=http://s10.sinaimg.cn/orignal/7778950dha568ac046649" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M00/3F/76/wKiom1PJP32zrIbLAAGzr4Ybj2A708.jpg" target="_blank"></a>
4、完成
1:建立一個基于身份認證的應用程式(具體參見上篇基于AD)
MembershipProvider 成員
RoleManager 角色
如圖:
<a href="http://s3.51cto.com/wyfs02/M02/3F/76/wKioL1PJQKzxFEySAAJqoPSB06E065.jpg" target="_blank"></a>
<a href="http://photo.blog.sina.com.cn/showpic.html#blogid=7778950d0100uu64&url=http://s2.sinaimg.cn/orignal/7778950dha5685bd6ef31" target="_blank"></a>
2:修改管理中心,我們建立的應用程式,還有Web服務裡面的SecurityTokenServiceApplication這個3個地方的web.config
每個地方都要加連接配接資料庫的字元串(最好自己建立的賬戶給予單獨的DB owner通路資料庫,不然可能通路不到資料)
<connectionStrings>
<addname="SQLConnectionString"connectionString="Data Source=profitsp;Database=WSS_Content_80;User ID=sa;password=xxxx" />
</connectionStrings>
找到管理中心的<system.web></system.web>,配置如下:
<roleManagerdefaultProvider="AspNetWindowsTokenRoleProvider"enabled="true"cacheRolesInCookie="false">
<providers>
<addconnectionStringName="SQLConnectionString"applicationName="/"description="Stores and retrieves roles from SQL Server"name="RoleManager"type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</roleManager>
<membershipdefaultProvider="MembershipProvider">
<addconnectionStringName="SQLConnectionString"passwordAttemptWindow="5"enablePasswordRetrieval="false"enablePasswordReset="false"requiresQuestionAndAnswer="true"applicationName="/"requiresUniqueEmail="true"passwordFormat="Hashed"description="Stores and Retrieves membership data from SQL Server"name="MembershipProvider"type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</membership>
找到應用程式的<system.web></system.web>,配置如下
<membershipdefaultProvider="i">
<addname="i"type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthMembershipProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<roleManagercacheRolesInCookie="false"defaultProvider="c"enabled="true">
<addname="c"type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthRoleProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
找到SecurityTokenServiceApplication站台web.config,它裡面沒有<system.web></system.web>,你需要自己添加
<system.web>
<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" />
<addconnectionStringName="SQLConnectionString"applicationName="/"description="Stores and retrieves roles from SQL Server"name="RoleManager"type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</roleManager>
<membershipdefaultProvider="i">
<addname="i"type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthMembershipProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<addconnectionStringName="SQLConnectionString"passwordAttemptWindow="5"enablePasswordRetrieval="false"enablePasswordReset="false"requiresQuestionAndAnswer="true"applicationName="/"requiresUniqueEmail="true"passwordFormat="Hashed"description="Stores and Retrieves membership data from SQL Server"name="MembershipProvider"type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</membership>
</system.web>
3 改好後,可以自己建立一個使用者。先設定預設的提供程式,然後就能用iis的功能添加使用者。添加好使用者後記得還原預設提供程式
<a href="http://s3.51cto.com/wyfs02/M02/3F/76/wKiom1PJP_Kgx-5SAAOESfNe_GI784.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M01/3F/76/wKioL1PJQQ3BK5wyAAMR35xQlZI580.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M00/3F/76/wKiom1PJP_OQ1KkTAAJPCjD8SOM057.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M02/3F/76/wKioL1PJQQ6Apc72AAJIp5TiXbA975.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M01/3F/76/wKiom1PJP_TimZ5hAALEWyvKAzg909.jpg" target="_blank"></a>
4、配置站點form驗證
5、用剛才建立的form賬号設定為站點集管理者
<a href="http://s3.51cto.com/wyfs02/M02/3F/76/wKiom1PJQBahXJPLAAK8O4s96Uo038.jpg" target="_blank"></a>
6、在iis中進行驗證,參看如下
輕按兩下功能視圖中的(連接配接字元串),然後,在打開的視圖中,選擇右邊的“添加”。然後,在彈出視窗中輸入我們連接配接字元串的名稱、資料庫伺服器、資料庫名稱、及指定憑據。憑據為我們剛剛資料庫中建立的使用者名(baigujing),最後點選确定按鈕。如圖:
<a href="http://photo.blog.sina.com.cn/showpic.html#blogid=7778950d0100uu64&url=http://s9.sinaimg.cn/orignal/7778950dha566a6cc2028" target="_blank"></a>
<a href="http://photo.blog.sina.com.cn/showpic.html#blogid=7778950d0100uu64&url=http://s3.sinaimg.cn/orignal/7778950dha566cfb9ef32" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M01/3F/76/wKioL1PJQVDCwqbnAAGGyz_LSDA895.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M00/3F/76/wKiom1PJQDbDwdwDAAE5PsVC3_0214.jpg" target="_blank"></a>
(3)、回到管理中心站點的功能視圖,輕按兩下提供程式,然後選擇清單中的(.NET角色)選項,點選添加按鈕,在彈出的視窗中依次填寫,選擇類型、名稱、ApplicationName、ConnectionaStringName。然後點選确定。如圖:
<a href="http://photo.blog.sina.com.cn/showpic.html#blogid=7778950d0100uu64&url=http://s10.sinaimg.cn/orignal/7778950dha5671691ade9" target="_blank"></a>
<a href="http://photo.blog.sina.com.cn/showpic.html#blogid=7778950d0100uu64&url=http://s7.sinaimg.cn/orignal/7778950dh76f0b5391286" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M01/3F/76/wKiom1PJQFajDdpfAAGDzlLbkfQ954.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M00/3F/76/wKioL1PJQXHhKTdcAAGiyyqB1Ro216.jpg" target="_blank"></a>
(4)、回到提供程式界面,然後在清單中選擇(.NET使用者)選項,單擊添加按鈕,在彈出的視窗中依次填寫類型、名稱、applicationname、connectionstringname,然後點選确定。如圖:
<a href="http://photo.blog.sina.com.cn/showpic.html#blogid=7778950d0100uu64&url=http://s8.sinaimg.cn/orignal/7778950dha56787e292a7" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M02/3F/76/wKiom1PJQHGhf8_3AAHv-HLpS24658.jpg" target="_blank"></a>
<a href="http://s3.51cto.com/wyfs02/M01/3F/76/wKioL1PJQY2R55WeAAIBYm1IokY745.jpg" target="_blank"></a>
<a href="http://photo.blog.sina.com.cn/showpic.html#blogid=7778950d0100uu64&url=http://s10.sinaimg.cn/orignal/7778950dha567891e56a9" target="_blank"></a>
7、完成,可以進行登入測試
參考文章:
<a href="http://blog.sina.com.cn/s/blog_7778950d0100uu64.html" target="_blank">http://blog.sina.com.cn/s/blog_7778950d0100uu64.html</a>
http://blog.csdn.net/foxdave/article/details/5793696
<a href="http://down.51cto.com/data/2364670" target="_blank">附件:http://down.51cto.com/data/2364670</a>
本文轉自 yuxye 51CTO部落格,原文連結:http://blog.51cto.com/fishvsfrog/1440100