views:

754

answers:

1

I created my own database schema to store user information.

CREATE TABLE [dbo].[MyCustomMembership_Users](
[UserId] [uniqueidentifier] NOT NULL,
[UserName] [nvarchar](256) NOT NULL,
[LoweredUserName] [nvarchar](256) NOT NULL,
[MobileAlias] [nvarchar](16) NULL,
[IsAnonymous] [bit] NOT NULL,
[LastActivityDate] [datetime] NOT NULL,
[FirstName] [nvarchar](256) NULL,
[MiddleName] [nvarchar](256) NULL,
[LastName] [nvarchar](256) NULL)

Then I extend the MembershipProvider and MembershipUser and create the overriden methods. How can I pass the additional information when I call the CreateUser Method? I am aware I can use profile for this but I also want to be able to do it this way and if it comes out to be too complicated that I will go the profile route.

public class MyMembershipProvider : MembershipProvider
{
  public override MembershipUser CreateUser(string username, string password, 
string email, string passwordQuestion, string passwordAnswer, bool isApproved, 
object providerUserKey, out MembershipCreateStatus status)
    {
        throw new NotImplementedException();
    }
}
public class MyMembershipUser : MembershipUser
{
    private string _firstName;
    public string FirstName { get { return _firstName; } set { _firstName = value; } }

    private string _middleName;
    public string MiddleName { get { return _middleName; } set { _middleName = value; } }

    private string _lastName;
    public string LastName { get { return _lastName; } set { _lastName = value; } }

    public MyMembershipUser() : base()
    {
        this.FirstName = _firstName;
        this.MiddleName = _middleName;
        this.LastName = _lastName;
    }
}
+2  A: 

I think you'll find the answer at the end of this page : http://msdn.microsoft.com/en-us/library/ms366730(VS.80).aspx

I found the answer by looking in the "related" column on the right side of the page :)

Matthieu