I am trying to create a custom membership provider for my front end users as theire logins are all stored in an external DB.
This is not something I've done before, umbraco or otherwise and I am struggling.
My requirements:
Pages can be protected from the backend
logged in users have access to all the these pages (I don't care about roles)
Not too much to ask really?! (then why am I struggling so much?)
So far I have created a class and inherited from MembershipProvider and because it crashes if I don't I have created a custom role provider.
I have overriden ValidateUser (I have tested this with the login control and it returns the correct value) and I store a userId and username in a session.
I have also overriden the GetUser functions, but all I am doing in them is using my stored ID and returning a membershipuser with just a userid and name:
public override MembershipUser GetUser(object unused, bool userIsOnline)
{
if (HttpContext.Current.Session[CurrentUserIdSessionName] != null)
{
MembershipUser user = new MembershipUser(
"myProvider",
HttpContext.Current.Session[CurrentUserNameSessionName].ToString(),
HttpContext.Current.Session[CurrentUserIdSessionName],
"",
"",
"",
true,
false,
DateTime.Now,
DateTime.Now,
DateTime.Now,
DateTime.Now,
DateTime.Now);
return user;
}
return null;
}
The problem occurs when I try and protect pages.
As I don't have roles as such I am just setting the page as protected and not assigning a role (maybe this is my problem) but when I log in it accepts my login details returns true then bounces me back to the login again.
In my role provider I can see it is calling the "GetRolesForUser" function, which I am returning
Custom Membership Provider Help!
Hi!
I am trying to create a custom membership provider for my front end users as theire logins are all stored in an external DB.
This is not something I've done before, umbraco or otherwise and I am struggling.
My requirements:
The problem occurs when I try and protect pages.
I'm assuming it will just take it as the user is just in the role?
I know this is very convoluted, but I only want something simple and I'm 99% sure I'm doing it wrong.
Can someone help?
Bex
is working on a reply...