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.
    boolean loadUserServiceAttributes = false;
    boolean loadUserDeviceConfigurationServiceAttributes = false;
    boolean loadUserResolvedGroups = false;
    boolean loadUserResolvedGroupIds = false;
    boolean loadUserGroups = false;
    boolean loadUserWLANVPNVOIPConfigurations = true;
  2. Retrieve the user account object.
    GetUserResult result= coreWebService.getUser(userId, locale, loadUserServiceAttributes, loadUserDeviceConfigurationServiceAttributes, loadUserResolvedGroups, loadUserResolvedGroupIds, loadUserGroups, loadUserWLANVPNVOIPConfigurations);
  3. Check the result for errors and handle any errors.
    if (result.getGetUserReturnStatus().getCode() != GetUserReturnStatusEnumType.SUCCESS) 
    {
          // handle any errors
    }
  4. Retrieve the user account object.
    User user=result.getUser();
  5. Search the result for the VPN configuration you want to remove from the user account.
    for (ITPolicyWLANVPNVOIPAttributes itr:user.getITPolicyWLANVPNVOIPAttributes()) 
    {
           for (VPNConfigurations itr2:itr.getVPNConfigurations()) {
                   if(itr2.getPolicyName().equalsIgnoreCase(configName))
                   {
  6. Retrieve the VPN Configuration ID.
                        int VPNConfigId = itr2.getWLANBaseConfigSetsId();
  7. Invoke unassignVPNConfigurationFromUser().
                        UnassignVPNConfigurationFromUserResult vpnResult = coreWebService.unassignVPNConfigurationFromUser(VPNConfigId, userId);
  8. Check the result for errors, and handle any errors.
                         if (vpnResult.getUnassignVPNConfigurationFromUserReturnStatus().getCode() != UnassignVPNConfigurationFromUserReturnStatusEnumType.SUCCESS) 
                        {
                               // handle any errors
                        }
                        break;
                   }
               }
           }
    }

Was this information helpful? Send us your comments.