我们有一个SharePoint实现,其中我们的Web应用程序使用基于表单的身份验证(FBA)。
服务器场中有 2 台服务器。驻留在 DMZ 中的 Web 前端服务器和企业网络中的 SQL 服务器。防火墙将它们分开。
我们正在使用 SQL 身份验证。
我们需要强制用户在第一次成功登录后更改其密码。因此,我们根据以下文章为亚马逊物流创建了自定义登录表单。(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);
据我了解,这行代码执行以下操作:
- 调用 OnSessionSecurityTokenCreated 方法来引发会话安全令牌创建事件 在
- SPFederationAuthenticationModule.Current 上调用 AuthenticateSessionSecurityToken 方法以设置线程主体,然后编写会话 cookie。
其他需要注意的几点是:
- 此 20 秒登录时间也发生在默认的 sharepoint FBA 页面 (/_forms/default.aspx)
- 它不会在独立的开发计算机上发生。
对我来说,这表明瓶颈与网络有关。
任何帮助将不胜感激。
通过解析以下 ULS 日志条目,我设法将登录过程缩短了大约 13 秒。
3/30/2016 11:08:53.71 W3WP.exe (0x2448) 0x1148 SharePoint 基础拓扑 8321 关键 证书验证操作耗时 23141.9482 毫秒,并且已超出执行时间阈值。 如果这种情况继续发生,则可能表示配置问题。 有关更多详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkId=246987。 BC926D9D-52AF-F0FB-B2AE-236A27CD54F1
因此,SharePoint 使用证书对安全令牌服务 (STS) 颁发的安全令牌进行签名。与所有证书一样,必须定期验证 STS 证书的有效性,以确保证书未被吊销。默认情况下,链中的根证书不会添加到 SharePoint 服务器的受信任的根证书颁发机构存储中。因此,证书的证书吊销列表 (CRL) 检查是通过互联网执行的,这在我们的 WFE 服务器上是不可能的。
我通过在 WFE 服务器上导出根证书来解决此问题,使用
$rootCert = (Get-SPCertificateAuthority)。根证书$rootCert.出口("证书") |Set-Content C:\SharePointRootAuthority.cer - Encoding byte
然后使用证书 mmc 管理单元将证书导入受信任的根证书颁发机构存储。