2009-11-25 8 views
3

SharePoint 2007 웹 응용 프로그램에서 폼 인증을 사용하는지 프로그래밍 방식으로 확인할 수 있습니까? 한 가지 방법은 web.config에서 읽는 것이지만 API에 노출 된 속성이 있는지 궁금합니다.프로그래밍 방식으로 인증 모드 확인

답변

5

를 살펴 보자 /_admin/Authentication.aspx 중앙 관리에서 어떻게하는지 :

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를 사용 어디에 관심있는 부분은 . 따라서 트릭은 웹 응용 프로그램 및 영역과 관련된 SPIisSettings에 대한 참조를 올바르게 가져 오는 것입니다. 여기서 중요한 것은 모든 작업을 수행해야한다는 것입니다. 이 정보는 웹 애플리케이션 및 영역에 대한 참조를 확인하고 얻을 수 있도록

당신은 전달되는이 코드의 일부를 매개 변수화해야합니다.

을가 his.rdo_authForms.Checked를 할당 위치를 확인? 그것이 양식 승인을 사용하는지 어떻게 알 수 있습니다.

또한, 이것은 당신이 영역은 웹 응용 프로그램의 사용자가 폼 인증이 존 Schoning의 답변을 사용

3

활성화되어 있는지보고하는 알 필요가 있음을 의미한다, 나는 것인지를 결정하기 위하여 다음과 같은 코드를 함께했다 현재 인증 모드는 다음과 같습니다.

if (SPContext.Current.Site.WebApplication.IisSettings[SPContext.Current.Site.Zone].AuthenticationMode == System.Web.Configuration.AuthenticationMode.Forms) { ... } 
관련 문제