Membership.CreateUser Method (String, String, String, String, String, Boolean, Object, MembershipCreateStatus)
Assembly: System.Web (in system.web.dll)
'Declaration Public Shared Function CreateUser ( _ username As String, _ password As String, _ email As String, _ passwordQuestion As String, _ passwordAnswer As String, _ isApproved As Boolean, _ providerUserKey As Object, _ <OutAttribute> ByRef status As MembershipCreateStatus _ ) As MembershipUser 'Usage Dim username As String Dim password As String Dim email As String Dim passwordQuestion As String Dim passwordAnswer As String Dim isApproved As Boolean Dim providerUserKey As Object Dim status As MembershipCreateStatus Dim returnValue As MembershipUser returnValue = Membership.CreateUser(username, password, email, passwordQuestion, passwordAnswer, isApproved, providerUserKey, status)
public static MembershipUser CreateUser ( String username, String password, String email, String passwordQuestion, String passwordAnswer, boolean isApproved, Object providerUserKey, /** @attribute OutAttribute() */ /** @ref */ MembershipCreateStatus status )
Not applicable.
Parameters
- username
The user name for the new user.
- password
The password for the new user.
The e-mail address for the new user.
- passwordQuestion
The password-question value for the membership user.
- passwordAnswer
The password-answer value for the membership user.
- isApproved
A Boolean that indicates whether the new user is approved to log on.
- providerUserKey
The user identifier for the user that should be stored in the membership data store.
- status
A MembershipCreateStatus indicating that the user was created successfully or the reason creation failed.
Return Value
A MembershipUser object for the newly created user. If no user was created, this method returns a null reference (Nothing in Visual Basic).CreateUser adds a new user to the data store and returns a MembershipUser object for the newly created user. If the user creation fails, you can retrieve a MembershipCreateStatus value from the status output parameter that indicates why user creation failed. You can specify a unique identifier for the user, such as a primary key value for a database, by using the providerUserKey parameter.
The CreateUser method will return a null reference (Nothing in Visual Basic) if password is an empty string or a null reference (Nothing in Visual Basic), username is an empty string or a null reference (Nothing in Visual Basic) or contains a comma (,), passwordQuestion is not a null reference (Nothing in Visual Basic) and contains an empty string, or passwordAnswer is not a null reference (Nothing in Visual Basic) and contains an empty string.
Once a membership user has been created and you have a reference to a MembershipUser object for that user, you can modify the settings for that user with the MembershipUser public methods and by setting the property values of the MembershipUser object and then passing the MembershipUser object to the UpdateUser method.
If a user already exists in the data source for the application, you can obtain a MembershipUser object for the existing user with the GetUser method.
Leading and trailing spaces are trimmed from all string parameter values.