Export (0) Print
Expand All

MembershipProvider.CreateUser Method

Adds a new membership user to the data source.

Namespace:  System.Web.Security
Assembly:  System.Web.ApplicationServices (in System.Web.ApplicationServices.dll)

public abstract MembershipUser CreateUser(
	string username,
	string password,
	string email,
	string passwordQuestion,
	string passwordAnswer,
	bool isApproved,
	Object providerUserKey,
	out MembershipCreateStatus status
)

Parameters

username
Type: System.String

The user name for the new user.

password
Type: System.String

The password for the new user.

email
Type: System.String

The e-mail address for the new user.

passwordQuestion
Type: System.String

The password question for the new user.

passwordAnswer
Type: System.String

The password answer for the new user

isApproved
Type: System.Boolean

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

providerUserKey
Type: System.Object

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

status
Type: System.Web.Security.MembershipCreateStatus

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

Return Value

Type: System.Web.Security.MembershipUser
A MembershipUser object populated with the information for the newly created user.

Takes, as input, the name of a new user, a password, and an e-mail 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.

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

.NET Framework

Supported in: 4.5.3, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft