ASP.NET MVC + MySql Membership Provider, User Cannot Log In

I played using MySql as a membership provider for asp.net mvc forms authentication. As far as I can tell, everything is set up correctly, and I can create users both using the register action and from the asp.net web configuration site. however, when I try to log in with one of the users, it does not work. it returns an error as if I entered the wrong password or if the account does not exist.

I checked in the database that the account exists. I followed the instructions here for reference: http://blog.tchami.com/post/ASPNET-MVC-2-and-MySQL-Membership-Provider.aspx

here is my web.config:

<?xml version="1.0"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=152368 --> <configuration> <connectionStrings> <add name="MySQLConn" connectionString="Server=localhost;Database=intereditor;Uid=<user>;Pwd=<password>;"/> </connectionStrings> <system.web> <compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </assemblies> </compilation> <authentication mode="Forms"> <forms loginUrl="~/Account/LogOn" timeout="2880" name=".ASPXFORM$" path="/" requireSSL="false" slidingExpiration="true" enableCrossAppRedirects="false" /> </authentication> <membership defaultProvider="MySqlMembershipProvider"> <providers> <clear/> <add name="MySqlMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider,MySql.Web,Version=6.3.4.0, Culture=neutral,PublicKeyToken=c5687fc88969c44d" autogenerateschema="true" connectionStringName="MySQLConn" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/" /> </providers> </membership> <profile defaultProvider="MySqlProfileProvider"> <providers> <clear/> <add name="MySqlProfileProvider" type="MySql.Web.Profile.MySQLProfileProvider,MySql.Web,Version=6.3.4.0,Culture=neutral,PublicKeyToken=c5687fc88969c44d" connectionStringName="MySQLConn" applicationName="/" /> </providers> </profile> <roleManager enabled="true" defaultProvider="MySqlRoleProvider"> <providers> <clear /> <add name="MySqlRoleProvider" type="MySql.Web.Security.MySQLRoleProvider,MySql.Web,Version=6.3.4.0,Culture=neutral,PublicKeyToken=c5687fc88969c44d" connectionStringName="MySQLConn" applicationName="/" /> </providers> </roleManager> <pages> <namespaces> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> </namespaces> </pages> </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration> 

Can someone help me determine what is wrong so that users can log in?

UPDATE

So, after debugging the process of entering the membership provider code, I found that the provider has an error. There is a mismatch between the hash password that is stored in the database and which is created based on the entered password. As a workaround for my problem, I changed the password format to "encrpyted" and added the machine key to my web.config.

I’m still interested to deal with the hashed format in the provider and spend some more time debugging it, and if I can understand the problem, I will collect the patch and send it.

+4
source share
3 answers

Starting with .NET 4, the hash algorithm used by the MySQL connector has changed from SHA1 to something more complex (HMACSHA256).

To overcome this, you can modify the web.config file:

 <membership defaultProvider="AspNetMySqlMembershipProvider" hashAlgorithmType="SHA1"> 

You can learn more about this at: http://www.devart.com/forums/viewtopic.php?t=17508&postdays=0&postorder=asc&start=15&sid=ed160634c0e76b0fb1a4a565e8b5e200

+5
source

make sure the user is not blocked. the islocked property is in one of the tables sqlmembershipprovider uses to provide registration services (do not remember the exact name :() I am sure this is a problem and you will need to change the islocked form true to false to log in using this registration username

+1
source

I had a similar problem. It seems to be related to an error in the mysql membership provider: http://bugs.mysql.com/bug.php?id=58906 Try going to>> = 6.3.6

0
source

All Articles