UWP VPN配置文件未创建VPN连接

时间:2019-11-18 08:47:04

标签: uwp vpn

我创建了一个VPN配置文件,但未设置以下设置:名称,密码和身份验证方法。我试图以管理员身份运行项目,但它也没有起作用。有什么问题吗?

  auto mgr = ref new VpnManagementAgent();

  auto  profile                          =   ref new VpnNativeProfile();
  profile->AlwaysOn                      =   true;
  profile->NativeProtocolType            =   VpnNativeProtocolType::L2tp;
  profile->UserAuthenticationMethod      =   VpnAuthenticationMethod::PresharedKey;
  profile->ProfileName                   =   "TestVpn";
  profile->RememberCredentials           =   true;
  profile->RequireVpnClientAppUI         =   true;
  profile->RoutingPolicyType             =   VpnRoutingPolicyType::ForceAllTrafficOverVpn;
  profile->Servers->Append("101.99.74.214");  

  auto profileStatus    = mgr->UpdateProfileFromObjectAsync(profile);

  auto credentials      = ref new PasswordCredential();
  credentials->UserName = "vpn";
  credentials->Password = "vpn";  

  auto connectStatus  = mgr->ConnectProfileWithPasswordCredentialAsync(profile, credentials);

enter image description here

0 个答案:

没有答案