2011-08-21 56 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没有实现许多基本方法 - 它们将返回一个未实现的异常。

如果你想要得到的Web应用程序的选择的成员资格提供参考,可以使用下面的代码:

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应用程序的供应商?
  • 您是否在web.config中注册了提供程序?
  • 如果您改用SPClaimsUtility.AuthenticateFormsUser会发生什么?
+0

1)是2)是3)相同的错误 – NieAR