如何在 DotRas 中指定 SSTP 用法?

How to specify SSTP usage in DotRas?

我正在尝试在 DotRas 中指定 sstp 连接 - 我找到了如何操作的示例 -

RasDevice device = RasDevice.GetDeviceByName("(SSTP)", RasDeviceType.Vpn, false);
            if (device == null) throw new Exception("Cannot get RasDevice");
            RasEntry entry = RasEntry.CreateVpnEntry(connectionName, serverAddress, RasVpnStrategy.SstpOnly, device);

但是在我的 RasVpnStrategy 中只有 DefaultL2tpFirstL2tpOnlyPptpFirstPptpOnly 字段可用。

我发现:

/// <summary>
    /// Defines the VPN strategies.
    /// </summary>
    public enum RasVpnStrategy
    {
        /// <summary>
        /// Dials PPTP first. If PPTP fails, L2TP is attempted.
        /// </summary>
        Default = 0,

        /// <summary>
        /// Dial PPTP only.
        /// </summary>
        PptpOnly = 1,

        /// <summary>
        /// Always dial PPTP first.
        /// </summary>
        PptpFirst = 2,

        /// <summary>
        /// Dial L2TP only.
        /// </summary>
        L2tpOnly = 3,

        /// <summary>
        /// Always dial L2TP first.
        /// </summary>
        L2tpFirst = 4,
#if (WIN2K8)
        /// <summary>
        /// Dial SSTP only.
        /// </summary>
        SstpOnly = 5,

        /// <summary>
        /// Always dial SSTP first.
        /// </summary>
        SstpFirst = 6
#endif
    }

所以,我什至无法在我的应用程序中指定 Sstp? (Win7)

您至少需要参考 DotRas.dll 的 Win2k8 版本,然后您应该有 RasVpnStrategy.SstpOnly 和 RasVpnStrategy.SstpFirst 枚举选项。

在当前的 DOTRas 版本中不可能 - 只有 PPTP/L2TP 可用。

即使在 W2K 程序集中,RasVpnStrategy.SstpOnly 和 RasVpnStrategy.SstpFirst 枚举选项似乎也丢失了,但下面的代码对我有用。

var device = RasDevice.GetDevices().FirstOrDefault(d => d.Name.Contains("SSTP"));
RasEntry entry = RasEntry.CreateVpnEntry(entryName, ipAddress, (RasVpnStrategy)5, device);