How do I create a Custom MembershipProvider?
Posted on 2006-11-05
I have read postings all over the Internet including the one that was supposedly solved on your website titled "ASP.Net 2.0 - Adding extra information to the CreateUserWizard". Unfortuantely the link to the solution that was accepted no longer works and/or requires special access (it points to a Beta site).
I simply want to create a custom class that inherits from the SqlMembershipProvider class and override the CreateUser method so it accepts more arguments like FirstName, LastName, Address1, Address2, City, State, Zip, Phone etc.
I do not with to use the profile table at this stage. I have an existing database structure setup and I need to allow users to register for my site using my Custom provider, store the basic info in Microsoft's default aspnet_membership_user table and then execute another stored procedure that puts the remaining custom fields in my own table.
My problem is that I want to use pretty much all of the existing functionality that the SqlMembershipProvider has but just modify that one method (CreateUser). When I try to do that I get errors telling me that either some library is missing, protected or inaccessible due to security reasons (i.e. SecUtil class is declared internal) or a variety of other irritations. I don't know what to do. I managed to get the source code for the SQLMembershipProvider from Microsoft's website. It references a bunch of other libraries, two of which (SR and SecUtil) are giving me a really hard time b/c even though I have the source for them and try to include them in my project, it still seems like the compiler doesn't even know they are there!
UPDATE: I have actually made progress since posting this. I am now able to use my own provider (almost). I at least have the page calling my custom provider b/c I am getting an error when I try to create the new user and the error is found in my custom provider code but at least it's actually USING my custom provider.
The error is that it seems as though the Initialize method is not getting the connectionStringName passed in and therefore my exception handler is flagging it.