Seperate User Database - General Discussions - General Discussions - Progress Community
 General Discussions

Seperate User Database

  • Seperate User Database
  • I need to develop two sites: examplea.com, and exampleb.com. There may be additional sites in the future as well. I would like everything on both to be completely separate, with one exception. The users should be shared across both (and eventually all) sites. I found a way to do this in 3.7, which was relatively simple. I just created the same user/role tables in a separate database, and made a few web.config changes. However, I would prefer to use 4.0. What would be the best way of sharing users across sites (domains) in 4.0? Let me know if you need any additional information. Thanks for any help!
  • 241991_providers1.png
    Hello Chris,

    You can create additional membership, role providers or just set the default member and role providers to point to the same database.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  • Thank you for your quick reply. I am a big fan of the Sitefinity forums!

    Since I don't need to change any functionality of the provider, it seems like the best way would be to just set the default member and role providers to point to the same database. How do I do that?

    I would have three databases. examplea.com would use dbA, exampleb.com would use dbB, and I want them both to use dbC for member and role providers. Where do make the changes to tell examplea.com to look at dbC for the providers, but dbA for everything else?
  • Bump.
  • Hello Chris,

    This database dbC should be Sitefinity's database. This means you should have installed a website in order to generate the database tables and users. The connection string of Sitefinity is stored inside

    App_Data/Sitefinity/Configuration/DataConfig.config

    The important part here is that both the websites should use the same SecurityConfig.config form the project you used to generate dbC tables. This SecurityConfig file contains validationKey and decriptionKey which are used to encode/decode users' password.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  • I created two sites using the Sitefinity Project Manager: testA and testB. Then I copied DataConfig.config and SecurityConfig.config from testA to testB. Now when I go to testB/sitefinity (or just testB for that matter) I get the following error:

    Invalid root node configured for pages. No root node with the name of "FrontendSiteMap".

    Is this the process that you had in mind?

  • Hi Chris,

    You could get this error if the project name has been changed. The default projectName is "/". If you change it you will get "Invalid root node configured for pages."

    You could check  App_Data\Sitefinity\Configuration\ProjectConfig.config file and projectName attribute. By default the attribute is not added to the config file, so you can try to add it manually. The project name is used as an identifier.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  • First, thank you very much for your help so far on this issue.

    I checked the ProjectConfig files for all of the test projects I have created, and they are all created with the project name attribute set to the name I used for the Project Name when I created the project using the sitefinity project manager. I have tried changing it to "/" and removing it completely, and I receive the same error regardless. (I re-saved the web.config file in between each change to make sure the app restarted because it seems like it reads those config files on startup) Any other ideas?

    Some other thoughts...
    When I created testA and testB, I went through the sitefinity startup wizard (first time you go to testA/sitefinity) where I selected a separate database for each. Then I copied the DataConfig.config and SecurityConfig.config from testA to testB. I wasn't sure if I should go though the startup wizard for testB or not, so I tried both ways.

    The first time I did not go through the startup wizard. I just created the project, copied over the DataConfig.config and SecurityConfig.config files, and clicked browse from the sitefinity project manager. This resulted in the following error:

    Violation of PRIMARY KEY constraint 'pk_sf_page_templates'. Cannot insert duplicate key in object 'dbo.sf_page_templates'. The duplicate key value is (e2b5894c-f3f8-49e8-bca7-acdfd5352e74).
    The statement has been terminated.

    So I assumed this was the wrong way. Which is when I tried going through the startup wizard then copying the config files. This resulted in the previously mentioned error:

    Invalid root node configured for pages. No root node with the name of "FrontendSiteMap".

  • Also, on the Primary Key issue - I removed the default templates then refreshed the page, and now it gives the following error:

    The type String cannot be constructed. You must configure the container to supply this value.

  • Just in case it helps anyone to resolve the "The type String cannot be constructed..." error:

    At the time of the exception, the container was:
      
      Resolving Telerik.Sitefinity.Modules.Pages.PageManager,OpenAccessDataProvider
      Resolving parameter "providerName" of constructor Telerik.Sitefinity.Modules.Pages.PageManager(System.String providerName, System.String transactionName)
        Resolving System.String,(none)
  • Hi Chris,

    Can you open a support request and give us link from where we can download both the projects and the single database you use. It looks like there is some mess with the configurations.


    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  • Hi Ivan,

    I will be happy to submit a support ticket. However, I really think if you follow these steps, you can reproduce this problem. (I am using 4.0.1030.0)

    1. Create SQLEXPRESS database called TestDB.
    2. Using Sitefinity Project Manager, click Create New Project.
    3. Enter TestA for the Project Name and click Next.
    4. Select Standard (trial) under Already activated licenses and click Next.
    5. Check "Open the administration of this project..." and click Finish.
    6. Proceed with normal administration startup procedure, where you select TestDB as the database.
    7. Repeat steps 2, 3, & 4 but this time enter TestB for the Project Name.
    8. DO NOT Check "Open the administration of this project..." and click Finish.
    9. Copy DataConfig.config and SecurityConfig.config from ~/App_Data/Sitefinity/Configuration/ under TestA to TestB.
    10. From the Project Manager, Select TestB and click Browse.

    Please try this and let me know if you cannot reproduce the results previously mentioned. If you cannot, then I will figure out which things I can strip out of my projects to get them under 20MB so that I can attach them with a support ticket.

    Thanks again for all of your help so far!
  • Hi Chris,

    Thanks for the steps. Using them you will definitely have problems, because when you copy the DataConfig.config  with Initialized setting set to true to a site, which is not initialized yet, you could get such kind of errors.

    Back to your initial request - you want to use one shared database for users in different web sites. Let say, that it will be the database created from the first site (SiteA). So, here are the steps (I added 10 and 12):

    1. Create SQLEXPRESS database called SiteA_DB.
    2. Using Sitefinity Project Manager, click Create New Project.
    3. Enter SiteA for the Project Name and click Next.
    4. Select Standard (trial) under Already activated licenses and click Next.
    5. Check "Open the administration of this project..." and click Finish.
    6. Proceed with normal administration startup procedure, where you select SiteA_DB as the database.
    7. Repeat steps 2, 3, & 4 but this time enter SiteB for the Project Name.
    8. DO NOT Check "Open the administration of this project..." and click Finish.
    9. Copy DataConfig.config and SecurityConfig.config from ~/App_Data/Sitefinity/Configuration/ under SiteA to SiteB.
    10. Open DataConfig: set initialized="Fase" and rename Sitefinity connectionString to Membership:
    <?xml version="1.0" encoding="utf-8"?>
    <dataConfig initialized="False" xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type" config:version="4.0.1098.0">
        <connectionStrings>
            <add connectionString="data source=local\SQLEXPRESS;Integrated Security=SSPI;initial catalog=SiteA_DB" providerName="System.Data.SqlClient" name="Membership" />
        </connectionStrings>
    </dataConfig>

    11. From the Project Manager, Select SiteB and click Browse.and proceed with the startup wizard.
    12. Log in and change default Role, Membership and Profile providers to use Membership connection string (add parameter connectionString = "Membership"). Alternatively, you can modify SecurityConfig.config in SiteB:
    <?xml version="1.0" encoding="utf-8"?>
    <securityConfig ...>
        ...
        <roleProviders>
            <add connectionString="Membership" name="Default" />
            <add connectionString="Membership" name="AppRoles" />
        </roleProviders>
        <profileProviders>
            <add connectionString="Membership" name="OpenAccessProfileProvider" />
        </profileProviders>
        <membershipProviders>
            <add connectionString="Membership" name="Default" />
        </membershipProviders>
    </securityConfig>

    Now, the SiteB should use the users and roles from SiteA.

    Please, let us know if you still have any problems.

    Regards,
    Vlad
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  • Thanks Vlad; that's exactly what I needed! If anyone is trying to share users across multiple sites, this thread will help you.