Checkbox Forums

Help
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    asm_ihill is offline Junior Member
    Join Date
    Apr 2009
    Posts
    2

    Default Creating a profile and filling in customer user fields using user management service

    I'm trying to create a new user profile and complete a profile with Custom User Fields. I prefer to do this all in one call to the .CreateUser method. The method looks to take in an array of SimpleNameValues.

    The issue I'm running into is filling out all the fields. Seems like only the last item value in the array gets added to the profile. In the code below it only fills in the "Favorite Color" item. Am I misundertanding the service? Could you provide a sample of the correct way this is done?

    Thanks in advance.

    Private Sub AddUser()
    Dim umsProxy As UserManagementServiceProxy = New UserManagementServiceProxy

    umsProxy.Url = WebServiceURL

    Dim userContextToken As Nullable(Of Guid) = umsProxy.AuthenticateUser("SomeUser", "blah")

    If Not userContextToken.HasValue Then
    Throw New Exception("Unable to authenticate user!")
    End If

    Dim User As String = tbUserName.Text.Trim

    Dim UserProfile As SimpleNameValue(Of Object, Object)
    UserProfile = New SimpleNameValue(Of Object, Object)

    Dim UserProfileArray(3) As SimpleNameValue(Of Object, Object)

    UserProfile.Name = "UniqueIdentifier"
    UserProfile.Value = User
    UserProfileArray(0) = UserProfile

    UserProfile.Name = "Email"
    UserProfile.Value = tbEmail.Text.Trim
    UserProfileArray(1) = UserProfile

    UserProfile.Name = "Birthday"
    UserProfile.Value = txtBirthday.Text.Trim
    UserProfileArray(2) = UserProfile

    UserProfile.Name = "Favorite Color"
    UserProfile.Value = "blue"
    UserProfileArray(3) = UserProfile

    Try
    User = umsProxy.CreateUser(userContextToken, tbUserName.Text.Trim, "my password", UserProfileArray, True)
    Catch ex As Exception
    Throw New Exception("Unable to create user: " & ex.ToString)
    End Try

    umsProxy.Dispose()
    umsProxy = Nothing
    End Sub
    Last edited by asm_ihill; 05-10-2010 at 02:39 PM.

  2. #2
    pwiesner is offline Administrator
    Join Date
    Mar 2007
    Posts
    385

    Default

    I am not familiar with Visual Basic but based on your description of the problem it sounds like you are filling your array with identical objects. What happens if you create a new UserProfile variable every time you add an element to the array?
    Last edited by pwiesner; 05-10-2010 at 03:15 PM.

  3. #3
    asm_ihill is offline Junior Member
    Join Date
    Apr 2009
    Posts
    2

    Default

    Quote Originally Posted by pwiesner View Post
    I am not familiar with Visual Basic but based on your description of the problem it sounds like you are filling your array with identical objects. What happens if you create a new UserProfile variable every time you add an element to the array?
    You're correct I need to create a new UserProfile object for each element.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO 3.5.0