Copied to clipboard

Flag this post as spam?

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


  • javier 59 posts 79 karma points
    May 04, 2011 @ 18:57
    javier
    0

    Share umbraco DB for membership authentification

     

    Hi,

    I really need help. I need to use an existing umbraco membership database to login and authentify from another non-umbraco site (intranet app). 

    I don't want to override the actual provider, just want to reuse the same funcionality but from another site. I think the idea is modify web.config, add some umbraco dll, but I don't know which ones.

    Any pointers on where to start looking would be greatly appreciated.

     

  • Jesper Hauge 298 posts 487 karma points c-trib
    May 04, 2011 @ 22:33
    Jesper Hauge
    0

    Hi Javier,

    Umbraco uses it's own asp.net based Membership provider defined in your sites web.config. You'll find something like:

    <add name="UmbracoMembershipProvider" 
             type="umbraco.providers.members.UmbracoMembershipProvider" 
             enablePasswordRetrieval="false" 
             enablePasswordReset="false" 
             requiresQuestionAndAnswer="false" 
             defaultMemberTypeAlias="Another Type" 
             passwordFormat="Hashed" />

    So you'll need to use the same membership provider in your intranet app. The provider is located in umbraco.providers.dll, so you'll need to add this dll to the bin folder of your project also. As you can see there's no connection string defined for the provider, so I'm guessing the provider reads the connection string from the umbracoDbDsn appSettings key. (Ordinarily you'd get the connection string from the connectionStrings section, but Umbraco is a bit odd around this)

    If you need asp.net role and profile functionality you'll need to copy the corresponding definitions from web.config also. But when all this is spinning you should be able to use the ordinary asp.net membership controls as well as classes and methods from the API.

    Regards
    Jesper Hauge

  • javier 59 posts 79 karma points
    May 04, 2011 @ 22:57
    javier
    0

    Hi Jesper and thanks for the reply.

    I copy the dll to the bin folder. Add the reference (project - add reference) to the asp app. Is there anything alse I have to put in the code to make reference to the dll? Imports or something?

    In the web.config I have the correct provider as you mention, only adding  connectionStringName="ConnUmbraco", so it will read that connection. The connection is working because I test making a query to CMSMEMBER and it retrieve it correctly.

    In the form I have <asp:Login ID="Login1" runat="server"></asp:Login> but it doesn't authentify. No error, just shows the login screen again.

    Also I put <asp:LoginStatus ID="MasterLoginStatus" runat="server" /> to see the status.

    Thanks for your help.

    Regards

    Javier

     

  • Jesper Hauge 298 posts 487 karma points c-trib
    May 04, 2011 @ 23:14
    Jesper Hauge
    0

    Hi Javier,

    Just did a little more digging. Turns out the membership provider in some methods actually call methods in umbraco.cms.businesslogic.member and CMSNode.SqlHelper so you'll also need to add cms.dll, and businesslogic.dll from your Umbraco site to your intranet project.

    Also I'm now sure, that you'll need to add an appSettings umbracoDbDSN key to your web.config, since the methods in CMSNode.SqlHelper relies on this appsettings key to function, so you'll need to add the following appsettings key to the web.config file of your intranet project:

    <add key="umbracoDbDSN" value="connection_string_for_your_umbraco_db" />

    Regards
    Jesper Hauge

  • javier 59 posts 79 karma points
    May 04, 2011 @ 23:30
    javier
    0

    Is this the correct way?

    <connectionStrings>

    <add name="Conn" connectionString="Dsn=ReportSys" providerName="System.Data.Odbc"/>

    <add name="ConnUmbraco" connectionString="Dsn=Umbraco" providerName="System.Data.Odbc"/>

    </connectionStrings>

    <appSettings><add key="umbracoDbDSN" value="ConnUmbraco" />appSettings>

    If that is correct, then no luck. I correctly added both dlls.

     

     

  • javier 59 posts 79 karma points
    May 04, 2011 @ 23:37
    javier
    0

    Do I need to write any code for the login button?

  • Jesper Hauge 298 posts 487 karma points c-trib
    May 05, 2011 @ 08:21
    Jesper Hauge
    0

    You need to actually write the connection string in the UmbracoDbDSN key. Also I don't think Umbraco is able to use a ODBC connection so you'll probably have to find out how your ODBC connection connects to the database, and create a connection string connection directly to the sql server.

    Try using the UmbracoDbDSN connection string from your websites web.config.

    Once you've got the right connection you should be able to use the login control without any special code.

    Regards
    Jesper Hauge

     

  • javier 59 posts 79 karma points
    May 05, 2011 @ 15:09
    javier
    0

    Hi Jesper.

    I followed your instructions and have the connection as it is in my umbraco site. Just same result.

    Is strange that when entering any username/password and pressing Login, nothing happends. No errors, no updated screen. The fields username and password keeps the information. Looks like the login button has no code on it.Is there a way I can test if the button is doing something?

    Thanks a lot.

    Regards

    Javier

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    May 05, 2011 @ 16:08
    Michael Latouche
    0

    Hi Javier,

    I guess you can register an event handler to one of the locgin control events, just to check that you do at least a post back to the server when pressing the button...

    Cheers,

    Michael.

  • javier 59 posts 79 karma points
    May 06, 2011 @ 00:39
    javier
    0

    No luck.

    Thanks Michael, but I don't know how to do that :(.

    Any other ideas?

  • javier 59 posts 79 karma points
    May 08, 2011 @ 23:32
    javier
    0

    Hi.

    I've start all over again with a new empty project. Did all again. Still can't connect, but now, at least, I receive an error message.

    It says:

    Object reference not set to an instance of an object

       umbraco.cms.businesslogic.member.Member.GetMemberFromLoginAndEncodedPassword(String loginName, String password) +185
       umbraco.providers.members.UmbracoMembershipProvider.ValidateUser(String username, String password) +147
       System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e) +74
       System.Web.UI.WebControls.Login.AttemptLogin() +151
       System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +123
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +69
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +28
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2980

    Any help?
    Thanks a lot

    Regards

     Javier

  • Jesper Hauge 298 posts 487 karma points c-trib
    May 09, 2011 @ 09:34
    Jesper Hauge
    0

    Hi Javier,

     

    Looks like you've managed to nail the .config setup now, since you're getting an error from the Umbraco dll's.

    I'm not sure why you're getting this error, do you have the following dll's in you intranet apps bin folder:

    businesslogic.dll
    cms.dll
    interfaces.dll
    umbraco.providers.dll

    Regards
    Jesper Hauge

  • javier 59 posts 79 karma points
    May 09, 2011 @ 16:19
    javier
    0

    Hi Jesper.

    Yes, I have those dll's and more than that. I copy all the bin folder :) from the umbraco website into the intranet (also reference them in asp.net project). Any idea on how to proced now to isolate the problem?

    Thanks
    Regards

    Javier

  • javier 59 posts 79 karma points
    May 11, 2011 @ 14:54
    javier
    0

     

    I still have the problem, and this is some testing results:

    lblLastMsg.Text = umbraco.cms.businesslogic.member.Member.UmbracoMemberProviderName

    returns a correct value. This means that the reference is working correctly.

    Using the function:

    lblLastMsg.Text = umbraco.cms.businesslogic.member.Member.IsMember("anyuser")

    returns:

     

    [NullReferenceException: Object reference not set to an instance of an object.]
       umbraco.cms.businesslogic.member.Member.IsMember(String loginName)

     

    What do you think? Connection problem to the database? 

    Please help!!! :)

    Regards and thanks for any idea.

    Javier

     

  • Natalia Langa 12 posts 31 karma points
    May 31, 2012 @ 10:49
    Natalia Langa
    0

    Hi, Javier!

    Have you managed to resolve your problem? I've got the same one...

    Best regards

Please Sign in or register to post replies

Write your reply to:

Draft