locked
adding user to a role RRS feed

  • Question

  • User-1793527187 posted

    Good morning All,
    I am developing a application with a membership authentication, I want to be able to store in a variable the login of the user that is logged in  and based on the selection he has done assign to a specific role

    This is the code I Used

    Dim LoginId = User.Identity.Name
            Dim roleselected = RCBUserType.SelectedValue
    
            Dim Pilots As String
            Dim Realtors As String
    
            If roleselected = 1 Then
                Roles.AddUsersToRole(LoginId, roleselected)
            End If

    but I am getting the following error: 

    Error 4 Value of type 'String' cannot be converted to '1-dimensional array of String'.

    Please help

    Thanks...!!

    Tuesday, November 20, 2018 3:14 PM

All replies

  • User-893317190 posted

    Hi jpuga,

    Your variable LoginId is of type String and the method Roles.AddUsersToRole's first parameter is of type String[], you should put your LoginId into a string array .

    Please use

     Roles.AddUsersToRole(New String() {LoginId}, roleselected)

    Best regards,

    Ackerly Xu

    Wednesday, November 21, 2018 2:38 AM