Tim

Footprints in the snow of a warped mind

Dual records in the ASP.Net authentication table

Where to find me

Flickr Icon  Twitter Icon  Linked In Icon  FaceBook Icon  Windows Live Alerts Butterfly  RSS 2.0 

Business Protection by Crisis Cover
DDD South West

Tag Cloud

AJAX (4) Analysis (3) ASP (6) ASP.Net (59) Error Reporting (4) Web Service (2) WSDL (1) Atlas (2) Born In The Barn (1) Business (87) Business Start-up Advice (30) Client (17) Expanding Your Business (21) Recruitment (1) C# (21) Canoeing (4) Canoe Racing (5) Cheshire Ring Race (5) Racing (2) Training (4) CIMA (1) Cisco (1) 7970G (1) CMS (1) Code Management (1) Cohorts (4) Commerce4Umbraco (1) Content (1) Content Management (1) Content Management System (1) CSS (3) dasBlog (5) DDD (1) Design (10) Icons (1) Development (24) eCommerce (10) Employment (2) General (39) Christmas (6) Fun and Games (11) Internet (22) Random (46) RX-8 (8) Hacking (1) Helpful Script (3) Home Cinema (2) Hosting (2) HTML (1) IIS (11) iPhone (1) JavaScript (4) jQuery (1) Marketing (6) Email (1) Multipack (1) MVC (1) Networking (3) Nintendo (1) Nuget (1) OS Commerce (1) Payment (1) Photography (1) PHP (1) PowerShell (2) Press Release (1) Productivity (3) Random Thought (1) Security (2) SEO (5) Server Maintenance (6) Server Management (11) Social Media (2) Social Networking (3) Experiment (1) Software (10) Office (5) Visual Studio (14) Windows (4) Vista (1) SQL (8) SQL Server (19) Statistics (2) Stored Procedure (1) Sublime Text 2 (1) TeaCommerce (1) Testing (2) The Site Doctor (127) Turnover Challenge (1) Twitter (3) uCommerce (11) Umbraco (30) 2009 (1) 2011 (1) Web Development (66) WebDD (33) Wii (1) XSLT (1)

Blog Archive

Search

<December 2006>
SunMonTueWedThuFriSat
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

Recent Comments

Blog Archive

Various Links

Blogs I Read

[Feed] Google Blog
Official Google Webmaster Central Blog
[Feed] Matt Cutts
Gadgets, Google, and SEO
[Feed] Ol' Deano's Blog
My mate Dean's blog on my space, equally as random as mine but not off on as much of a tangent!
[Feed] Sam's Blog
Sam is one of my younger brothers studying Product Design and Manufacture at Loughborough, this is his blog :) Enjoy!

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

newtelligence dasBlog 2.2.8279.16125

Send mail to the author(s) Email Me (Tim Gaunt)

© 2012 Tim Gaunt.

Sign In

# Friday, December 15, 2006

Dual records in the ASP.Net authentication table

Friday, December 15, 2006 2:38:10 PM (GMT Standard Time, UTC+00:00)

I recently updated one of our sites to use a shared authentication database to save on the maintenance, but in doing so I messed something up and couldn’t work out why I was getting dual records of the user. To summarise what I’d done, I had updated the applicationName value from “/” to “SomeName” and then updated the values in the database to reflect these changes.

In addition to having duplicate records for the users, the LastActivityDate was only being altered on login and subsequent page requests were not being noted which was a problem as this system requires this data. I did look into alternative methods around this until I realised that one of dates for the user was actually being updated –just not the roles/membership one!

There are a number of posts discussing doing this pre-userbase which were about as useful as a chocolate fireman. I finally realised that I’d not added the provider node for the profiles which meant it was not only reverting to the old connection string named “LocalSqlServer” but it was also assigning “/” as the application name. After updating this node all’s fine and dandy again.

For future reference, you need to override 3 web.config settings to ensure your application is referencing the correct database and within each one add the <clear /> node otherwise your application is likely to inherit from the machine.config (I’d got that one!!):

Web.Config Settings

<membership defaultProvider="YourMembershipProvider">
    <providers>
        <clear />
        <add name="YourMembershipProvider" 
         applicationName="YourApplicationName" 
         connectionStringName="YourASPNetSqlServerConn"
         type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
    </providers>
</membership>

<roleManager>
    <providers>
        <clear/>
        <add name="YourRoleProvider" 
         connectionStringName="YourASPNetSqlServerConn" 
         applicationName="YourApplicationName" 
         type="System.Web.Security.SqlRoleProvider" />
    </providers>
</roleManager>

<profile enabled="true" defaultProvider="YourProfileProvider">
  <providers>
    <clear />
    <add name="YourProfileProvider"
         connectionStringName="YourASPNetSqlServerConn"
         applicationName="YourApplicationName"
         type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </providers>
</profile>
 

Don't forget to follow me on Twitter.