Skip to content

Instantly share code, notes, and snippets.

@robinwassen
Created August 6, 2013 13:34
Show Gist options
  • Save robinwassen/6164456 to your computer and use it in GitHub Desktop.
Save robinwassen/6164456 to your computer and use it in GitHub Desktop.
#define _WIN32_DCOM
#include <windows.h>
#include <conio.h>
#include <objbase.h>
#include <rpcsal.h>
#include <objbase.h>
#include <msxml6.h>
#include <atlbase.h>
#include <iostream>
#include <iomanip>
// headers needed to use WLAN APIs
#include <wlanapi.h>
using namespace std;
const WCHAR EapCredBlob[] = L"<?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> \
<MsPeap:RoutingIdentity>MYSSID</MsPeap:RoutingIdentity> \
<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>";
int _cdecl wmain(int argc,WCHAR * wargv[])
{
DWORD dwRetCode =0;
DWORD dwNegotiatedVersion = 0;
HANDLE hClient;
PWLAN_INTERFACE_INFO_LIST pIntfList = NULL;
dwRetCode = WlanOpenHandle(WLAN_API_VERSION, NULL, &dwNegotiatedVersion, &hClient);
wcout << dwRetCode << endl;
dwRetCode = WlanEnumInterfaces(hClient, NULL, &pIntfList);
wcout << dwRetCode << endl;
dwRetCode = WlanSetProfileEapXmlUserData(hClient, &pIntfList->InterfaceInfo[0].InterfaceGuid, L"MYSSID", 0, EapCredBlob, NULL);
wcout << dwRetCode << endl;
return 0;
}
@sunjunlishi
Copy link

me too

@sunjunlishi
Copy link

how to resolve??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment