private static extern uint RasSetEntryProperties( string lpszPhonebook, string lpszEntry, ref RASENTRY lpRasEntry, int dwEntryInfoSize, IntPtr lpbDeviceInfo, int dwDeviceInfoSize);
private void LoadDialupConnections() { this.dialupList = new Dictionary<String, RASENTRY>(); this.ConnectionNames.Clear(); var rasEntries = new ArrayList(); ras1.ListEntries(ref rasEntries); foreach (String item in rasEntries) { RASENTRY details = new RASENTRY(); ras1.GetEntry(item, ref details); this.dialupList.Add(item, details); this.ConnectionNames.Add(item); } }
private void LoadDialupConnections() { this.dialupList = new Dictionary <string, RASENTRY>(); this.ConnectionNames.Clear(); var rasEntries = new ArrayList(); this.ras1.ListEntries(ref rasEntries); foreach (string item in rasEntries) { var details = new RASENTRY(); this.ras1.GetEntry(item, ref details); this.dialupList.Add(item, details); this.ConnectionNames.Add(item); } }
private void FillRasControls(string serverName) { this.LoadDialupConnections(); this.RASDetailsListBox.Items.Clear(); if (this.dialupList != null && this.dialupList.ContainsKey(serverName)) { RASENTRY selectedRAS = this.dialupList[serverName]; this.RASDetailsListBox.Items.Add(String.Format("{0}:{1}", "Connection", serverName)); this.RASDetailsListBox.Items.Add(String.Format("{0}:{1}", "Area Code", selectedRAS.AreaCode)); this.RASDetailsListBox.Items.Add(String.Format("{0}:{1}", "Country Code", selectedRAS.CountryCode)); this.RASDetailsListBox.Items.Add(String.Format("{0}:{1}", "Device Name", selectedRAS.DeviceName)); this.RASDetailsListBox.Items.Add(String.Format("{0}:{1}", "Device Type", selectedRAS.DeviceType)); this.RASDetailsListBox.Items.Add(String.Format("{0}:{1}", "Local Phone Number", selectedRAS.LocalPhoneNumber)); } }
private void LoadDialupConnections() { dialupList = new Dictionary <string, RASENTRY>(); System.Collections.ArrayList rasEntries = new System.Collections.ArrayList(); RasError error = ras1.ListEntries(ref rasEntries); foreach (string item in rasEntries) { RASENTRY details = new RASENTRY(); ras1.GetEntry(item, ref details); dialupList.Add(item, details); if (!cmbServers.Items.Contains(item)) { this.cmbServers.Items.Add(item); } } }
private void cmbServers_SelectedIndexChanged(object sender, EventArgs e) { if (ProtocolComboBox.Text == "RAS") { LoadDialupConnections(); RASDetailsListBox.Items.Clear(); if (dialupList != null && dialupList.ContainsKey(cmbServers.Text)) { RASENTRY selectedRAS = dialupList[cmbServers.Text]; RASDetailsListBox.Items.Add(string.Format("{0}:{1}", "Connection", cmbServers.Text)); RASDetailsListBox.Items.Add(string.Format("{0}:{1}", "Area Code", selectedRAS.AreaCode)); RASDetailsListBox.Items.Add(string.Format("{0}:{1}", "Country Code", selectedRAS.CountryCode)); RASDetailsListBox.Items.Add(string.Format("{0}:{1}", "Device Name", selectedRAS.DeviceName)); RASDetailsListBox.Items.Add(string.Format("{0}:{1}", "Device Type", selectedRAS.DeviceType)); RASDetailsListBox.Items.Add(string.Format("{0}:{1}", "Local Phone Number", selectedRAS.LocalPhoneNumber)); } } }
private void UpdateStats() { lbDetails1.Items.Clear(); this.BringToFront(); if (this.Connected) { if (connectedTime == DateTime.MinValue) { connectedTime = DateTime.Now; } RASENTRY entry = new RASENTRY(); rASConnection.ras.GetEntry(rASConnection.ras.EntryName, ref entry); AddDetailsText("Connection Status", "Connected"); AddDetailsText("Host", entry.LocalPhoneNumber); AddDetailsText("IP Address", rASConnection.ras.IPAddress()); System.TimeSpan ts = new TimeSpan(DateTime.Now.Ticks - connectedTime.Ticks); AddDetailsText("Connection Duration:", string.Format("{0} Days, {1} Hours, {2} Minutes, {3} Seconds", ts.Days, ts.Hours, ts.Minutes, ts.Seconds)); } else { AddDetailsText("Connection Status", "Not Connected"); } }
public static bool createIKEV2VPN(string name, string server) { UInt32 dwSize = 0; RasGetEntryProperties(null, "", IntPtr.Zero, ref dwSize, IntPtr.Zero, IntPtr.Zero); RASENTRY rasE = new RASENTRY(); rasE.dwSize = (int)dwSize; rasE.dwType = (int)RasEntryTypes.RASET_Vpn; rasE.dwRedialCount = 1; rasE.dwRedialPause = 60; rasE.dwfNetProtocols = (int)RasNetProtocols.RASNP_Ip; rasE.dwEncryptionType = (int)RasEntryEncryption.ET_Optional; rasE.szLocalPhoneNumber = server; rasE.szDeviceType = "RASDT_Vpn"; rasE.dwfOptions = (int)RasEntryOptions.RASEO_RemoteDefaultGateway | (int)RasEntryOptions.RASEO_RequireDataEncrption; rasE.dwfOptions2 = (int)RasEntryOptions2.RequireMachineCertificates; rasE.dwVpnStrategy = 7; // IKEV2? uint ret = RasSetEntryProperties(null, name, ref rasE, rasE.dwSize, IntPtr.Zero, 0); return(true); }
private void UpdateStats() { lbDetails1.Items.Clear(); this.BringToFront(); if (this.Connected) { if (connectedTime == DateTime.MinValue) connectedTime = DateTime.Now; RASENTRY entry = new RASENTRY(); rASConnection.ras.GetEntry(rASConnection.ras.EntryName, ref entry); AddDetailsText("Connection Status", "Connected"); AddDetailsText("Host", entry.LocalPhoneNumber); AddDetailsText("IP Address", rASConnection.ras.IPAddress()); System.TimeSpan ts = new TimeSpan(DateTime.Now.Ticks - connectedTime.Ticks); AddDetailsText("Connection Duration:", string.Format("{0} Days, {1} Hours, {2} Minutes, {3} Seconds", ts.Days, ts.Hours, ts.Minutes, ts.Seconds)); } else { AddDetailsText("Connection Status", "Not Connected"); } }
private void LoadDialupConnections() { dialupList = new Dictionary<string, RASENTRY>(); System.Collections.ArrayList rasEntries = new System.Collections.ArrayList(); RasError error = ras1.ListEntries(ref rasEntries); foreach(string item in rasEntries) { RASENTRY details = new RASENTRY(); ras1.GetEntry(item, ref details); dialupList.Add(item, details); if(!cmbServers.Items.Contains(item)) this.cmbServers.Items.Add(item); } }