Discussion:
wlanapi.h: how to use WLAN_CONNECTION_IGNORE_PRIVACY_BIT
(too old to reply)
kevin
2007-08-30 12:12:01 UTC
Permalink
I am developing my WiFi easy config module on Vista. I found Vista SDK
defines WLAN_CONNECTION_IGNORE_PRIVACY_BIT. In wlanapi.h, it is said that
this flag is for easy config association.

But when I use this flag in my code, it doesn't take effect. I create a
temporary profile with OPEN Authentication and NONE encryption. Then use
WlanConnect with this profile to connect to an WPA-AP. WlanConnect returns
SUCCESS, but I cannot capture any authentication request and association
request sent out.

Can anyone help on this issue? Is there any example on how to use this bit?
kevin
2007-08-30 13:18:01 UTC
Permalink
Here is my code:
pWriter->WriteStartDocument(XmlStandalone_Omit);

pWriter->WriteStartElement(NULL,L"WLANProfile",NULL);

pWriter->WriteAttributeString(L"p1",L"xmlns",NULL,L"http://www.microsoft.com/networking/WLAN/profile/v1");

ReadWriteXML_Name(TRUE,xmlToWlan,L"name",pWriter);
ReadWriteXML_SSID(TRUE,xmlToWlan,L"SSIDConfig",pWriter);

pWriter->WriteStartElement(NULL,L"connectionType",NULL);
pWriter->WriteString(L"ESS");

pWriter->WriteFullEndElement();

pWriter->WriteStartElement(NULL,L"connectionMode",NULL);
pWriter->WriteString(L"auto");
pWriter->WriteFullEndElement();

pWriter->WriteStartElement(NULL,L"MSM",NULL);
pWriter->WriteStartElement(NULL,L"security",NULL);

pWriter->WriteStartElement(NULL,L"authEncryption",NULL);

pWriter->WriteStartElement(NULL,L"authentication",NULL);
pWriter->WriteString(L"open");
pWriter->WriteFullEndElement();

pWriter->WriteStartElement(NULL,L"encryption",NULL);
pWriter->WriteString(L"none");
pWriter->WriteFullEndElement();

pWriter->WriteStartElement(NULL,L"useOneX",NULL);
pWriter->WriteString(L"false");
pWriter->WriteFullEndElement(); //useOneX

pWriter->WriteFullEndElement(); //authEncryption

pWriter->WriteFullEndElement(); // security
pWriter->WriteFullEndElement(); // MSM
pWriter->WriteFullEndElement(); // wlanProfile
pWriter->WriteEndDocument();
pWriter->Flush();

// create a COM object to read the XML file
hr = CoCreateInstance(
CLSID_DOMDocument60,
NULL,
CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument2,
(void**)&pXmlDoc
);
if (hr != S_OK)
{
dwError = WIN32_FROM_HRESULT(hr);
return dwError;
}
hr = pXmlDoc->load((CComVariant)TempStr, &vbSuccess);
if (hr != S_OK || vbSuccess != VARIANT_TRUE)
{
dwError = ERROR_BAD_PROFILE;
return dwError;
}

hr = pXmlDoc->get_xml(&bstrXml);
if (hr != S_OK)
{
dwError = ERROR_BAD_PROFILE;
return dwError;

}

ZeroMemory(&dot11Ssid,sizeof(DOT11_SSID));
StringWToSsid(xmlToWlan->SSID,&dot11Ssid);
wlanConnPara.wlanConnectionMode = wlan_connection_mode_temporary_profile;
wlanConnPara.pDot11Ssid = &dot11Ssid;
wlanConnPara.strProfile = bstrXml;
wlanConnPara.dot11BssType = dot11_BSS_type_infrastructure;
wlanConnPara.pDesiredBssidList = NULL;
wlanConnPara.dwFlags = WLAN_CONNECTION_IGNORE_PRIVACY_BIT;

dwError = WlanConnect(
wlandevice,
&AdapterGUID,
&wlanConnPara,
NULL // reserved
);
maic zhu
2012-02-21 08:03:43 UTC
Permalink
I also meet the question at this time, when I try to use WlanConnect function to connect an AP(WEP),I failed. I know there must some wrong about the parameters what I set. It is probably the XML profile. But I reality don't know how to change it after I try anything what I can thing. Do you help me? Thanks very much, I will appreciate to it.
Looking forward to reply.

my code is as follow:


TCHAR xmlData[][33] = {
_T("Temp"),//_T("Profile Name"),
_T("PAN"),//_T("SSID"),
_T("ESS"),//_T("Connection Type"),
_T("auto"),//_T("Connection Mode"),
_T("open"),//_T("Authentication"),
_T("WEP"),//_T("Encryption"),
_T("false"),//_T("UseOnex")
_T("networkKey"),//_T("KeyType")
_T("1234567890"),//_t(KeyNum)
};

TCHAR xmlProfile[8192];
_stprintf_s( xmlProfile, _T("\
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n\
<WLANProfile xmlns=\"http://www.microsoft.com/networking/WLAN/profile/v1\">\r\n\
\t<name>%s</name>\r\n\
\t<SSIDConfig>\r\n\
\t\t<SSID>\r\n\
\t\t\t<name>%s</name>\r\n\
\t\t</SSID>\r\n\
\t</SSIDConfig>\r\n\
\t<connectionType>%s</connectionType>\r\n\
\t<connectionMode>%s</connectionMode>\r\n\
\t<autoSwitch>false</autoSwitch>\r\n\
\t<MSM>\r\n\
\t\t<security>\r\n\
\t\t\t<authEncryption>\r\n\
\t\t\t\t<authentication>%s</authentication>\r\n\
\t\t\t\t<encryption>%s</encryption>\r\n\
\t\t\t\t<useOneX>%s</useOneX>\r\n\
\t\t\t</authEncryption>\r\n\
\t\t\t<sharedKey>\r\n\
\t\t\t\t<keyType>%s</keyType>\r\n\
\t\t\t\t<protected>false</protected>\r\n\
\t\t\t\t<keyMaterial>%s</keyMaterial>\r\n\
\t\t\t</sharedKey>\r\n\
\t\t</security>\r\n\
\t</MSM>\r\n\
</WLANProfile>\r\n"),
xmlData[0],
xmlData[1],
xmlData[2],
xmlData[3],
xmlData[4],
xmlData[5],
xmlData[6],
xmlData[7],
xmlData[8]
);

WlanConPara.wlanConnectionMode =wlan_connection_mode_temporary_profile;
WlanConPara.strProfile = bstrXml;
WlanConPara.pDot11Ssid =(PDOT11_SSID)&pAvaiNet->dot11Ssid;
WlanConPara.pDesiredBssidList = NULL;
WlanConPara.dot11BssType = dot11_BSS_type_infrastructure;
WlanConPara.dwFlags =(WLAN_CONNECTION_EAPOL_PASSTHROUGH | WLAN_CONNECTION_IGNORE_PRIVACY_BIT);

dwResult=WlanConnect(hClient,&(pIntfList->InterfaceInfo->InterfaceGuid),&WlanConPara,NULL);
Post by kevin
I am developing my WiFi easy config module on Vista. I found Vista SDK
defines WLAN_CONNECTION_IGNORE_PRIVACY_BIT. In wlanapi.h, it is said that
this flag is for easy config association.
But when I use this flag in my code, it doesn't take effect. I create a
temporary profile with OPEN Authentication and NONE encryption. Then use
WlanConnect with this profile to connect to an WPA-AP. WlanConnect returns
SUCCESS, but I cannot capture any authentication request and association
request sent out.
Can anyone help on this issue? Is there any example on how to use this bit?
Post by kevin
pWriter->WriteStartDocument(XmlStandalone_Omit);
pWriter->WriteStartElement(NULL,L"WLANProfile",NULL);
pWriter->WriteAttributeString(L"p1",L"xmlns",NULL,L"http://www.microsoft.com/networking/WLAN/profile/v1");
ReadWriteXML_Name(TRUE,xmlToWlan,L"name",pWriter);
ReadWriteXML_SSID(TRUE,xmlToWlan,L"SSIDConfig",pWriter);
pWriter->WriteStartElement(NULL,L"connectionType",NULL);
pWriter->WriteString(L"ESS");
pWriter->WriteFullEndElement();
pWriter->WriteStartElement(NULL,L"connectionMode",NULL);
pWriter->WriteString(L"auto");
pWriter->WriteFullEndElement();
pWriter->WriteStartElement(NULL,L"MSM",NULL);
pWriter->WriteStartElement(NULL,L"security",NULL);
pWriter->WriteStartElement(NULL,L"authEncryption",NULL);
pWriter->WriteStartElement(NULL,L"authentication",NULL);
pWriter->WriteString(L"open");
pWriter->WriteFullEndElement();
pWriter->WriteStartElement(NULL,L"encryption",NULL);
pWriter->WriteString(L"none");
pWriter->WriteFullEndElement();
pWriter->WriteStartElement(NULL,L"useOneX",NULL);
pWriter->WriteString(L"false");
pWriter->WriteFullEndElement(); //useOneX
pWriter->WriteFullEndElement(); //authEncryption
pWriter->WriteFullEndElement(); // security
pWriter->WriteFullEndElement(); // MSM
pWriter->WriteFullEndElement(); // wlanProfile
pWriter->WriteEndDocument();
pWriter->Flush();
// create a COM object to read the XML file
hr = CoCreateInstance(
CLSID_DOMDocument60,
NULL,
CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument2,
(void**)&pXmlDoc
);
if (hr != S_OK)
{
dwError = WIN32_FROM_HRESULT(hr);
return dwError;
}
hr = pXmlDoc->load((CComVariant)TempStr, &vbSuccess);
if (hr != S_OK || vbSuccess != VARIANT_TRUE)
{
dwError = ERROR_BAD_PROFILE;
return dwError;
}
hr = pXmlDoc->get_xml(&bstrXml);
if (hr != S_OK)
{
dwError = ERROR_BAD_PROFILE;
return dwError;
}
ZeroMemory(&dot11Ssid,sizeof(DOT11_SSID));
StringWToSsid(xmlToWlan->SSID,&dot11Ssid);
wlanConnPara.wlanConnectionMode = wlan_connection_mode_temporary_profile;
wlanConnPara.pDot11Ssid = &dot11Ssid;
wlanConnPara.strProfile = bstrXml;
wlanConnPara.dot11BssType = dot11_BSS_type_infrastructure;
wlanConnPara.pDesiredBssidList = NULL;
wlanConnPara.dwFlags = WLAN_CONNECTION_IGNORE_PRIVACY_BIT;
dwError = WlanConnect(
wlandevice,
&AdapterGUID,
&wlanConnPara,
NULL // reserved
);
Loading...