我在.net c#window应用程序中创建了wifi扫描程序。现在我能够连接到WPA2-个人身份验证网络。现在我想与WPA-Enterprise网络连接,但我不知道如何连接到它。 如果您有任何解决方案,请告诉我
以下是我正在使用的WPA2-Personal代码
WlanClient client = new WlanClient();
foreach (WlanClient.WlanInterface wlanIface in client.Interfaces)
{
Wlan.WlanAvailableNetwork[] networks = wlanIface.GetAvailableNetworkList(0);
foreach (Wlan.WlanAvailableNetwork network in networks)
{
Wlan.Dot11Ssid ssid = network.dot11Ssid;
string networkName = Encoding.ASCII.GetString(ssid.SSID, 0, (int)ssid.SSIDLength);
ListViewItem item = new ListViewItem(networkName);
item.SubItems.Add(network.dot11DefaultCipherAlgorithm.ToString());
item.SubItems.Add(network.wlanSignalQuality + "%");
item.SubItems.Add(network.dot11DefaultAuthAlgorithm.ToString());
listView1.Items.Add(item);
}
string profileName = "Network"; // this is also the SSID
string macA = "MAC_ADDRESS";
string key = "PASSWORD";
string profileXml = string.Format("<?xml version=\"1.0\" encoding=\"US-ASCII\"?><WLANProfile xmlns=\"http://www.microsoft.com/networking/WLAN/profile/v1\"><name>{0}</name><SSIDConfig><SSID><name>{0}</name></SSID></SSIDConfig><connectionType>ESS</connectionType><connectionMode>auto</connectionMode><autoSwitch>false</autoSwitch><MSM><security><authEncryption><authentication>WPAPSK</authentication><encryption>TKIP</encryption><useOneX>false</useOneX></authEncryption><sharedKey><keyType>passPhrase</keyType><protected>false</protected><keyMaterial>{1}</keyMaterial></sharedKey></security></MSM></WLANProfile>", profileName, key); //WPA-PSK
wlanIface.SetProfile(Wlan.WlanProfileFlags.AllUser, profileXml, true);
wlanIface.Connect(Wlan.WlanConnectionMode.Profile, Wlan.Dot11BssType.Any, profileName);
}