MySQL: .Net Connector User Login Fails for Hashed but not ClearPasswords

If you are running into issues with the MySQL .Net Connector (any version) specially when it comes to user login after registration you may need to added some additional configuration to your web.config file.

I ran into a strange situation where a web application which was setup using the MySQL .Net Connector 6.3.0.0 for membership would allow a new user to register without an issue but once that user logs out and then attempts to log back in all they get is the “Your login attempt was unsuccessful” error message. I quadruple checked the web.config and made sure that the membership, roles, and profile providers for MySQL membership were all setup correctly. They were perfect! I finally in a ditch effort changed the password format from ‘Hashed’ to ‘Clear’, wiped out my membership database and recreated it. Amazingly, that fixed it, my users could register the same as before but this time they could actually login once logged out.

I did some Google searches on the strange difference between ‘Clear’ and ‘Hashed’ passwords and the MySQL .Net Connector and found that it relied heavily on the ‘MachineKey’ entry and was expecting a ‘ValidationKey’ and ‘DecryptionKey’ to be explicitly set. since I am running multiple applications on my production servers and since they are all using different keys in the farm I decided it would be best to place the ‘MachineKey’ entry in the web.config for each of my applications in order to allow them each to have their own keys.

Once I added the ‘MachineKey’ with the explicitly set values I switched the membership provider from ‘Clear’ to ‘Hashed’ password format, cleared out my membership database and retried registering and logging in users. This completely fixed my issue. Below is the entry that needs to be added to your web.config.

<machineKey
validationKey=”yourkeygoeshere”
decryptionKey=”yourkeygoeshere”
validation=”SHA1″
decryption=”AES”/>

Published by

Tim Clark

Experienced Business Owner, Chief Information Officer, Vice President, Chief Software Architect, Application Architect, Project Manager, Software Developer, Senior Web Developer, Graphic Designer & 3D Modeler, University Instructor, University Program Chair, Academic Director. Specialties: Ruby, Ruby on Rails, JavaScript, JQuery, AJAX, Node.js, React.js, Angular.js, MySQL, PostgreSQL, MongoDB, SQL Server, Responsive Design, HTML5, XHTML, CSS3, C#, ASP.net, Project Management, System Design/Architecture, Web Design, Web Development, Adobe CS6 (Photoshop, Illustrator)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s