Customizing the MembershipProvider without starting from scrap

I

ibiza

Hi all,

I'd like to write my own MembershipProvider for my ASP.NET 2.0 web
application but I fear all the code to write. Basically, I only want to
add a few functionalities like being able to change a username (which
the standard MembershipProvider does not allow), add some fields to a
user (e.g.: "Area", a few others...) and some other functions I may not
think of right now.

How could I write my own MembershipProvider while still enjoying the
standard built-in functionalities like password salting and hashing and
all the advanced functions that I do not want to re-code? Is there a
simple way to add functionalities rather than modifying the whole
package?

Thank you very much for your help,

ibiza
 
G

Guest

Ibiza,
You could try creating a new MembershipProviderEx class that derives from
the existing class and see if you can add your desired functionality that
way, without having to "reinvent the wheel". Otherwise, they provide a sample
Class template and its not that difficult to write a new one.

Here's an example of two I did for the SQLite database:

http://www.eggheadcafe.com/articles/20051119.asp


Peter
 
I

ibiza

wow, I looked at your code and it seems pretty complete...too much for
me! :\

unfortunately, I tried just the following to check the minimum I had to
code :

public sealed class test : MembershipProvider {}

and I have something like 25+ functions to override, from createuser to
changepassword, lockuser and more...isn't there a way to only *add* the
few functions we want more on the standard MembershipProvider? I'm kind
of discouraged.. :S

thanks a lot

ibiza
 
G

Guest

You don't have to override every method. Or if you want, you can do so and in
the method body just call
base.MethodName();
and you are done.
Peter
 
I

ibiza

That's a great idea! I'll try it and let you know if it works or I
encounter any problem :)

Thanks!

ibiza
 
I

ibiza

Hi,

ok, first problem...

I use VB.NET to code, I hope it does not bother you (too much)!

But here is what I tried:

public class test : Inherits MembershipProvider
public overloads overrides function ChangePassword(username as
string, oldPassword as string, newPassword as string) as boolean
return mybase.ChangePassword(username, oldPassword,
newPassword)
end function
end class

and here's what it throws : "MyBase cannot be used with method 'Public
MustOverride Function ChangePassword(username as string, oldPassword as
string, newPassword as string' As Boolean because it is declared
'MustOverride'."

So I guess I HAVE to override every single 'MustOverride' function and
can't just call the base function...am I correct? :S

thanks, your help is greatly appreciated

Bruno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top