0

我们有一个 SharePoint 实现,其中我们的 Web 应用程序使用基于表单的身份验证 (FBA)。

场中有 2 台服务器。位于 DMZ 中的 Web 前端服务器和企业网络中的 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. 这 20 秒的登录时间也发生在默认的 sharepoint fba 页面 (/_forms/default.aspx)
  2. 它不会发生在独立的开发机器上。

对我来说,这表明瓶颈与网络有关。

任何帮助将非常感激。

4

1 回答 1

0

通过解析以下 ULS 日志条目,我设法将登录过程缩短了大约 13 秒。

2016 年 3 月 30 日 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 管理单元将证书导入受信任的根证书颁发机构存储。

于 2016-03-30T13:43:03.097 回答