lachan
lachan

Reputation: 21

Is there a way to prevent On-demand VPN from being turnned off?

I want to create a VPN configuration profile and enable the use of the On-demand feature. My main goal is to always keep the VPN on, that every connection will go out through the VPN tunnel.

I'm looking for a (programmatic preferred) way to prevent a user from disabling the On-demand feature. The trick is - I can't use an MDM profile in no way.

Is there anyone here that is familiar with a way to prevent from a user from turning off the On-demand option? No MDM usage?

Thank you

Upvotes: 2

Views: 3129

Answers (3)

Benjamin RD
Benjamin RD

Reputation: 12044

Swift 5

let targetManager: NEVPNManager = NEVPNManager.shared()
targetManager.isOnDemandEnabled = true;
targetManager.saveToPreferences(completionHandler: { (NSError) -> Void in

})

Upvotes: 0

mKane
mKane

Reputation: 982

If the user connects via your app why dont you check for a connected state and call

 self.targetManager.onDemandEnabled = true;
        self.targetManager.saveToPreferencesWithCompletionHandler({ (NSError) -> Void in
        })

This way it will save on demand as a preference.

Upvotes: 2

Woggledog
Woggledog

Reputation: 58

If you can get access to the phone before giving it to the user, and make it supervised, then yes.

From Apple's deployment guide:

Always-on VPN Overview Always-on VPN gives your organization full control over device traffic by tunneling all IP traffic back to the organization. The default tunneling protocol, IKEv2, secures traffic transmission with data encryption. Your organizations can now monitor and filter traffic to and from its devices, secure data within its network, and restrict device access to the Internet. Always-on VPN activation requires device supervision. Once the Always-on VPN profile is installed on a device, Always-on VPN automatically activates with no user interaction. Always-on VPN stays activated (including across reboots) until the Always-on VPN profile is uninstalled.

Upvotes: 0

Related Questions