I'm trying to use a custom membership provider to authenticate users (via webservice) on login but can't seem to get it to work.
From searching around the great big interweb here is what I've got so far:
- I'm extending umbraco.providers.members.UmbracoMembershipProvider in CustomMemberShipProvider.cs and overriding public bool ValidateUser(string username, string password) - witch for testing purposes always return true
- Pointing to the new Membership Provider in web.config (CustomMemberShipProvider.cs) . I have simply modified the type of UmbracoMembershipProvider from umbraco.providers.members.UmbracoMembershipProvider to myNamespace.CustomMemberShipProvider.
- Added a asp:login component to a new usercontrol and added that usercontrole to a page called "login" in umbraco
- Changed the "public access" to "Role based protection" on a page in umbraco and added the role "MemberGroupsTest"
- Added defaultMemberTypeAlias="MemberGroupsTest" to UmbracoMembershipProvider in webconfig.
A quick question:
- On my login page in the Authenticate event (click on login button) how do I Authenticate the user? Currently this is what I've got:
I don't think you need that extra piece of authentication code, it's taken care of by the membership provider, all that needs to be done is overriding the ValidateUser() function (in your custom membership provider implementation) to check whether username/password combo is correct. It's the whole point of setting the provider via the web.config.
Role 'MemberGroupsTest' has a different meaning from type 'MemberGroupsTest', unless you've named both the same? Each member is of a specific type, and if you've specified MemberGroupsTest as default member type in web.config, all members who will be registered using the CreateUserWizard (or created via admin backend) will be of this type.
If you want role based protection, you'll have to make sure to have at least a member of type 'MemberGroupsTest' who has at least the role 'MemberGroupsTest', otherwise member will never get to the protected page.
Thanks for your quick reply - it seems to be working now:-) My final goal is to combine a Custom MemberShipProvider and a Custom RoleProvider. From the information I can find on the subject it appears that I need to override some methods in UmbracoRoleProvider ... something like this:
namespace WebGUI
{
public class CustomRoleProvider: umbraco.providers.members.UmbracoRoleProvider
{
public override bool IsUserInRole(string username, string roleName)
{
//TODO check if user has role using CROWD
return true;
}
}
}
Am I one the right track? Any potential pitfalls? :-)
sorry to insert this in your thread, but I'm trying the same and have a question for you...should you be extending umbraco.providers.members.UmbracoMembershipProvider...or deriving from System.Web.Security.MembershipProvider base class? I tried the other and it wouldn't work, you succeded with UmbracoMembershipProvider, is that the best practice then please?
Custom membership provider / login
Hi:-)
I'm trying to use a custom membership provider to authenticate users (via webservice) on login but can't seem to get it to work.
From searching around the great big interweb here is what I've got so far:
- I'm extending umbraco.providers.members.UmbracoMembershipProvider in CustomMemberShipProvider.cs and overriding public bool ValidateUser(string username, string password) - witch for testing purposes always return true
- Pointing to the new Membership Provider in web.config (CustomMemberShipProvider.cs) . I have simply modified the type of UmbracoMembershipProvider from umbraco.providers.members.UmbracoMembershipProvider to myNamespace.CustomMemberShipProvider.
- Added a asp:login component to a new usercontrol and added that usercontrole to a page called "login" in umbraco
- Changed the "public access" to "Role based protection" on a page in umbraco and added the role "MemberGroupsTest"
- Added defaultMemberTypeAlias="MemberGroupsTest" to UmbracoMembershipProvider in webconfig.
A quick question:
- On my login page in the Authenticate event (click on login button) how do I Authenticate the user? Currently this is what I've got:
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { CustomMemberShipProvider customMemberShipProvider = new CustomMemberShipProvider(); e.Authenticated = customMemberShipProvider.ValidateUser(Login1.UserName, Login1.Password); }Hoping someone can point me in the right direction :-)
Oh, btw... using Umbraco 4 :-)
Hi trendt,
I don't think you need that extra piece of authentication code, it's taken care of by the membership provider, all that needs to be done is overriding the ValidateUser() function (in your custom membership provider implementation) to check whether username/password combo is correct. It's the whole point of setting the provider via the web.config.
Role 'MemberGroupsTest' has a different meaning from type 'MemberGroupsTest', unless you've named both the same? Each member is of a specific type, and if you've specified MemberGroupsTest as default member type in web.config, all members who will be registered using the CreateUserWizard (or created via admin backend) will be of this type.
If you want role based protection, you'll have to make sure to have at least a member of type 'MemberGroupsTest' who has at least the role 'MemberGroupsTest', otherwise member will never get to the protected page.
Feel free to ask more questions if still unclear.
Hope this helps.
Regards,
/Dirk
Hi Dirk
Thanks for your quick reply - it seems to be working now:-) My final goal is to combine a Custom MemberShipProvider and a Custom RoleProvider. From the information I can find on the subject it appears that I need to override some methods in UmbracoRoleProvider ... something like this:
namespace WebGUI { public class CustomRoleProvider: umbraco.providers.members.UmbracoRoleProvider { public override bool IsUserInRole(string username, string roleName) { //TODO check if user has role using CROWD return true; } } }Am I one the right track? Any potential pitfalls? :-)
Kind Regards
Mads
Hi trendt,
sorry to insert this in your thread, but I'm trying the same and have a question for you...should you be extending umbraco.providers.members.UmbracoMembershipProvider...or deriving from System.Web.Security.MembershipProvider base class? I tried the other and it wouldn't work, you succeded with UmbracoMembershipProvider, is that the best practice then please?
@Trendt / @Stc
Did you manage to get your members role provider working?
I'm too trying to get it running, but struggling.
Peter
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.