簡體   English   中英

SharePoint 2013基於表單的身份驗證很慢–為什么SetPrincipalAndWriteSessionToken需要20秒或更長時間?

[英]SharePoint 2013 Forms Based Authentication is Slow– Why does SetPrincipalAndWriteSessionToken take 20 seconds or more?

我們有一個SharePoint實現,其中我們的Web應用程序正在使用基於表單的身份驗證(FBA)。

服務器場中有2台服務器。 Web前端服務器,位於公司網絡中的DMZ和SQL服務器中。 防火牆將它們分開。

我們正在使用SQL身份驗證。

首次成功登錄后,我們需要強制用戶更改密碼。 因此,我們根據以下文章為FBA創建了自定義登錄表單。 https://sharepoint.stackexchange.com/questions/42541/how-to-create-a-custom-fba-login-page-that-forces-user-to-change-password-and-vi )。

有問題的代碼是:

private void SignInUser()
{
        SecurityToken token = SPSecurityContext.SecurityTokenForFormsAuthentication
                                                 (new Uri(SPContext.Current.Web.Url),
                                                  GetMembershipProvider(SPContext.Current.Site),
                                                  GetRoleProvider(SPContext.Current.Site),
                                                 _userName,
                                                 _password, SPFormsAuthenticationOption.None);
        SPFederationAuthenticationModule fam = SPFederationAuthenticationModule.Current;           
        fam.SetPrincipalAndWriteSessionToken(token, SPSessionTokenWriteType.WriteSessionCookie);
        SPUtility.Redirect(System.Web.Security.FormsAuthentication.DefaultUrl,
        SPRedirectFlags.UseSource, this.Context);                
}  

public static string GetMembershipProvider(SPSite site)
{
        // get membership provider of whichever zone in the web app fba isenabled 
        SPIisSettings settings = GetFbaIisSettings(site);
        if (settings == null) return null;
        return settings.FormsClaimsAuthenticationProvider.MembershipProvider;
}

public static string GetMembershipProvider(SPSite site)
{
        // get membership provider of whichever zone in the web app is fba enabled 
        SPIisSettings settings = GetFbaIisSettings(site);
        if (settings == null) return null;
        return settings.FormsClaimsAuthenticationProvider.MembershipProvider;
} 

花費時間的代碼是:

fam.SetPrincipalAndWriteSessionToken(token, SPSessionTokenWriteType.WriteSessionCookie); 據我了解,這行代碼執行以下操作:

  1. 調用OnSessionSecurityTokenCreated方法引發SessionSecurityTokenCreated事件
  2. 在SPFederationAuthenticationModule.Current上調用AuthenticateSessionSecurityToken方法以設置線程主體,然后編寫會話cookie。

需要注意的其他幾點是:

  1. 對於默認的共享點fba頁面(/_forms/default.aspx),也會發生此20秒的登錄時間。
  2. 在獨立開發機上不會發生。

對我來說,這表明瓶頸與網絡有關。

任何幫助將非常感激。

通過解決以下ULS日志條目,我設法節省了約13秒的登錄過程。

3/30/2016 11:08:53.71 w3wp.exe(0x2448)0x1148 SharePoint Foundation拓撲8321嚴重證書驗證操作花費了23141.9482毫秒,並且超過了執行時間閾值。 如果這種情況繼續發生,則可能表示配置問題。 請參閱http://go.microsoft.com/fwlink/?LinkId=246987,以獲取更多詳細信息。 bc926d9d-52af-f0fb-b2ae-236a27cd54f1

因此,SharePoint使用證書來簽名由安全令牌服務(STS)發行的安全令牌。 與所有證書一樣,必須定期驗證STS證書的有效性,以確保未撤消該證書。 默認情況下,鏈中的根證書不會添加到SharePoint服務器的“受信任的根證書頒發機構”存儲中。 因此,證書的證書吊銷列表(CRL)檢查是通過Internet執行的,這在我們的WFE服務器上是不可能的。

我通過使用以下方法導出WFE服務器上的根證書來解決此問題:

$ rootCert =(Get-SPCertificateAuthority).RootCertificate $ rootCert.Export(“ Cert”)| 設置內容C:\\ SharePointRootAuthority.cer-編碼字節

然后使用證書mmc管理單元將證書導入到“受信任的根證書頒發機構”存儲中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM