2011-08-21 1 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