有没有一种编程方式可以确定SharePoint 2007 Web应用程序是否正在使用Forms身份验证?我想从web.config文件中读取它可能是一种方法,但我想知道API中是否公开了某些属性。
有没有一种编程方式可以确定SharePoint 2007 Web应用程序是否正在使用Forms身份验证?我想从web.config文件中读取它可能是一种方法,但我想知道API中是否公开了某些属性。
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
string g = base.Request.QueryString["WebAppId"];
this.webApp = (SPWebApplication) SPConfigurationDatabase.Local.GetObject(new Guid(g));
this.zone = (SPUrlZone) Enum.Parse(typeof(SPUrlZone), base.Request.QueryString["Zone"]);
this.lb_Zone.Text = SPHttpUtility.HtmlEncode(SPAlternateUrl.GetZoneName(this.zone));
SPIisSettings iisSettings = this.webApp.IisSettings[this.zone];
// CODE ELIDED
if (AuthenticationMode.Windows != iisSettings.AuthenticationMode)
{
if (AuthenticationMode.Forms != iisSettings.AuthenticationMode)
{
// CODE ELIDED
}
else
{
this.rdo_authForms.Checked = true;
}
// CODE ELIDED
}
}
根据Jon Schoning的答案,我得出了以下代码来确定当前的身份验证模式是否为表单:
if (SPContext.Current.Site.WebApplication.IisSettings[SPContext.Current.Site.Zone].AuthenticationMode == System.Web.Configuration.AuthenticationMode.Forms) { ... }