Source code of Windows XP (NT5)
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.

155 lines
5.3 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright(C) 1999-2000 Microsoft Corporation all rights reserved.
  4. //
  5. // Module: migrateregistry.cpp
  6. //
  7. // Project: Windows 2000 IAS
  8. //
  9. // Description: IAS NT 4 Registry to IAS W2K MDB Migration Logic
  10. //
  11. // Author: TLP 1/13/1999
  12. //
  13. //
  14. // Revision 02/24/2000 Moved to a separate dll
  15. //
  16. /////////////////////////////////////////////////////////////////////////////
  17. #include "stdafx.h"
  18. #include "migrateregistry.h"
  19. //////////////////////////////////////////////////////////////////////////////
  20. // DeleteAuthSrvService
  21. //////////////////////////////////////////////////////////////////////////////
  22. LONG CMigrateRegistry::DeleteAuthSrvService()
  23. {
  24. LONG Result = ERROR_CAN_NOT_COMPLETE;
  25. SC_HANDLE hServiceManager;
  26. SC_HANDLE hService;
  27. if ( NULL != (hServiceManager = OpenSCManager(
  28. NULL,
  29. NULL,
  30. SC_MANAGER_ALL_ACCESS
  31. )) )
  32. {
  33. if ( NULL != (hService = OpenService(
  34. hServiceManager,
  35. L"AuthSrv",
  36. SERVICE_ALL_ACCESS
  37. )) )
  38. {
  39. DeleteService(hService);
  40. CloseServiceHandle(hService);
  41. }
  42. Result = ERROR_SUCCESS;
  43. CloseServiceHandle(hServiceManager);
  44. }
  45. return Result;
  46. }
  47. //////////////////////////////////////////////////////////////////////////////
  48. // MigrateProviders
  49. //////////////////////////////////////////////////////////////////////////////
  50. void CMigrateRegistry::MigrateProviders()
  51. {
  52. const int MAX_EXTENSION_DLLS_STRING_SIZE = 4096;
  53. const WCHAR AUTHSRV_KEY[] = L"SYSTEM\\CurrentControlSet"
  54. L"\\Services\\AuthSrv";
  55. const WCHAR AUTHSRV_PROVIDERS_EXTENSION_DLL_VALUE[] = L"ExtensionDLLs";
  56. HKEY hKeyAuthSrvParameter;
  57. LONG Result = RegOpenKeyEx(
  58. HKEY_LOCAL_MACHINE,
  59. CUtils::AUTHSRV_PARAMETERS_KEY,
  60. 0,
  61. KEY_ALL_ACCESS,
  62. &hKeyAuthSrvParameter
  63. );
  64. if ( Result != ERROR_SUCCESS )
  65. {
  66. _com_issue_error(HRESULT_FROM_WIN32(Result));
  67. }
  68. BYTE szProvidersExtensionDLLs[MAX_EXTENSION_DLLS_STRING_SIZE] = "";
  69. DWORD lSizeBuffer = MAX_EXTENSION_DLLS_STRING_SIZE;
  70. LONG ExtensionDLLResult = RegQueryValueEx(
  71. hKeyAuthSrvParameter,
  72. AUTHSRV_PROVIDERS_EXTENSION_DLL_VALUE,
  73. NULL,
  74. NULL,
  75. szProvidersExtensionDLLs,
  76. &lSizeBuffer
  77. );
  78. RegCloseKey(hKeyAuthSrvParameter);
  79. DeleteAuthSrvService(); //ignore the result
  80. CRegKey RegKey;
  81. Result = RegKey.Open(HKEY_LOCAL_MACHINE, CUtils::SERVICES_KEY);
  82. if ( Result == ERROR_SUCCESS )
  83. {
  84. RegKey.RecurseDeleteKey(L"AuthSrv"); //result not checked
  85. }
  86. if ( ExtensionDLLResult == ERROR_SUCCESS ) //ExtensionsDLLs to restore
  87. {
  88. HKEY hKeyAuthSrv;
  89. DWORD dwDisposition;
  90. WCHAR EmptyString[] = L"";
  91. // re-create the AuthSrv key
  92. Result = RegCreateKeyEx(
  93. HKEY_LOCAL_MACHINE,
  94. AUTHSRV_KEY,
  95. 0,
  96. EmptyString,
  97. REG_OPTION_NON_VOLATILE,
  98. KEY_ALL_ACCESS,
  99. NULL,
  100. &hKeyAuthSrv,
  101. &dwDisposition
  102. );
  103. if ( Result != ERROR_SUCCESS )
  104. {
  105. _com_issue_error(HRESULT_FROM_WIN32(Result));
  106. }
  107. HKEY hKeyParameters;
  108. Result = RegCreateKeyEx(
  109. hKeyAuthSrv,
  110. L"Parameters",
  111. 0,
  112. EmptyString,
  113. REG_OPTION_NON_VOLATILE,
  114. KEY_ALL_ACCESS,
  115. NULL,
  116. &hKeyParameters,
  117. &dwDisposition
  118. );
  119. if ( Result != ERROR_SUCCESS )
  120. {
  121. _com_issue_error(HRESULT_FROM_WIN32(Result));
  122. }
  123. Result = RegSetValueEx(
  124. hKeyParameters,
  125. AUTHSRV_PROVIDERS_EXTENSION_DLL_VALUE,
  126. 0,
  127. REG_MULTI_SZ,
  128. szProvidersExtensionDLLs,
  129. lSizeBuffer
  130. );
  131. RegCloseKey(hKeyParameters);
  132. RegCloseKey(hKeyAuthSrv);
  133. }
  134. // Else no ExtensionDLL value to restore
  135. }