3

我在 .net c# 窗口应用程序中创建了 wifi 扫描仪。现在我可以连接到 WPA2-个人身份验证网络。现在我想连接到 WPA-企业网络,但我不知道如何连接到它。如果您有任何解决方案,请告诉我

以下是我正在运行的 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);
        }
4

0 回答 0