Question

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?

Was it helpful?

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

OTHER TIPS

If password is stored as hashed, it doesn't use machine key.

However, password is stored as encrypted, it uses machine key.

If they are mixed and machine key is not explicitly set in web.config, only thing you can do is to retrieve the machine key from old server using this method -

How to read Auto Generated machine key?

Rule of thumb is you want to include machine key in web.config. We learn the hard way that Azure creates machine key automatically if you do not set one in web.config.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top