Solved

.NET Add Parameters to Membership CreateUser function

Posted on 2009-07-03
1
838 Views
Last Modified: 2012-05-07
I'm creating login functionality for my website using an access database.  Everything works until I try to add customized parameters such as first name, last name, phone number, etc.  I realized that all I really need to get everything to work is to add the new parameters to the CreateUser function in the AccessMembershipProvider.cs file.  However, I can't find where this function is called.  Where fild containing the code that calls CreateUser when the user hits the "Create User" button in the membership form?  I put the first line of the function below, with the parameters that I'm trying to add commented out.
Thanks!
public override MembershipUser CreateUser(string username,
                                           string password,
                                 //          string firstname,
                                 //          string lastname,
                                 //          string phoneNumb,
                                           string email,
                                           string passwordQuestion,
                                           string passwordAnswer,
                                           bool isApproved,
                                           object userId,
                                           out    MembershipCreateStatus status) {
 
//Code here
 
}

Open in new window

0
Comment
Question by:atuccillo
1 Comment
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
ID: 24775105
You cannot modify createuser method definition i.e. pass additional parameters.
Also there is not way to catch CreateUser event...
I do remember some way out in this case ...but cannot recall or don't have references handy.
But here is one option that you can try and it will work as well.
CreatedUser Event - where again you have two choices.
1: Use Asp.net Profiles. But I am never used AccessProfileProviders(not sure even if one exists)
Check this link: http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx
It user SqlProfileProvider but you might find somewhere AccessProfileProvider.

2: Create your own UserProfiles table. Link it with aspnet_Users table using UserId as FK relationship.
Now in CreatedUser Event handler, insert FN,LN,BD etc field values into UserProfiles Table
Check this:
http://weblogs.asp.net/gurusarkar/archive/2009/01/27/storing-user-profile-into-a-custom-table-using-createuser-wizard-control.aspx

Now the link 2 above user SqlConnection/SqlCommand objects to insert values but in your case should use OleDbConnection/Command objects.

Option 1 and 2 are almost similar but in case 1, asp.net profile provider takes care of profiletable and insert/update mechanism but in case 2, you do it manually by youself.
The concept remains same to use CreatedUser Event of CUW control.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question