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.
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.
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.
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:
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.
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?
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...
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?
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.
Hi Javier,
Umbraco uses it's own asp.net based Membership provider defined in your sites web.config. You'll find something like:
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
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
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:
Regards
Jesper Hauge
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.
Do I need to write any code for the login button?
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
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
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.
No luck.
Thanks Michael, but I don't know how to do that :(.
Any other ideas?
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
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
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
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:
What do you think? Connection problem to the database?
Please help!!! :)
Regards and thanks for any idea.
Javier
Hi, Javier!
Have you managed to resolve your problem? I've got the same one...
Best regards
is working on a reply...