Remove a VPN configuration from a user account

To remove a VPN configuration from a user account, you can use the unassignVPNConfigurationFromUser() method.
Before you begin: Retrieve the following variables:
  • userID integer for the user account that you want remove the VPN configuration from
  • configName string for the name of the VPN configuration
  1. Specify the attributes to load with the user account that you want to remove the VPN configuration from. To access the VPN configurations of the user account, you must specify the loadUserWLANVPNVOIPConfigurations attribute as true.
    getUser userRequest = new getUser();
    userRequest.loadUserServiceAttributes=false;
    userRequest.loadUserDeviceConfigurationServiceAttributes=false;
    userRequest.loadUserResolvedGroups=false;
    userRequest.loadUserResolvedGroupIds=false;
    userRequest.loadUserGroups=false;
    userRequest.loadUserWLANVPNVOIPConfigurations=true;
  2. Retrieve the user account object.
    getUserResponse userResponse = coreWebService.getUser(getUserRequest);
    getUserResult userResult = userResponse.returnValue;
  3. Check the result for errors and handle any errors.
    if (result.getUserReturnStatus.code != GetUserReturnStatusEnumType.SUCCESS) 
    {
          // handle any errors
    }
  4. Retrieve the user account object.
    User user = result.user;
  5. Search the result for the VPN configuration you want to remove from the user account.
    for (int i=0; i < user.itPolicyWLANVPNVOIPAttributes.Length; i++) 
    {
           if (user.itPolicyWLANVPNVOIPAttributes[i].GetType.Equals(typeof(VPNConfigurations)))
           {
               for (int j=0; j<user.itPolicyWLANVPNVOIPAttributes[i].Length; j++)
               {
                   if(user.itPolicyWLANVPNVOIPAttributes[i].policyName.ToUpper().Equals(configName.ToUpper()))
                   {
  6. Retrieve the VPN Configuration ID.
                        int vpnConfigID = user.itPolicyWLANVPNVOIPAttributes[i].vpnConfigurations[j].wlanBaseConfigSetsId;
  7. Invoke unassignVPNConfigurationFromUser().
                        unassignVPNConfigurationFromUser removeRequest = new unassignVPNConfigurationFromUser();
                        removeRequest.vpnConfigId = vpnConfigID;
                        removeRequest.userId = userID;
                        unassignVPNConfigurationFromUserResponse vpnResponse = coreWebService.unassignVPNConfigurationFromUser(removeRequest);
                        unassignVPNConfigurationFromUserResult vpnResult = vpnResponse.returnValue;
  8. Check the result for errors, and handle any errors.
                         if (vpnResult.unassignVPNConfigurationFromUserReturnStatus.code != UnassignVPNConfigurationFromUserReturnStatusEnumType.SUCCESS) 
                        {
                               // handle any errors
                        }
                        break;
                   }
               }
           }
    }

Was this information helpful? Send us your comments.