+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Custom Membership Provider providerName

Custom Membership Provider providerName

5 posts, 1 answered
  1. Tech
    Tech avatar
    26 posts
    Registered:
    13 Sep 2010
    29 Oct 2010
    Link to this post
    Greetings all,

    I'm working to develop a custom Membership provider to tie Sitefinity 3.x into our internal membership management system, but I'm running into an issue.  Within the root of the site, when authenticating a user, I'm not having any issues, but when I try to authenticate a user into the /Sitefinity CMS admin folder, I get the following error:

    The membership provider name specified is invalid.
    Parameter name: providerName
    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.ArgumentException: The membership provider name specified is invalid.
    Parameter name: providerName
     
    Source Error:
     
    Line 121:            if (ccontact != null)
    Line 122:            {
    Line 123:                user = new MembershipUser(
    Line 124:                    new System.Web.Configuration.MembershipSection().DefaultProvider.ToString(),
    Line 125:                    ccontact.FullName,

    The code generating the error is as follows:

    user = new MembershipUser(
        new System.Web.Configuration.MembershipSection().DefaultProvider.ToString(),
        ccontact.FullName,
        ccontact.ContactId,
        ccontact.EmailAddress,
        "",
        "",
        true,
        false,
        ccontact.JoinDate,
        DateTime.Today,
        DateTime.Today.AddDays(-1),
        DateTime.Today.AddDays(-1),
        DateTime.Today.AddDays(-1));

    After some digging around, I managed to find out that the provider name being passed in from the DefaultProvider value is actually AspNetSqlMembershipProvider, and not the value specified in the Web.config in the root folder of my site.  I looked at the web.config in the /Sitefinity folder as well, but that value is not overridden at all in that file either.

    However, if I hard-code the providerName value, it works just fine.  I would certainly prefer to NOT have to hard code that value, and pull it from the web.config, but I'm not sure why it's pulling in AspNetSqlMembershipProvider instead of the value in my web.config.

    Any help on this would be awesome...thanks!
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    29 Oct 2010
    Link to this post
    Hello Phillip,

    Backend can work only with one membership provider which have to be set in <security> node

    <security defaultProvider="DefaultSecurityProvider" cmsProvidersName="MyCustomProvider">

    Your provider should be declared inside <membership> node, but "Sitefinity" should be set as a default provider

    sample

    <membership defaultProvider="Sitefinity" userIsOnlineTimeWindow="15" hashAlgorithmType="">
            <providers>
              <clear/>
              <add name="MyCustomProvider" connectionStringName="Membership2" type="MembershipProviderClass, App_Code" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" passwordAttemptWindow="10" passwordStrengthRegularExpression="" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0"/>
              <add name="Sitefinity" connectionStringName="DefaultConnection" type="Telerik.DataAccess.AspnetProviders.TelerikMembershipProvider, Telerik.DataAccess" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" passwordAttemptWindow="10" passwordStrengthRegularExpression="" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0"/>
          
            </providers>
          </membership>


    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Tech
    Tech avatar
    26 posts
    Registered:
    13 Sep 2010
    29 Oct 2010
    Link to this post
    Ivan,

    Thanks for the quick response.  I made the changes in my web.config that you recommended, but it is still giving me the same error message.  It seems to me as if, for some reason, within the /Sitefinity subfolder of the site, there is some configuration setting overriding the value in the <membership defaultProvider="MyProviderName"> value to AspNetSqlMembershipProvider.  I double checked IIS to make sure the /Sitefinity folder is not configured as a separate application or perhaps pulling that value from elsewhere, and also double checked the web.config in that subfolder to make sure that the value was not begin overridden in there somehow.

    If it would help, I can send you a PM with my web.config files in them, just let me know.

    Thanks!
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    29 Oct 2010
    Link to this post
    Hello Phillip,

    Membership.Provider.Name; will give you reference to the default provider. Check whether "defaultProvider" attribute in the <membership /> matches the "name" attribute in the <add /> element.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
  5. Tech
    Tech avatar
    26 posts
    Registered:
    13 Sep 2010
    29 Oct 2010
    Link to this post
    Ivan,

    That seems to have done the trick.  Thanks much!
Register for webinar
5 posts, 1 answered