Attempting to set L2tp Only VPN properties in C#

﹥>﹥吖頭↗ 提交于 2019-12-11 09:52:09

问题


I am attempting to create a console app to create a VPN connection for my company. I am able to create the VPN connection but unable to set a few of the properties. I want Unencrypted password (PAP) to be true and CHAP and CHAP2 to be false. But, the opposite is happening to those settings. I am using DotRas tools. What am i doing wrong or missing?

string VpnName = "Test VPN";
            string Destination = "127.0.0.1";
            string PresharedKey = "testkey";
            RasPhoneBook PhoneBook = new RasPhoneBook();
            PhoneBook.Open();

            RasEntry VpnEntry = RasEntry.CreateVpnEntry(VpnName, Destination, DotRas.RasVpnStrategy.L2tpOnly, DotRas.RasDevice.Create(VpnName, DotRas.RasDeviceType.Vpn));
            VpnEntry.Options.UsePreSharedKey = true;
            VpnEntry.Options.UseLogOnCredentials = false;
            VpnEntry.Options.RequirePap = true;
            VpnEntry.Options.RequireMSChap = false;
            VpnEntry.Options.RequireMSChap2 = false;
            PhoneBook.Entries.Add(VpnEntry);
            VpnEntry.UpdateCredentials(RasPreSharedKey.Client, PresharedKey);
            Console.WriteLine("VPN connection created successfully");

回答1:


You can change the three security checkboxes using a combination of options.

VpnEntry.Options.RequireEncryptedPassword = false;
VpnEntry.Options.RequirePap = true;
VpnEntry.Options.RequireChap = false;
VpnEntry.Options.RequireMSChap = false;
VpnEntry.Options.RequireMSChap2 = false;

Those options will have PAP checked, CHAP unchecked, and MS-CHAP v2 unchecked.



来源:https://stackoverflow.com/questions/48648353/attempting-to-set-l2tp-only-vpn-properties-in-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!