user not created

Discussion in 'ASP .Net Security' started by hardik shah, Aug 7, 2008.

  1. hardik shah

    hardik shah Guest

    Hi,

    I am using membership class to create new user programmatically, If the
    user is duplicated , no user created in table without giving any error.
    How can I detect any error in creating user. My code is as follow.

    Any hint will be appreciated .

    Hardik Shah

    ================================================

    Try
    Dim newuser As MembershipUser = Membership.CreateUser("hardik3",
    "shah_shah", "", "hi", "hi", True, "0")



    Catch ex As MembershipCreateUserException

    msg.Text = GetErrorMessage(ex.StatusCode)

    Catch ex As Exception

    msg.Text = ex.Message

    End Try

    msg.Text = "User Created"

    End Sub

    Public Sub CreateUser_OnClick(ByVal sender As Object, ByVal args As
    EventArgs)



    End Sub



    ===============================

    Public Function GetErrorMessage(ByVal status As MembershipCreateStatus) As
    String

    Select Case status

    Case MembershipCreateStatus.DuplicateUserName

    Return "Username already exists. Please enter a different user name."

    Case MembershipCreateStatus.DuplicateEmail

    Return "A username for that e-mail address already exists. Please enter a
    different e-mail address."

    Case MembershipCreateStatus.InvalidPassword

    Return "The password provided is invalid. Please enter a valid password
    value."

    Case MembershipCreateStatus.InvalidEmail

    Return "The e-mail address provided is invalid. Please check the value and
    try again."

    Case MembershipCreateStatus.InvalidAnswer

    Return "The password retrieval answer provided is invalid. Please check the
    value and try again."

    Case MembershipCreateStatus.InvalidQuestion

    Return "The password retrieval question provided is invalid. Please check
    the value and try again."

    Case MembershipCreateStatus.InvalidUserName

    Return "The user name provided is invalid. Please check the value and try
    again."

    Case MembershipCreateStatus.ProviderError

    Return "The authentication provider Returned an error. Please verify your
    entry and try again. If the problem persists, please contact your system
    administrator."

    Case MembershipCreateStatus.UserRejected

    Return "The user creation request has been canceled. Please verify your
    entry and try again. If the problem persists, please contact your system
    administrator."

    Case Else

    Return "An unknown error occurred. Please verify your entry and try again.
    If the problem persists, please contact your system administrator."

    End Select

    End Function
    hardik shah, Aug 7, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ulf Heyder
    Replies:
    0
    Views:
    561
    Ulf Heyder
    Oct 16, 2003
  2. jimjim
    Replies:
    12
    Views:
    1,890
    Ron Natalie
    Jun 3, 2005
  3. tom c
    Replies:
    6
    Views:
    504
    tom c
    Sep 6, 2006
  4. Sunfire
    Replies:
    1
    Views:
    480
    Roland Dick
    Nov 10, 2007
  5. msimmons
    Replies:
    0
    Views:
    468
    msimmons
    Jul 16, 2009
Loading...

Share This Page