Created
July 28, 2011 16:32
-
-
Save jonschoning/1111885 to your computer and use it in GitHub Desktop.
Programmatically determine SharePoint 2007 authentication mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Is there a way to programmatically determine if a SharePoint 2007 web application is using Forms authentication? I guess one way might be to read it from the web.config but I was wondering if there is some property exposed in the 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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment