Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
4.5 KiB

  1. // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
  2. // NOTE: Do not modify the contents of this file. If this class is regenerated by
  3. // Microsoft Visual C++, your modifications will be overwritten.
  4. #include "stdafx.h"
  5. #include "inetmgrapp.h"
  6. #include "impexp.h"
  7. #include "iisuiobj.h"
  8. extern CInetmgrApp theApp;
  9. inline HRESULT SetBlanket(LPUNKNOWN pIUnk)
  10. {
  11. return CoSetProxyBlanket( pIUnk,
  12. RPC_C_AUTHN_WINNT, // NTLM authentication service
  13. RPC_C_AUTHZ_NONE, // default authorization service...
  14. NULL, // no mutual authentication
  15. RPC_C_AUTHN_LEVEL_DEFAULT, // authentication level
  16. RPC_C_IMP_LEVEL_IMPERSONATE, // impersonation level
  17. NULL, // use current token
  18. EOAC_NONE ); // no special capabilities
  19. }
  20. HRESULT DoNodeExportConfig(BSTR bstrMachineName,BSTR bstrUserName,BSTR bstrUserPassword,BSTR bstrMetabasePath)
  21. {
  22. HRESULT hResult = E_FAIL;
  23. BOOL bPleaseDoCoUninit = FALSE;
  24. IImportExportConfig *pTheObject = NULL;
  25. CLSID clsID;
  26. if (!bstrMetabasePath)
  27. {
  28. return HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER);
  29. }
  30. if(FAILED(hResult = CoInitialize(NULL)))
  31. {
  32. return hResult;
  33. }
  34. bPleaseDoCoUninit = TRUE;
  35. if (FAILED(hResult = CLSIDFromProgID(OLESTR("IISUIObj.ImportExportConfig"), &clsID)))
  36. {
  37. goto DoNodeExportConfig_Exit;
  38. }
  39. if (FAILED(hResult = CoCreateInstance(clsID,NULL,CLSCTX_SERVER,__uuidof(IImportExportConfig),(void **)&pTheObject)))
  40. {
  41. goto DoNodeExportConfig_Exit;
  42. }
  43. SetBlanket(pTheObject);
  44. // at this point we were able to instantiate the com object on the server (local or remote)
  45. if (bstrMachineName)
  46. {
  47. hResult = pTheObject->put_MachineName(bstrMachineName);
  48. }
  49. if (bstrUserName)
  50. {
  51. hResult = pTheObject->put_UserName(bstrUserName);
  52. }
  53. if (bstrUserPassword)
  54. {
  55. hResult = pTheObject->put_UserPassword(bstrUserPassword);
  56. }
  57. {
  58. // ensure the dialog gets themed
  59. CThemeContextActivator activator(theApp.GetFusionInitHandle());
  60. // call the export object
  61. if (FAILED(hResult= pTheObject->ExportConfigToFileUI(bstrMetabasePath)))
  62. {
  63. goto DoNodeExportConfig_Exit;
  64. }
  65. }
  66. DoNodeExportConfig_Exit:
  67. if (pTheObject)
  68. {
  69. pTheObject->Release();
  70. pTheObject = NULL;
  71. }
  72. if (bPleaseDoCoUninit)
  73. {
  74. CoUninitialize();
  75. }
  76. return hResult;
  77. }
  78. HRESULT DoNodeImportConfig(BSTR bstrMachineName,BSTR bstrUserName,BSTR bstrUserPassword,BSTR bstrMetabasePath,BSTR bstrKeyType)
  79. {
  80. HRESULT hResult = E_FAIL;
  81. BOOL bPleaseDoCoUninit = FALSE;
  82. IImportExportConfig *pTheObject = NULL;
  83. CLSID clsID;
  84. if (!bstrMetabasePath)
  85. {
  86. return HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER);
  87. }
  88. if (!bstrKeyType)
  89. {
  90. return HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER);
  91. }
  92. if(FAILED(hResult = CoInitialize(NULL)))
  93. {
  94. return hResult;
  95. }
  96. bPleaseDoCoUninit = TRUE;
  97. if (FAILED(hResult = CLSIDFromProgID(OLESTR("IISUIObj.ImportExportConfig"), &clsID)))
  98. {
  99. goto DoNodeImportConfig_Exit;
  100. }
  101. if (FAILED(hResult = CoCreateInstance(clsID,NULL,CLSCTX_SERVER,__uuidof(IImportExportConfig),(void **)&pTheObject)))
  102. {
  103. goto DoNodeImportConfig_Exit;
  104. }
  105. SetBlanket(pTheObject);
  106. // at this point we were able to instantiate the com object on the server (local or remote)
  107. if (bstrMachineName)
  108. {
  109. hResult = pTheObject->put_MachineName(bstrMachineName);
  110. }
  111. if (bstrUserName)
  112. {
  113. hResult = pTheObject->put_UserName(bstrUserName);
  114. }
  115. if (bstrUserPassword)
  116. {
  117. hResult = pTheObject->put_UserPassword(bstrUserPassword);
  118. }
  119. {
  120. // ensure the dialog gets themed
  121. CThemeContextActivator activator(theApp.GetFusionInitHandle());
  122. // call the import object
  123. if (FAILED(hResult = pTheObject->ImportConfigFromFileUI(bstrMetabasePath,bstrKeyType)))
  124. {
  125. goto DoNodeImportConfig_Exit;
  126. }
  127. }
  128. DoNodeImportConfig_Exit:
  129. if (pTheObject)
  130. {
  131. pTheObject->Release();
  132. pTheObject = NULL;
  133. }
  134. if (bPleaseDoCoUninit)
  135. {
  136. CoUninitialize();
  137. }
  138. return hResult;
  139. }