Exemple #1
0
        public async Task Connect(VPNConnection conn)
        {
            VpnManagementAgent mgr = new VpnManagementAgent();

            VpnNativeProfile profile = new VpnNativeProfile()
            {
                AlwaysOn                   = true,
                NativeProtocolType         = VpnNativeProtocolType.Pptp,
                ProfileName                = conn.ConnectionName,
                RememberCredentials        = true,
                RequireVpnClientAppUI      = false,
                RoutingPolicyType          = VpnRoutingPolicyType.ForceAllTrafficOverVpn,
                TunnelAuthenticationMethod = VpnAuthenticationMethod.PresharedKey,
                UserAuthenticationMethod   = VpnAuthenticationMethod.PresharedKey
            };

            profile.Servers.Add(conn.ServerName);

            VpnManagementErrorStatus profileStatus = await mgr.AddProfileFromObjectAsync(profile);

            PasswordCredential credentials = new PasswordCredential
            {
                UserName = conn.UserName,
                Password = conn.Password,
            };

            VpnManagementErrorStatus connectStatus = await mgr.ConnectProfileWithPasswordCredentialAsync(profile, credentials);

            activeProfile = profile;
        }
Exemple #2
0
        private async Task LoadVpn()
        {
            Profiles.Clear();
            Agent = new VpnManagementAgent();
            var profiles = await Agent.GetProfilesAsync();

            foreach (var profile in profiles)
            {
                Log($"PROFILE: {profile.ProfileName}");
                Profiles.Add(profile);
            }
        }
Exemple #3
0
        private async void OnAutoCheck(object sender, RoutedEventArgs e)
        {
            CheckBox checkBox = sender as CheckBox;

            if (checkBox.IsChecked.HasValue)
            {
                if (Profile.AlwaysOn == checkBox.IsChecked.Value)
                {
                    // It's already the right way around; ust return.
                    return;
                }
                Profile.AlwaysOn = checkBox.IsChecked.Value;
                VpnManagementAgent vpnManagementAgent = new VpnManagementAgent();
                var result = await vpnManagementAgent.UpdateProfileFromObjectAsync(Profile);

                VpnManagementErrorStatus errorStatus = result;
                var f = string.Format("{0} / {1}", errorStatus, errorStatus.ToString());
                Log($"{errorStatus}");
            }
        }
 private void button_Click(object sender, RoutedEventArgs e)
 {
     VpnManagementAgent vma     = new VpnManagementAgent();
     VpnPlugInProfile   profile = new VpnPlugInProfile();
 }
Exemple #5
0
        public async Task Disconnect()
        {
            VpnManagementAgent mgr = new VpnManagementAgent();

            mgr.DisconnectProfileAsync(activeProfile);
        }