Creating Our Custom MembershipUser Class - Creating a Custom Membership Provider and Membership User utilizing a Data Set Table Adapter - Step 7

We are now ready to create our custom MembershipUser Class. First create a new class and add it to your ProviderClasses directory.

Add "Inherits MembershipUser."

ChangePassword in MembershipUser versus MembershipProvider

The system automatically calls the MembershipProvider "ChangePassword" method first, so your MembershipProvider method will never be implemented unless you call it in this method as below:

#Region "ChangePassword Functionality"
        ' http://devauthority.com/blogs/jwooley/archive/2006/08/25/2208.aspx
        ' system automatically calls this one first, since the membershipuser has its 
        ' own method, use this to call the membershipprovider changepassword...
        Public Overrides Function ChangePassword(ByVal oldPassword As String, _
        ByVal newPassword As String) As Boolean
            ' Validate the old password for user 
            If Membership.Provider.ValidateUser(Me.UserName, oldPassword) Then
                Return Membership.Provider.ChangePassword(Me.UserName, _
                oldPassword, newPassword)
            Else ' Incorrect username/password combination.
                Return False
            End If
        End Function

#End Region
Read the complete article here...

1 Comment

Comments have been disabled for this content.