2011-08-21 3 views
1

인증 로직이있는 로그인 양식이 있습니다. ==============FBA 인증 및 보안 토큰 오류

SecurityToken tk = SPSecurityContext.SecurityTokenForFormsAuthentication 
    (
    new Uri(SPContext.Current.Web.Url), 
    "MyUserProvider", 
    "MyRoleProvider", 
    this.txLogin.Text, 
    this.txPassword.Text 
); 

: 나는 다음이 코드 라인에서 "방법 또는 작업이 구현되지" "로그인"버튼을 클릭 오류가 로그인과 암호를 입력 ==================================

Server Error in '/' Application. 

The method or operation is not implemented. 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]: The method or operation is not implemented. 

Stack Trace: 


[FaultException`1: The method or operation is not implemented.] 
    Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.ReadResponse(Message response) +1161013 
    Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.Issue(RequestSecurityToken rst, RequestSecurityTokenResponse& rstr) +73 
    Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.Issue(RequestSecurityToken rst) +36 
    Microsoft.SharePoint.SPSecurityContext.SecurityTokenForContext(Uri context, Boolean bearerToken, SecurityToken onBehalfOf, SecurityToken actAs, SecurityToken delegateTo) +26193297 
    Microsoft.SharePoint.SPSecurityContext.SecurityTokenForFormsAuthentication(Uri context, String membershipProviderName, String roleProviderName, String username, String password) +26189452 
    Microsoft.SharePoint.IdentityModel.Pages.FormsSignInPage.GetSecurityToken(Login formsSignInControl) +188 
    Microsoft.SharePoint.IdentityModel.Pages.FormsSignInPage.AuthenticateEventHandler(Object sender, AuthenticateEventArgs formAuthenticateEvent) +123 
    System.Web.UI.WebControls.Login.AttemptLogin() +152 

하지만 사용자 정의 회원 및 역할과 조립이 제공자와 모든 메소드가 구현되었습니다! 실수는 어디 있습니까?

답변

1

당신처럼, 직접 사용자 지정 멤버 자격 및 역할 공급자로부터 기본 회원 함수를 호출 할 수있다 : 회원 제공되지 않습니다

Membership.FindUsersByEmail("[email protected]"); 

이이 기본 멤버 자격 공급자에 의해 처리 얻을 것이다, SPClaimsAuthMembershipProvider가됩니다. SPClaimsAuthMembershipProvider는 많은 기본 메서드를 구현하지 않습니다. 구현되지 않은 예외를 반환합니다. 당신이 참조하는 웹 응용 프로그램의 선택 멤버 자격 공급자를 얻고 싶은 경우에

, 다음과 같은 코드를 사용할 수 있습니다

public static string GetMembershipProvider(SPSite site) 
{ 
    // get membership provider of whichever zone in the web app is fba enabled 
    SPIisSettings settings = GetFBAIisSettings(site); 
    return settings.FormsClaimsAuthenticationProvider.MembershipProvider; 
} 

public static SPIisSettings GetFBAIisSettings(SPSite site) 
{ 
    SPIisSettings settings = null; 

    // try and get FBA IIS settings from current site zone 
    try 
    { 
     settings = site.WebApplication.IisSettings[site.Zone]; 
     if (settings.AuthenticationMode == AuthenticationMode.Forms) 
      return settings; 
    } 
    catch 
    { 
     // expecting errors here so do nothing     
    } 

    // check each zone type for an FBA enabled IIS site 
    foreach (SPUrlZone zone in Enum.GetValues(typeof(SPUrlZone))) 
    { 
     try 
     { 
      settings = site.WebApplication.IisSettings[(SPUrlZone)zone]; 
      if (settings.AuthenticationMode == AuthenticationMode.Forms) 
       return settings; 
     } 
     catch 
     { 
      // expecting errors here so do nothing     
     } 
    } 

    // return null if FBA not enabled 
    return null; 
} 
+0

감사합니다! 잘 작동한다. – NieAR

0

몇 가지 시도 :

  • 당신이 킬로그램 관리를 통해 웹 응용 프로그램의 제공을 등록 했습니까?
  • web.config에 공급자를 등록 했습니까?
  • 대신 SPClaimsUtility.AuthenticateFormsUser을 사용하면 어떻게됩니까?
+0

1) 예 2) 예 3) 동일한 오류 – NieAR