MembershipProvider.CreateUser Method

Definition

Adds a new membership user to the data source.

C#
public abstract System.Web.Security.MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out System.Web.Security.MembershipCreateStatus status);

Parameters

username
String

The user name for the new user.

password
String

The password for the new user.

email
String

The email address for the new user.

passwordQuestion
String

The password question for the new user.

passwordAnswer
String

The password answer for the new user.

isApproved
Boolean

Whether or not the new user is approved to be validated.

providerUserKey
Object

The unique identifier from the membership data source for the user.

status
MembershipCreateStatus

A MembershipCreateStatus enumeration value indicating whether the user was created successfully.

Returns

A MembershipUser object populated with the information for the newly created user.

Examples

For an example of a MembershipProvider implementation, see Implementing a Profile Provider.

Remarks

Takes, as input, the name of a new user, a password, and an email address and inserts a new user for the application into the data source. The CreateUser method returns a MembershipUser object populated with the information for the newly created user. The CreateUser method also defines an out parameter (in Visual Basic, you can use ByRef) that returns a MembershipCreateStatus value that indicates that the user was successfully created, or a reason that user creation failed.

The CreateUser method raises the ValidatingPassword event, if a MembershipValidatePasswordEventHandler event handler has been specified, and continues or cancels the create-user action based on the results of the event. You can use the OnValidatingPassword virtual method to execute the specified MembershipValidatePasswordEventHandler event handler.

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also