none
WlanSetProfileEapXmlUserData API在win7 64bit上报1206 error RRS feed

  • 问题

  • 最近在弄一个工具,使用wlanapi来进行配置无线网络,我发现使用WlanSetProfileEapXmlUserData这个api在win7 64bit上总是报错1206错误,但在win7 32bit上没有问题。

    代码:https://github.com/wufeng6174/code/tree/master/SetEapData

    无线网络的profile: https://github.com/wufeng6174/code/blob/master/sxf-profile.xml

    #ifndef UNICODE
    #define UNICODE
    #endif
    
    #include <windows.h>
    #include <wlanapi.h>
    #include <objbase.h>
    #include <wtypes.h>
    
    #include <stdio.h>
    #include <stdlib.h>
    
    #include <Eaptypes.h>
    
    // Need to link with Wlanapi.lib and Ole32.lib
    #pragma comment(lib, "wlanapi.lib")
    #pragma comment(lib, "ole32.lib")
    
    using namespace std;
    
    int wmain(int argc, char **argv)
    {
    
    	// Declare and initialize variables.
    
    	HANDLE hClient = NULL;
    	DWORD dwMaxClient = 2;      //    
    	DWORD dwCurVersion = 0;
    	DWORD dwResult = 0;
    	DWORD dwRetVal = 0;
    
    
    	/* variables used for WlanEnumInterfaces  */
    
    	PWLAN_INTERFACE_INFO_LIST pIfList = NULL;
    
    	LPCWSTR xml = L"<?xml version=\"1.0\" ?>\n"
    		L"  <EapHostUserCredentials xmlns=\"http://www.microsoft.com/provisioning/EapHostUserCredentials\"\n"
    		L"    xmlns:eapCommon=\"http://www.microsoft.com/provisioning/EapCommon\" \n"
    		L"    xmlns:baseEap=\"http://www.microsoft.com/provisioning/BaseEapMethodUserCredentials\">\n"
    		L"    <EapMethod>\n"
    		L"      <eapCommon:Type>25</eapCommon:Type> \n"
    		L"      <eapCommon:AuthorId>0</eapCommon:AuthorId> \n"
    		L"    </EapMethod>\n"
    		L"    <Credentials xmlns:eapUser=\"http://www.microsoft.com/provisioning/EapUserPropertiesV1\"\n"
    		L"      xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
    		L"      xmlns:baseEap=\"http://www.microsoft.com/provisioning/BaseEapUserPropertiesV1\"\n"
    		L"      xmlns:MsPeap=\"http://www.microsoft.com/provisioning/MsPeapUserPropertiesV1\"\n"
    		L"      xmlns:MsChapV2=\"http://www.microsoft.com/provisioning/MsChapV2UserPropertiesV1\">\n"
    		L"      <baseEap:Eap>\n"
    		L"        <baseEap:Type>25</baseEap:Type> \n"
    		L"        <MsPeap:EapType>\n"
    		L"          <MsPeap:RoutingIdentity>sxf</MsPeap:RoutingIdentity> \n"
    		L"          <baseEap:Eap>\n"
    		L"            <baseEap:Type>26</baseEap:Type> \n"
    		L"            <MsChapV2:EapType>\n"
    		L"              <MsChapV2:Username>52950</MsChapV2:Username> \n"
    		L"              <MsChapV2:Password>dlw6666</MsChapV2:Password> \n"
    		L"              <MsChapV2:LogonDomain></MsChapV2:LogonDomain> \n"
    		L"            </MsChapV2:EapType>\n"
    		L"          </baseEap:Eap>\n"
    		L"        </MsPeap:EapType>\n"
    		L"      </baseEap:Eap>\n"
    		L"    </Credentials>\n"
    		L"  </EapHostUserCredentials>";
    
    
    
    	dwResult = WlanOpenHandle(dwMaxClient, NULL, &dwCurVersion, &hClient);
    	if (dwResult != ERROR_SUCCESS) {
    		wprintf(L"WlanOpenHandle failed with error: %u\n", dwResult);
    		return 1;
    		// You can use FormatMessage here to find out why the function failed
    	}
    
    	dwResult = WlanEnumInterfaces(hClient, NULL, &pIfList);
    	if (dwResult != ERROR_SUCCESS) {
    		wprintf(L"WlanEnumInterfaces failed with error: %u\n", dwResult);
    		return 1;
    		// You can use FormatMessage here to find out why the function failed
    	}
    	else {
    		wprintf(L"Num Entries: %lu\n", pIfList->dwNumberOfItems);
    		wprintf(L"Current Index: %lu\n", pIfList->dwIndex);
    		
    		dwResult = WlanSetProfileEapXmlUserData(hClient, &pIfList->InterfaceInfo[0].InterfaceGuid, L"sxf", 1, xml, NULL);
    
    		if (dwResult != ERROR_SUCCESS) {
    			wprintf(L"WlanSetProfileEapXmlUserData failed with error: %u\n",
    				dwResult);
    			// You can use FormatMessage to find out why the function failed
    		}
    
    
    		return dwResult;
    	}
    
    	if (pIfList != NULL) {
    		WlanFreeMemory(pIfList);
    		pIfList = NULL;
    	}
    
    	return dwRetVal;
    }

    • 已编辑 打师 2016年11月26日 9:43
    2016年11月26日 9:42

全部回复

  • 您的程序是32位的吗?您编译一个64位的程序版本然后在64位的机器上试一下看看呢?

    Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.

    2016年11月27日 8:40
    版主
  • Hi 打师,

    感谢在MSDN论坛发帖。

    >>最近在弄一个工具,使用wlanapi来进行配置无线网络,我发现使用WlanSetProfileEapXmlUserData这个api在win7 64bit上总是报错1206错误,但在win7 32bit上没有问题。

    错误1206的意思是网络连接配置文件已损坏。 无法解析在strProfileName参数中指定的概要文件。请检查配置文件的名称,需要与EAP用户数据相关联,配置文件名称区分大小写。

    Best Regards,

    Sera Yu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2016年12月16日 9:18