// Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++ // NOTE: Do not modify the contents of this file. If this class is regenerated by // Microsoft Visual C++, your modifications will be overwritten. #include "stdafx.h" #include "inetmgrapp.h" #include "impexp.h" #include "iisuiobj.h" extern CInetmgrApp theApp; inline HRESULT SetBlanket(LPUNKNOWN pIUnk) { return CoSetProxyBlanket( pIUnk, RPC_C_AUTHN_WINNT, // NTLM authentication service RPC_C_AUTHZ_NONE, // default authorization service... NULL, // no mutual authentication RPC_C_AUTHN_LEVEL_DEFAULT, // authentication level RPC_C_IMP_LEVEL_IMPERSONATE, // impersonation level NULL, // use current token EOAC_NONE ); // no special capabilities } HRESULT DoNodeExportConfig(BSTR bstrMachineName,BSTR bstrUserName,BSTR bstrUserPassword,BSTR bstrMetabasePath) { HRESULT hResult = E_FAIL; BOOL bPleaseDoCoUninit = FALSE; IImportExportConfig *pTheObject = NULL; CLSID clsID; if (!bstrMetabasePath) { return HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER); } if(FAILED(hResult = CoInitialize(NULL))) { return hResult; } bPleaseDoCoUninit = TRUE; if (FAILED(hResult = CLSIDFromProgID(OLESTR("IISUIObj.ImportExportConfig"), &clsID))) { goto DoNodeExportConfig_Exit; } if (FAILED(hResult = CoCreateInstance(clsID,NULL,CLSCTX_SERVER,__uuidof(IImportExportConfig),(void **)&pTheObject))) { goto DoNodeExportConfig_Exit; } SetBlanket(pTheObject); // at this point we were able to instantiate the com object on the server (local or remote) if (bstrMachineName) { hResult = pTheObject->put_MachineName(bstrMachineName); } if (bstrUserName) { hResult = pTheObject->put_UserName(bstrUserName); } if (bstrUserPassword) { hResult = pTheObject->put_UserPassword(bstrUserPassword); } { // ensure the dialog gets themed CThemeContextActivator activator(theApp.GetFusionInitHandle()); // call the export object if (FAILED(hResult= pTheObject->ExportConfigToFileUI(bstrMetabasePath))) { goto DoNodeExportConfig_Exit; } } DoNodeExportConfig_Exit: if (pTheObject) { pTheObject->Release(); pTheObject = NULL; } if (bPleaseDoCoUninit) { CoUninitialize(); } return hResult; } HRESULT DoNodeImportConfig(BSTR bstrMachineName,BSTR bstrUserName,BSTR bstrUserPassword,BSTR bstrMetabasePath,BSTR bstrKeyType) { HRESULT hResult = E_FAIL; BOOL bPleaseDoCoUninit = FALSE; IImportExportConfig *pTheObject = NULL; CLSID clsID; if (!bstrMetabasePath) { return HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER); } if (!bstrKeyType) { return HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER); } if(FAILED(hResult = CoInitialize(NULL))) { return hResult; } bPleaseDoCoUninit = TRUE; if (FAILED(hResult = CLSIDFromProgID(OLESTR("IISUIObj.ImportExportConfig"), &clsID))) { goto DoNodeImportConfig_Exit; } if (FAILED(hResult = CoCreateInstance(clsID,NULL,CLSCTX_SERVER,__uuidof(IImportExportConfig),(void **)&pTheObject))) { goto DoNodeImportConfig_Exit; } SetBlanket(pTheObject); // at this point we were able to instantiate the com object on the server (local or remote) if (bstrMachineName) { hResult = pTheObject->put_MachineName(bstrMachineName); } if (bstrUserName) { hResult = pTheObject->put_UserName(bstrUserName); } if (bstrUserPassword) { hResult = pTheObject->put_UserPassword(bstrUserPassword); } { // ensure the dialog gets themed CThemeContextActivator activator(theApp.GetFusionInitHandle()); // call the import object if (FAILED(hResult = pTheObject->ImportConfigFromFileUI(bstrMetabasePath,bstrKeyType))) { goto DoNodeImportConfig_Exit; } } DoNodeImportConfig_Exit: if (pTheObject) { pTheObject->Release(); pTheObject = NULL; } if (bPleaseDoCoUninit) { CoUninitialize(); } return hResult; }