尝试在C#中设置仅L2tp VPN属性

时间:2018-02-06 17:09:29

标签: c# vpn dotras

我正在尝试创建一个控制台应用程序来为我的公司创建VPN连接。我能够创建VPN连接但无法设置一些属性。我希望未加密的密码(PAP)为true,CHAP和CHAP2为false。但是,相反的情况发生在那些环境中。我正在使用DotRas工具。我做错了什么或错过了什么?

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");

2 个答案:

答案 0 :(得分:0)

您可以使用选项的组合来更改三个安全性复选框。

df <- read.table(text =
    "Site Date Species BodySize Mass
    1   0017-03-19  grandis  7.4    2.0555241
    1   0017-03-19  grandis  7.6    2.2167792
    1   0017-03-19  grandis  6.6    1.4866433
    1   0017-03-19  doddsii  8.2    2.7490281
    1   0017-03-19  doddsii  7.0    1.7562082
    1   0017-03-19  doddsii  7.8    2.3859990
    1   0017-03-19  doddsii  7.8    2.3859990
    1   0017-03-19  doddsii  7.6    2.2167792
    1   0017-03-19  doddsii  9.0    3.5782702
    1   0017-03-19  doddsii  7.2    1.9020590
    1   0017-03-19  infrequens  4.2 0.4133332
    1   0017-03-19  infrequens  4.2 0.4133332
    1   0017-03-19  infrequens  4.6 0.5347965
    1   0017-03-19  infrequens  4.8 0.6033003
    1   0017-03-19  infrequens  6.2 1.2454079
    1   0017-03-19  infrequens  6.8 1.6177954
    1   0017-03-19  infrequens  4.0 0.3599915
    1   0017-03-19  infrequens  6.0 1.1349656
    1   0017-03-19  cockerelli  12.0    6.4860992
    1   0017-03-19  cockerelli  11.8    6.1838799
    1   0017-03-19  cockerelli  10.8    4.8092579
    1   0017-03-19  doddsii     7.6     2.2167792", header = T)

这些选项将选中PAP,未选中CHAP和未选中MS-CHAP v2。

答案 1 :(得分:0)

您可以使用Windows建筑物拨号命令“ rasdial.exe”进行连接,并使用如下代码:

Windows