【发布时间】:2019-03-28 00:42:30
【问题描述】:
我正在尝试创建 vpn 配置文件并使用我的凭据连接到它。这是我的代码:
Profile = new VpnNativeProfile();
Profile.AlwaysOn = true;
Profile.NativeProtocolType = VpnNativeProtocolType.IpsecIkev2;
Profile.ProfileName = VpnProfileName;
Profile.RememberCredentials = false;
Profile.RequireVpnClientAppUI = true;
Profile.RoutingPolicyType = VpnRoutingPolicyType.ForceAllTrafficOverVpn;
Profile.Servers.Add(myserver);
Profile.UserAuthenticationMethod = VpnAuthenticationMethod.Eap;
try
{
StorageFolder localFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
string path = Path.Combine(localFolder.Path, "eap-conf.xml");
Profile.EapConfiguration = File.ReadAllText(path);
}
catch
{
return false;
}
var profileres = await Agent.AddProfileFromObjectAsync(Profile);
已创建配置文件,然后尝试连接到它
VpnManagementErrorStatus status = await Agent.ConnectProfileWithPasswordCredentialAsync(Profile, new PasswordCredential
{
UserName = controller.Configuration.Id.ToString(),
Password = controller.Configuration.Password
});
而且它不工作,它要么进入无限等待,要么返回“其他”连接状态。 手动输入我的凭据效果很好,连接已建立。我试图从代码中调用连接,然后手动输入凭据,我看到了我的登录错误传递的原因
我将 Name 传递为“1005”,不带点或任何其他规范符号。将不胜感激任何提示或帮助,谢谢。
【问题讨论】:
-
你能提供你的操作系统版本和SDK目标版本吗?
-
我的操作系统版本是 1803(build 17134.345),sdk 目标版本是 1803(build 17134)最低版本是 build 15063