我对 DotRas 完全陌生,所以请耐心等待。我有一个配置了“路由和远程访问”的 Windows Server 2012 R2。在这个简单的配置中,有一个拨号器连接到一个 vpn,如您在第一张图片中所见。
所以,如果我点击连接..一切正常,网络接口的状态从断开连接变为连接。转到事件查看器,这就是我得到的:
来自 RASCLIENT 源日志的事件:
事件一:
CoId={A52088DC-5358-44D6-8B77-DA49516C3FBD}: The user SYSTEM has started dialing a VPN connection using a all-user connection profile named VpnAtlanta02. The connection settings are:
Dial-in User = c******s
VpnStrategy = PPTP
DataEncryption = Require
PrerequisiteEntry =
AutoLogon = No
UseRasCredentials = Yes
Authentication Type = MS-CHAPv2
Ipv4DefaultGateway = No
Ipv4AddressAssignment = By Server
Ipv4DNSServerAssignment = By Server
Ipv6DefaultGateway = Yes
Ipv6AddressAssignment = By Server
Ipv6DNSServerAssignment = By Server
IpDnsFlags =
IpNBTEnabled = No
UseFlags = Private Connection
ConnectOnWinlogon = No.
活动二:
CoId={A52088DC-5358-44D6-8B77-DA49516C3FBD}: The user SYSTEM is trying to establish a link to the Remote Access Server for the connection named VpnAtlanta02 using the following device:
Server address/Phone Number = ***.***.***.***
Device = WAN Miniport (PPTP)
Port = VPN3-4
MediaType = VPN.
活动三:
CoId={A52088DC-5358-44D6-8B77-DA49516C3FBD}: The user SYSTEM has successfully established a link to the Remote Access Server using the following device:
Server address/Phone Number = ***.***.***.***
Device = WAN Miniport (PPTP)
Port = VPN3-4
MediaType = VPN.
活动四:
CoId={A52088DC-5358-44D6-8B77-DA49516C3FBD}: The link to the Remote Access Server has been established by user SYSTEM.
活动五:
CoId={A52088DC-5358-44D6-8B77-DA49516C3FBD}: The user SYSTEM has dialed a connection named VpnAtlanta02 to the Remote Access Server which has successfully connected. The connection parameters are:
TunnelIpAddress = 172.20.0.19
TunnelIpv6Address = None
Dial-in User = c******s.
现在..我的目标是从 Windows 服务连接
所以这是我的代码(重要部分):
Dialer = new RasDialer();
Dialer.PhoneBookPath = "C:\\Windows\\System32\\ras\\Router.pbk";
Dialer.Timeout = 20 * 1000;
Dialer.HangUpPollingInterval = 20 * 1000;
Dialer.AllowUseStoredCredentials = false;
Dialer.AutoUpdateCredentials = RasUpdateCredential.None;
Dialer.EntryName = "VpnAtlanta02";
Dialer.Credentials = new System.Net.NetworkCredential("c******s", "*********");
Watcher = new RasConnectionWatcher();
Watcher.EnableRaisingEvents = true;
Watcher.Connected += Watcher_Connected;
Watcher.Disconnected += Watcher_Disconnected;
InfoLog("Begin connection");
Watcher.Handle = Dialer.Dial();
private void Watcher_Disconnected(object sender, RasConnectionEventArgs e)
{
InfoLog(e.Connection.EntryName + " is disconnected");
}
private void Watcher_Connected(object sender, RasConnectionEventArgs e)
{
InfoLog(e.Connection.EntryName + " is connected");
}
到目前为止,无论如何...去事件查看器寻找 RasClient 事件源,正如预期的那样,我记录了 5 个事件。1,2,3 和 4 等于手动连接生成的值,不幸的是最后一个 (5) 是:
CoId={E2814072-13C7-44CF-998A-A1160FDC86E3}: The user SYSTEM dialed a connection named VpnAtlanta02 which has failed. The error code returned on failure is 720.
请考虑一下,如果您认为某些错误的凭据或其他..我尝试了没有凭据,并且正如预期的那样,在这种情况下我无法获得事件 4 任何想法?