简体   繁体   English

在 Windows 问题上连接到企业 WiFi

[英]Connect to Enterprise WiFi on Windows issue

I configured the Radius Server on Windows Server 2016 and I want to connect to Enterprise WiFi network using my application.我在 Windows Server 2016 上配置了 Radius 服务器,我想使用我的应用程序连接到企业 WiFi 网络。 I tried to do the following steps:我尝试执行以下步骤:

Set the profile without credentials using WlanSetProfile (I used imported profile from netsh with some modifications)使用WlanSetProfile设置没有凭据的配置文件(我使用从 netsh 导入的配置文件并进行了一些修改)

Then set the xml profile below with my username and password to WlanSetProfileEapXmlUserData :然后使用我的用户名和密码将下面的 xml 配置文件设置为WlanSetProfileEapXmlUserData

<?xml version="1.0" ?> 
 <EapHostUserCredentials xmlns="http://www.microsoft.com/provisioning/EapHostUserCredentials" 
   xmlns:eapCommon="http://www.microsoft.com/provisioning/EapCommon" 
   xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapMethodUserCredentials">
   <EapMethod>
     <eapCommon:Type>26</eapCommon:Type> 
     <eapCommon:AuthorId>0</eapCommon:AuthorId> 
   </EapMethod>
   <Credentials xmlns:eapUser="http://www.microsoft.com/provisioning/EapUserPropertiesV1" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapUserPropertiesV1" 
     xmlns:MsPeap="http://www.microsoft.com/provisioning/MsPeapUserPropertiesV1" 
     xmlns:MsChapV2="http://www.microsoft.com/provisioning/MsChapV2UserPropertiesV1">
     <baseEap:Eap>
       <baseEap:Type>26</baseEap:Type> 
       <MsChapV2:EapType>
         <MsChapV2:Username>test</MsChapV2:Username> 
         <MsChapV2:Password>test</MsChapV2:Password> 
       </MsChapV2:EapType>
     </baseEap:Eap>
   </Credentials>
 </EapHostUserCredentials>

Then I use WlanConnect function and callback function to verify the connection.然后我使用WlanConnect function 和回调 function 来验证连接。 When connecting I get the following issue:连接时出现以下问题:

NotificationCode returns code 8 (wlan_notification_acm_scan_fail) and then 11 (wlan_notification_acm_connection_attempt_fail). NotificationCode 返回代码 8 (wlan_notification_acm_scan_fail),然后返回 11 (wlan_notification_acm_connection_attempt_fail)。

Also, from MS docs:此外,来自 MS 文档:

wlan_notification_acm_scan_fail: wlan_notification_acm_scan_fail:

A scan for connectable networks failed.对可连接网络的扫描失败。

The pData member of the WLAN_NOTIFICATION_DATA structure points to a WLAN_REASON_CODE data type value that identifies the reason the WLAN operation failed. WLAN_NOTIFICATION_DATA 结构的 pData 成员指向 WLAN_REASON_CODE 数据类型值,该值标识 WLAN 操作失败的原因。

So, I checked the pData when this issue occurs and it returns the following reason:因此,我在出现此问题时检查了 pData,它返回以下原因:

wlan_notification_acm_scan_fail "The operation was successful." wlan_notification_acm_scan_fail "操作成功。"

But the network is not connected.但是网络没有连接。 Thanks in advance for your help.在此先感谢您的帮助。

I have fixed this issue.我已经解决了这个问题。 The problem was because the PerformServerValidation was set to true and it displayed the notification dialog to verify the certificate on Windows that's why it returned:问题是因为 PerformServerValidation 设置为 true 并显示通知对话框以验证 Windows 上的证书,这就是它返回的原因:

wlan_notification_acm_scan_fail "The operation was successful." wlan_notification_acm_scan_fail "操作成功。"

Setting the PerformServerValidation to false fixed the issue (WlanSetProfile function).将 PerformServerValidation 设置为 false 修复了该问题(WlanSetProfile 函数)。

<PerformServerValidation xmlns=\"http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV2\">false</PerformServerValidation>

Also, for WlanSetProfileEapXmlUserData function I provided this profile:另外,对于 WlanSetProfileEapXmlUserData function 我提供了这个配置文件:

<?xml version="1.0" ?>
<EapHostUserCredentials
xmlns="http://www.microsoft.com/provisioning/EapHostUserCredentials"
xmlns:eapCommon="http://www.microsoft.com/provisioning/EapCommon"
xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapMethodUserCredentials">
<EapMethod>
<eapCommon:Type>25</eapCommon:Type>
<eapCommon:AuthorId>0</eapCommon:AuthorId>
</EapMethod>
<Credentials
xmlns:eapUser="http://www.microsoft.com/provisioning/EapUserPropertiesV1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapUserPropertiesV1"
xmlns:MsPeap="http://www.microsoft.com/provisioning/MsPeapUserPropertiesV1"
xmlns:MsChapV2="http://www.microsoft.com/provisioning/MsChapV2UserPropertiesV1">
<baseEap:Eap>
<baseEap:Type>25</baseEap:Type>
<MsPeap:EapType>
<baseEap:Eap>
<baseEap:Type>26</baseEap:Type>
<MsChapV2:EapType>
<MsChapV2:Username>username</MsChapV2:Username>
<MsChapV2:Password>password</MsChapV2:Password>
</MsChapV2:EapType>
</baseEap:Eap>
</MsPeap:EapType>
</baseEap:Eap>
</Credentials>
</EapHostUserCredentials>

Now it connects successfully to Enterprise network.现在它成功连接到企业网络。 The issue is resolved.问题已解决。 Thank you.谢谢你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM