Sitecore separate users from CORE database – move membership provider to separate database

Since Sitecore 6, Sitecore have had the .NET membership tables in the CORE database. And since every instance of Sitecore needs access to the CORE database, it might seem as a good place to store them.

But separating the users from the CORE database will make upgrades easier, as you can have 2 instances of Sitecore running without disturbing user access. You also have more scalability options when separating the two.

The separation is easy:

STEP 1: MAKE A COPY OF THE CORE DATABASE

Get yourself a copy of your CORE database. Name the new database something user-membership-like, for example “Users“.

Never mind the Sitecore tables in the newly copied database. Unless you are in need of disk space, you can leave them. They will never be used.

STEP 2: ADD A CONNECTION STRING TO THE CONNECTIONSTRINGS.CONFIG FILE

In /App_Config/ConnectionStrings.Config, add a new connection string to your “Users” database:

<add name="Users" 
   connectionString="user id=*****;password=*****;Data Source=*****;Database=Users" />

STEP 3: MODIFY WEB.CONFIG

In the web.config, find the “membership“, “rolemanager” and “profile” sections, and modify the “connectionStringName” property from “core” to “Users“:

<membership defaultProvider="sitecore" hashAlgorithmType="SHA1">
  <providers>
    <clear />
    <add name="sitecore" type="Sitecore.Security.SitecoreMembershipProvider, Sitecore.Kernel" realProviderName="sql" providerWildcard="%" raiseEvents="true" />
    <add name="sql" type="System.Web.Security.SqlMembershipProvider" connectionStringName="Users" applicationName="sitecore" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" />
    <add name="switcher" type="Sitecore.Security.SwitchingMembershipProvider, Sitecore.Kernel" applicationName="sitecore" mappings="switchingProviders/membership" />
  </providers>
</membership>
<roleManager defaultProvider="sitecore" enabled="true">
  <providers>
    <clear />
    <add name="sitecore" type="Sitecore.Security.SitecoreRoleProvider, Sitecore.Kernel" realProviderName="sql" raiseEvents="true" />
    <add name="sql" type="System.Web.Security.SqlRoleProvider" connectionStringName="Users" applicationName="sitecore" />
    <add name="switcher" type="Sitecore.Security.SwitchingRoleProvider, Sitecore.Kernel" applicationName="sitecore" mappings="switchingProviders/roleManager" />
  </providers>
</roleManager>
<profile defaultProvider="sql" enabled="true" inherits="Sitecore.Security.UserProfile, Sitecore.Kernel">
  <providers>
    <clear />
    <add name="sql" type="System.Web.Profile.SqlProfileProvider" connectionStringName="Users" applicationName="sitecore" />
    <add name="switcher" type="Sitecore.Security.SwitchingProfileProvider, Sitecore.Kernel" applicationName="sitecore" mappings="switchingProviders/profile" />
  </providers>
  <properties>
    <clear />
    <add type="System.String" name="SC_UserData" />
  </properties>
</profile>

MORE TO READ:

 

Advertisements

About briancaos

Developer at Pentia A/S since 2003. Have developed Web Applications using Sitecore Since Sitecore 4.1.
This entry was posted in Sitecore 6, Sitecore 7, Sitecore 8 and tagged , . Bookmark the permalink.

3 Responses to Sitecore separate users from CORE database – move membership provider to separate database

  1. Goran says:

    Smart, very nice :-)

  2. dru says:

    Good idea. In a scenario of hosting in multiple data centers around the world, I often see non-replicated Core databases, one per data center. This causes issues with users synchronization. Would a separate user database like this be easier to replicate across data centers?

  3. briancaos says:

    Yes thatt’s a scenario that I had not thought of. The membership databases are easily replicated as the caching towards these are very sparse. Good point Dru.

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 )

Google+ photo

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

Connecting to %s