Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • monster 13 posts 33 karma points
    Sep 22, 2010 @ 09:24
    monster
    0

    User umbraco role provider in separate application

    Hi

    I have an existing website application, I would like to start using umbraco to create new websites. But i would like all my old websites to use the same user store - provided by my umbraco installation.

    So far, I have successfully shared the member sessions across the appplications, a member can log into my umbraco website and the member is also logged into my second app.

    Now I would like to access the roles for the member as they are set in my umbraco installation.

    so, User.Identity.Name, gives me the correct member name as logged into my umbraco front end. trying to check the user role i get the following,

    'User.IsInRole("Admin")' threw an exception of type 'System.TypeInitializationException'

    the inner exception looks like such:
    The type initializer for 'umbraco.BusinessLogic.Application' threw an exception. System.Exception {System.TypeInitializationException}
    the above exception lies here:
    SqlHelper 'umbraco.BusinessLogic.Application.SqlHelper' threw an exception of type 'System.TypeInitializationException' umbraco.DataLayer.ISqlHelper {System.TypeInitializationException}
    So this is my issue. What could be causing this exception, I must just be missing something...
    Here are other details:
    Version 4.5.x
    Framework 4...everything
    Default app pool 4.0
    IIS 7
    My webconfig for my second app looks like this, these parts taken from my umbraco application:
        <membership defaultProvider="UmbracoMembershipProvider" userIsOnlineTimeWindow="15">
          <providers>
            <clear />
            <add name="UmbracoMembershipProvider" type="umbraco.providers.members.UmbracoMembershipProvider" applicationName="umbraco" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" defaultMemberTypeAlias="WebsiteUser" passwordFormat="Hashed" />
          </providers>
        </membership>
        <!-- added by NH to support membership providers in access layer -->
        <roleManager enabled="true" defaultProvider="UmbracoRoleProvider">
          <providers>
            <clear />
            <add name="UmbracoRoleProvider" type="umbraco.providers.members.UmbracoRoleProvider" />
          </providers>
        </roleManager>
    and i have added the appsetting section from my umbraco installation
      <appSettings>
        <add key="umbracoDbDSN" value="my working connection string...." />
    ....
    my second app has the following dll references:
    businesslogic.dll
    cms.dll
    interfaces.dll
    Microsoft.ApplicationBlocks.Data.dll
    umbraco.Datalayer.dll
    umbraco.dll
    umbraco.Linq.Core.dll
    umbraco.macroRenderings.dll
    umbraco.providers.dll
    i dont think I have missed anything
    please help, this i think would be a very useful ability for many ppl wanting to use umbraco without having to move websites into umbraco, but rather just leveraging off it's user store.
    thanks a mil in advance

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Sep 22, 2010 @ 10:28
    Michael Latouche
    0

    Hi monster,

    I don't directly know what the problem might be, but can you maybe try with Roles.IsUserInRole( User.Identity.Name, "Admin") and see if you get the same kind of error? Maybe it will then help getting a view on the problem.

    Cheers,

    Michael.

  • monster 13 posts 33 karma points
    Sep 22, 2010 @ 11:10
    monster
    0

    Hi Mike

     

    Thanks for response.

     

    It must just been dll confusion or something i did wrong. I removed all umbraco references from my project, added only umbraco.providers, which in turn added the other dependancy dlls.

    Now i get:

    User.IsInRole("Admin") true bool

    Thanks for your time, I knew it was just something random like that.

  • monster 13 posts 33 karma points
    Sep 23, 2010 @ 08:29
    monster
    0

    So I managed to recreate the error....remember this is a separate application with it's own webconfig etc

     

    As soon as I add the umbraco.dll to the project and then it crashes my IIS..

    running any code that is within umbraco.cms.businesslogic namespace.

     

    so 

    using umbraco.cms.businesslogic.member;

    Member m = Member.GetCurrentMember();

    works perfectly until I reference umbraco.dll.

    is there possible some configuration setting that I am missing that the umbraco.dll is dependant on.

     

    really just want to reference the umbraco dlls in my separate app, and use them. this article http://our.umbraco.org/wiki/how-tos/getting-started-with-umbraco-whats-next-after-you-install/setting-up-your-project-in-visual-studio says we should be able to do that easily - but I am wondering if this is not fully possible.

    If i change my appsettings here:

    <add key="umbracoPath" value="/Bin" />

    I get different results...the above breaks IIS, just "/" my member comes back as null. No umbraco.dll in project i get the full member.

     

    any ideas? 

     

    Thanks

  • monster 13 posts 33 karma points
    Sep 23, 2010 @ 09:35
    monster
    0

    I realise I am trying to reinvent the wheel, I will just use the umbraco webservices to that which i need. thanks again.

Please Sign in or register to post replies

Write your reply to:

Draft