Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

Why are users losing their role assignment when DB is restored?

$
0
0

This is a follow-up to my earlier posting.  I thought everything was working fine but today I learned that it was not.

I performed a test today, which failed.  Here's what occurred:

  1. My app is a C# / ASP.NET 4.0 Web Forms app that uses Memberships & Roles.
  2. It has been developed on progressively newer versions of Visual Studio.  I'm currently using VS2013.
  3. The app's DB is running on my development machine with SQL Server 2014 Express.
  4. Prior to a DB Restore, there were 21 users.  Two were assigned to an "Administrator" role and the other 19 were assigned to two other non-admin roles.
  5. I backed up the DB with SQL Server Management Studio and then immediately restored it.
  6. Here's the strange part: When I ran my app in Debug mode in VStudio then everything worked normally.  BUT when I ran a brand new published version (ie. in wwwroot using IIS) then upon logging myself in, I had lost my Admin privileges!
  7. I once again ran it in VStudio, went to the User Manager and everything appeared to be normal, including my username being assigned as an Administrator.
  8. I went back to the deployed version and logged in with a special "temporary admin" account that gets created if something like this occurs and all administrators are locked out of the system.  It let me login and immediately took me to the User Manager.  Sure enough, all of the users had lost their Role assignments.

Any ideas on why this might be happening?  Is it possible that the two different versions of the app (one in development mode, one deployed on the same machine) would somehow be drawing their credentials from different locations?!  If so, how do I fix that???

Note: In VStudio I can see "ASPNETDB.MDF" in the App_Data folder.  I suspect that that this is where the VStudio version is getting its Roles & Users data.  Ultimately I want this data to ALWAYS be stored in the actual SQL Server DB and thus backed up & restored properly there.  How do I make this happen?

Robert


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>