Search code examples
asp.netsqlmembership-provider

ASP.NET Membership Provider failing on different SQL instance


I am using the ASP.NET Membership Schema using aspnet_regsql.exe on SQL1 (hosted via windows server), I had a backup of that sql database restored on SQL2 (local instance).

However, when I have my connection string pointed to SQL2, authentication is failing @

Membership.ValidateUser

It is returning a false, but when I change my connection string back to SQL1, it returns true, this is happening on same codebase. I am not sure what is causing this, I have tried the following

  • Checked SQL1 and SQL2 passwords and salts, they match exactly
  • Tried using SQL Compare to see if there was something different, the schema matches exactly
  • Checked SQL login permissions, they both match

Any ideas?


Solution

  • The encrypted password is created from a hash of the machine key (which is in web.config so could be a red herring if this is the same web server?) + actual pwd + randomly generated password salt.

    Try running a sql trace to capture the issued commands and try running those in QA. This would show up a hash mismatch or simple auth fail.

    Maybe you should force the machine key, look for machine.config and copy it from there into your local web.config.

    My past pain-history says if ur still scratching your head - go find a decent decompiler (ILSpy) and attach your debugger to the dll and step through as you would if it were your own code.

    Machine key in Forms-Auth