SharePoint 2010 啟用Form認證並增加用戶注冊功能


啟用Form認證並增加用戶注冊的方法見這位仁兄的文章:http://www.cnblogs.com/fanwenxuan/archive/2010/09/18/1830353.html

或者:http://donalconlon.wordpress.com/2010/02/23/configuring-forms-base-authentication-for-sharepoint-2010-using-iis7/

本文不再做闡述。

用上文的方法操作后,用戶注冊完成必須關閉瀏覽器重新登錄,否則直接點擊完成返回首頁會報錯。

錯誤原因無非是asp.net的CreateUserWizard在完成用戶創建后會自動使用戶登錄,但是asp.net的默認登錄邏輯跟SP1010的Claim認證機制估計不兼容。

解決方案:

1)處理CreateUserWizard的OnCreatedUser事件,增加兼容Claim的認證機制

反編譯了下默認的登錄頁面代碼(_forms/default.aspx),發現Claim的登錄機制代碼還是蠻多的,其中涉及到眾多的internal方法,全部摳出來需要一點時間…

2)禁止CreateUserWizard自動認證用戶,創建完成用戶后,轉向默認登錄頁面,讓新用戶手工登錄。本文主要闡述這種方法:

完整的注冊頁面代碼如下:

<%@ Assembly Name="Microsoft.SharePoint.IdentityModel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Assembly Name="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%> 
<%@ Page Language="C#"  MasterPageFile="~/_layouts/simple.master"   %>
 <%@ Import Namespace="Microsoft.SharePoint.WebControls" %> 
<%@ Register Tagprefix="SharePoint" 
Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
 <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" 
Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Import Namespace="Microsoft.SharePoint" %> 
<%@ Import Namespace="Microsoft.SharePoint.Administration" %> 
<%@ Import Namespace="Microsoft.SharePoint.Administration.Claims" %> 
<%@ Import Namespace="System.IdentityModel.Tokens" %> 

<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<script language="C#" runat="server">

protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('register success, please login on using your account');window.location='/';", true);
}
 
</script>

<asp:Content ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">
    SignUp
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderPageTitleInTitleArea" runat="server">
    Sign Up
</asp:Content>
<asp:Content ContentPlaceHolderId="PlaceHolderSiteName" runat="server"/>
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<asp:CreateUserWizard ID="SignUp" runat="server" LoginCreatedUser="false"  oncreateduser="CreateUserWizard1_CreatedUser"
CreateUserButtonText="Sign Up">
<TextBoxStyle CssClass="ms-inputuserfield" />
        <WizardSteps>
        <asp:CreateUserWizardStep runat="server" Title="Sign Up"></asp:CreateUserWizardStep>
        <asp:CompleteWizardStep runat="server"></asp:CompleteWizardStep>
        </WizardSteps>
</asp:CreateUserWizard>
</asp:Content>

另:推薦按照FBATools來進行用戶管理:http://fbamanagementtool.codeplex.com/
or
http://sharepoint2010fba.codeplex.com/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM