Connect to Enterprise WiFi network issue
-
No I don't. You should bring that to the Microsoft developer network forum.
-
Yes, I asked it on MSDN, but it seems that even Microsoft do not know what causing such issue :)
-
Did you discover an "an unknown feature" ?
Can you post the link to your thread over there ? It might become useful over time.
-
Did you discover an "an unknown feature" ?
Can you post the link to your thread over there ? It might become useful over time.
Hello!
Also, I am still investigating this issue. There are three options:
- Using
WlanSetProfileEapXmlUserData
lead to 1168 error because the profile is always wrong. - Using
WlanSetProfileEapUserData
also lead to 1168 error, but I think the reason, due toEAP_METHOD_TYPE
struct, because from the MS docs: AnEAP_METHOD_TYPE
structure that contains the method for which the caller is supplying EAP user credentials.. But I can not provide the username and password to this struct because it only haveeapType
anddwAuthorId
:
typedef struct _EAP_METHOD_TYPE { EAP_TYPE eapType; DWORD dwAuthorId; } EAP_METHOD_TYPE;
Checking
EAP_TYPE
structure also does not have the ability to set username and password:typedef struct _EAP_TYPE { BYTE type; DWORD dwVendorId; DWORD dwVendorType; } EAP_TYPE;
But there is
EapUsernamePasswordCredential
structure (https://docs.microsoft.com/en-us/windows/win32/api/eaptypes/ns-eaptypes-eapusernamepasswordcredential), so I can set the user credentials, butWlanSetProfileEapUserData
does not accept it and displays compilation errors, because the 4th parameter should be onlyEAP_METHOD_TYPE
and notEapUsernamePasswordCredential
:typedef struct _EapUsernamePasswordCredential { LPWSTR username; LPWSTR password; } EapUsernamePasswordCredential;
So, the 3rd option is:
3. UseWlanSetProfile
to set Enterprise profile. It successfully sets the Enterprise profile, but it only accepts this profile without credentials. With credentials it lead to 1206 error code, which means: The profile invalid according to the schema / ERROR_BAD_PROFILE.
I think theWlanSetProfile
must work with combination of one more method to set the user credentials but it is missing.These 3 options are failed for me.
- Using
-
I figured it out! So, to resolve this issue you must do the following steps:
-
Set the profile without credentials using
WlanSetProfile
(I used imported profile from netsh with some modifications) -
Then set the xml profile below with your username and password to
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 use
WlanConnect
function and callback function to verify the connection.
It all good, but I get another issue:
229377 ("The operation was cancelled.")
It was the reason code that reports
229377
code, I think it returned such code because I opened the Windows WiFi Manager from the taskbar. The actualNotificationCode
returns code8 (wlan_notification_acm_scan_fail)
and then11 (wlan_notification_acm_connection_attempt_fail)
. I am still investigating this issue. Thanks. -
-
Also, from MS docs:
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.
So, I checked the
pData
when this issue occurs and it returns the following reason:wlan_notification_acm_scan_fail "The operation was successful."
But the network is not connected, it is strange.
-
Hello!
I have fixed this issue. The problem was because thePerformServerValidation
was set totrue
and it displayed the notification dialog to verify the certificate onWindows
that's why it returnedwlan_notification_acm_scan_fail "The operation was successful."
.Setting the
PerformServerValidation
tofalse
fixed the issue (WlanSetProfile
function).<PerformServerValidation xmlns=\"http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV2\">false</PerformServerValidation>
Also, for
WlanSetProfileEapXmlUserData
function I provided this profile:<?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.
-
Nice debugging !
Thanks for the feedback and thorough description !
-
Hello!
I have fixed this issue. The problem was because thePerformServerValidation
was set totrue
and it displayed the notification dialog to verify the certificate onWindows
that's why it returnedwlan_notification_acm_scan_fail "The operation was successful."
.Setting the
PerformServerValidation
tofalse
fixed the issue (WlanSetProfile
function).<PerformServerValidation xmlns=\"http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV2\">false</PerformServerValidation>
Also, for
WlanSetProfileEapXmlUserData
function I provided this profile:<?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.
@Cobra91151 Hi, would you mind sharing the xml profile that you set as well? I'm not able to make the windows wifi popup not show. Thank you!
-
My observation is SetEapXmlUserData() works only if the SetProfile() is set to All users that is 0x00000001 but on ManagedNativeWiFi Api, the value is 0