Domanda

There is a login form with any authentication logic. I enter login and password, then I click "Login" and get error "The method or operation is not implemented" in this code line:

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

But I have assembly with custom Membership and Roles Provider and all methods are implemented! Where is a mistake?

È stato utile?

Soluzione

You may be calling base membership functions directly from your custom membership and roles provider, like:

Membership.FindUsersByEmail("myemail@here.com");

These will get handled by the default membership provider, which won't be your membership provider, but will be the SPClaimsAuthMembershipProvider. SPClaimsAuthMembershipProvider doesn't implement a lot of the base methods - they will return a not implemented exception.

If you want to get the web app's selected membership provider to reference, you can use the following code:

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;
}

Altri suggerimenti

Some things to try:

  • Did you register the providers in the web application through the Cental Admin?
  • Did you register the providers in your web.config?
  • What happens if you use SPClaimsUtility.AuthenticateFormsUser instead?
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top