有没有办法以编程方式确定 SharePoint 2007 Web 应用程序是否正在使用表单身份验证?我想一种方法可能是从 web.config 中读取它,但我想知道 API 中是否公开了一些属性。
看看 /_admin/Authentication.aspx 在 Central Admin 中是如何实现的:
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
}
}
您感兴趣的部分是它使用 iisSettings.AuthenticationMode 来确定它是否是 Forms Auth。因此,诀窍是正确获取与您的 web 应用程序和区域相关的 SPIisSettings 引用。到达这一点是需要完成所有工作的地方。
您需要参数化此代码的部分内容,以便传入识别和获取对 webApp 和区域的引用的信息。
看看它在哪里分配了 his.rdo_authForms.Checked 吗?这就是你如何知道它是否使用表单身份验证。
此外,这意味着您需要知道您正在查看 Web 应用程序的哪个区域,以查看是否启用了表单身份验证
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)