There are times it can be convenient to have users defined as pages in EPiServer. There are several ways of archiving this. This approaches uses a DDS table with user data and attach to the publish events on the pages.
The code bellow assumes you are using some sort of strong typed pages and those pages you want to be considered users have to implement IAmUser
bool EnsureUserData(UserData user);
bool UpdateUser(MembershipUser user);
These 2 methods will be called when a page is published, and when a user is saved thru the membership api.
This code attach to the publish event and checks if the current pages that are being saved have IAmUser and if it is It calls the EnsureUserData method,
EPiServer.DataFactory.Instance.PublishedPage += new EPiServer.PageEventHandler(Instance_PublishedPage);
I have experienced that if you change the signature of your class (added properties) I have problem with retrieving those new properties from the old data that are already stored. Therefore I usually makes myself a delete all function that removes the whole store for my class., This I do in development of course :)
Then I need to make myself a Membership provider. The important function is the validate user method
if (UserData.CreatePasswordHash(password, user.HashedPasswordSalt).Equals(user.HashedPassword))
On the page that implements IAmUser I’m using a custom property that is username. This property will display if the username is already taken, and will show the pages that are using the same username. This is information that is easy to show in the page tree also as shown in PageIcon method on the UserPageType class above
What we have now is a membership provider that are based on pages in EPiServer. We don’t have a role provider for these users, but as shown in my blog post about multiplexing providers that is not necessarily. Since we can use the normal one.