diff --git a/EAPMethods/src/Main_UI.cpp b/EAPMethods/src/Main_UI.cpp index e2337a5..c930f08 100644 --- a/EAPMethods/src/Main_UI.cpp +++ b/EAPMethods/src/Main_UI.cpp @@ -193,17 +193,17 @@ DWORD WINAPI EapPeerConfigBlob2Xml( HRESULT hr; // Create configuration XML document. - com_obj pDoc; - if (FAILED(hr = pDoc.create(CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER))) { + com_obj pConfigDoc; + if (FAILED(hr = pConfigDoc.create(CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER))) { g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = HRESULT_CODE(hr), _T(__FUNCTION__) _T(" Error creating XML document."))); return dwResult; } - pDoc->put_async(VARIANT_FALSE); + pConfigDoc->put_async(VARIANT_FALSE); // Load empty XML configuration. VARIANT_BOOL isSuccess = VARIANT_FALSE; - if (FAILED((hr = pDoc->loadXML(L"", &isSuccess)))) { + if (FAILED((hr = pConfigDoc->loadXML(L"", &isSuccess)))) { g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = HRESULT_CODE(hr), _T(__FUNCTION__) _T(" Error loading XML document template."))); return dwResult; } @@ -214,16 +214,16 @@ DWORD WINAPI EapPeerConfigBlob2Xml( // Select node. com_obj pXmlElConfig; - pDoc->setProperty(bstr(L"SelectionNamespaces"), variant(L"xmlns:eaphostconfig=\"http://www.microsoft.com/provisioning/EapHostConfig\"")); - if (FAILED(eapxml::select_node(pDoc, bstr(L"eaphostconfig:Config"), &pXmlElConfig))) { + pConfigDoc->setProperty(bstr(L"SelectionNamespaces"), variant(L"xmlns:eaphostconfig=\"http://www.microsoft.com/provisioning/EapHostConfig\"")); + if (FAILED(eapxml::select_node(pConfigDoc, bstr(L"eaphostconfig:Config"), &pXmlElConfig))) { g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_FOUND, _T(__FUNCTION__) _T(" Error selecting element."))); return dwResult; } // Save configuration. - pDoc->setProperty(bstr(L"SelectionNamespaces"), variant(L"xmlns:eap-metadata=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\"")); + pConfigDoc->setProperty(bstr(L"SelectionNamespaces"), variant(L"xmlns:eap-metadata=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\"")); try { - g_peer.config_blob2xml(dwFlags, pConnectionData, dwConnectionDataSize, pDoc, pXmlElConfig); + g_peer.config_blob2xml(dwFlags, pConnectionData, dwConnectionDataSize, pConfigDoc, pXmlElConfig); } catch (std::exception &err) { g_peer.log_error(*ppEapError = g_peer.make_error(err)); return dwResult = (*ppEapError)->dwWinError; @@ -231,7 +231,7 @@ DWORD WINAPI EapPeerConfigBlob2Xml( return dwResult = ERROR_INVALID_DATA; } - *ppConfigDoc = pDoc.detach(); + *ppConfigDoc = pConfigDoc.detach(); } return dwResult; diff --git a/lib/EAPBase/src/Config.cpp b/lib/EAPBase/src/Config.cpp index 4d177e0..9364806 100644 --- a/lib/EAPBase/src/Config.cpp +++ b/lib/EAPBase/src/Config.cpp @@ -666,10 +666,10 @@ void eap::config_connection::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode * const bstr bstrNamespace(L"urn:ietf:params:xml:ns:yang:ietf-eap-metadata"); HRESULT hr; - // Select node. - com_obj pXmlElIdentityProviderList; - if (FAILED(hr = eapxml::select_node(pConfigRoot, bstr(L"eap-metadata:EAPIdentityProviderList"), &pXmlElIdentityProviderList))) - throw com_runtime_error(hr, __FUNCTION__ " Error selecting element."); + // Create node. + com_obj pXmlElIdentityProviderList; + if (FAILED(hr = eapxml::create_element(pDoc, bstr(L"EAPIdentityProviderList"), bstrNamespace, &pXmlElIdentityProviderList))) + throw com_runtime_error(hr, __FUNCTION__ " Error creating element."); for (provider_list::const_iterator provider = m_providers.cbegin(), provider_end = m_providers.cend(); provider != provider_end; ++provider) { // @@ -683,6 +683,9 @@ void eap::config_connection::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode * if (FAILED(hr = pXmlElIdentityProviderList->appendChild(pXmlElIdentityProvider, NULL))) throw com_runtime_error(hr, __FUNCTION__ " Error appending element."); } + + if (FAILED(hr = pConfigRoot->appendChild(pXmlElIdentityProviderList, NULL))) + throw com_runtime_error(hr, __FUNCTION__ " Error appending element."); }