Link to home
Start Free TrialLog in
Avatar of tim_chicagopartyanimals
tim_chicagopartyanimalsFlag for United States of America

asked on

MembershipCreateUserException "The password-answer supplied is invalid."

I am having a difficult time getting past an error.  To start with, I used the Silverlight Business Application template to create the base project and website.  I have made some modifications to the default login forms created.  I did this so people could register with just a username, email address, and password.  This required a number of changes in various spots.  For instance, I edited the RegistrationData.vb file that was generated in the server project in the Models folder.  This altered the registration xaml child window.  I also modified the UserRegistrationService.vb file in the server project services folder so the Membership.CreateUser method so it was only taking the arguments for username, password, and email address.  I also wanted to eliminate the need for a non alpha numeric character in the password.  Finally, I modified the web.config file to reflect the desired changes.  That section of code is currently looking like:

<membership>
      <providers>
        <remove name="LocalSqlServer"/>
        <add name="ChicagoPartyAnimalsMembershipProvider"
             connectionStringName="LocalSqlServer"
             type="System.Web.Security.SqlMembershipProvider"
             enablePasswordRetrieval="false"
             enablePasswordReset="false"
             requiresQuestionAndAnswer="false"
             applicationName="ChicagoPartyAnimals"
             requiresUniqueEmail="false"
             passwordFormat="Hashed"
             maxInvalidPasswordAttempts="5"
             minRequiredPasswordLength="1"
             minRequiredNonalphanumericCharacters="0"
             passwordAttemptWindow="10"
             passwordStrengthRegularExpression=""/>
      </providers>
    </membership>

When I run the project and go to the registration page, I am properly displaying just the 4 fields I desire (username, email, password, confirm password) and when I click the OK button to actually register, I receive the exception listed in the title.  I have tried going through everything with a fine tooth comb to see if I can see what I am missing, although thus far I have been completely stumped.  It is possible/likely that I have modified something else in the effort to remove the security question and answer details as well as the minimum length and character types for the password that has not been listed here.  I just do not understand why I am getting an error related to a security question that is not necessary.  Perhaps my assumption that the error is regarding a security question answer is incorrect???  Regardless, and insight would be greatly appreciated.
The StatusCode of the exception view detail is "MembershipCreateStatus.InvalidAnswer". User generated image
ASKER CERTIFIED SOLUTION
Avatar of SameerJagdale
SameerJagdale
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tim_chicagopartyanimals

ASKER

That was it, thank you for your help.  From the time the error started until now, things in the web.config file (as well as a few others) slowly evolved and that is something that I didn't even think about or realize.  Your help is greatly appreciated.

Cheers!
glad to hear that :)
Avatar of Zappel89
Zappel89

I'm afraid the solution doesn't work for me. I still get the "The password-answer supplied is invalid." exception when trying to create a new user with this call:
var newUser = Sitecore.Security.Accounts.User.Create(newMember.Username, newMember.GenerateNewPassword(8));

Open in new window


My default web.config looks like this:
<add name="sql"
type="System.Web.Security.SqlMembershipProvider" 
connectionStringName="core" 
applicationName="sitecore" 
minRequiredPasswordLength="1" 
minRequiredNonalphanumericCharacters="0"
requiresQuestionAndAnswer="false" 
requiresUniqueEmail="true" 
maxInvalidPasswordAttempts="256"/>
        

Open in new window


And I then replaced it with your solution like this:
<membership defaultProvider="sitecore">
      <providers>
        <clear/>
        <add name="sitecore" type="Sitecore.Security.SitecoreMembershipProvider, Sitecore.Kernel" realProviderName="sql" providerWildcard="%" raiseEvents="true"/>       
        <add name="sql"
             type="System.Web.Security.SqlMembershipProvider"
             connectionStringName="core"
             enablePasswordRetrieval="false"
             enablePasswordReset="true"
             requiresQuestionAndAnswer="false"
             applicationName="sitecore"
             requiresUniqueEmail="false"
             passwordFormat="Hashed"
             maxInvalidPasswordAttempts="5"
             minRequiredPasswordLength="1"
             minRequiredNonalphanumericCharacters="0"
             passwordAttemptWindow="10"
             passwordStrengthRegularExpression="" />
        
        <add name="switcher" type="Sitecore.Security.SwitchingMembershipProvider, Sitecore.Kernel" applicationName="sitecore" mappings="switchingProviders/membership"/>
      </providers>
    </membership>

Open in new window


I really hope you have a solution for this, I have spent so much time on this problem now!

Thank you!