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.

82 lines
1.9 KiB

  1. #include "precomp.h"
  2. DWORD
  3. ExportPoliciesToFile(
  4. HANDLE hSrcPolicyStore,
  5. HANDLE hDesPolicyStore
  6. )
  7. {
  8. DWORD dwError = 0;
  9. PIPSEC_POLICY_STORE pDesPolicyStore = NULL;
  10. PIPSEC_POLICY_DATA * ppIpsecPolicyData = NULL;
  11. DWORD dwNumPolicyObjects = 0;
  12. pDesPolicyStore = (PIPSEC_POLICY_STORE) hDesPolicyStore;
  13. dwError = ExportFilterDataToFile(
  14. hSrcPolicyStore,
  15. pDesPolicyStore
  16. );
  17. dwError = ExportNegPolDataToFile(
  18. hSrcPolicyStore,
  19. pDesPolicyStore
  20. );
  21. dwError = ExportISAKMPDataToFile(
  22. hSrcPolicyStore,
  23. pDesPolicyStore
  24. );
  25. BAIL_ON_WIN32_ERROR(dwError);
  26. dwError = ExportPolicyDataToFile(
  27. hSrcPolicyStore,
  28. pDesPolicyStore,
  29. &ppIpsecPolicyData,
  30. &dwNumPolicyObjects
  31. );
  32. BAIL_ON_WIN32_ERROR(dwError);
  33. dwError = ExportNFADataToFile(
  34. hSrcPolicyStore,
  35. pDesPolicyStore,
  36. ppIpsecPolicyData,
  37. dwNumPolicyObjects
  38. );
  39. BAIL_ON_WIN32_ERROR(dwError);
  40. dwError = EnablePrivilege(
  41. SE_BACKUP_NAME
  42. );
  43. BAIL_ON_WIN32_ERROR(dwError);
  44. _wremove(pDesPolicyStore->pszFileName);
  45. dwError = RegSaveKeyW(
  46. pDesPolicyStore->hRegistryKey,
  47. pDesPolicyStore->pszFileName,
  48. NULL
  49. );
  50. BAIL_ON_WIN32_ERROR(dwError);
  51. error:
  52. if (ppIpsecPolicyData) {
  53. FreeMulIpsecPolicyData(
  54. ppIpsecPolicyData,
  55. dwNumPolicyObjects
  56. );
  57. }
  58. FlushRegSaveKey(
  59. pDesPolicyStore->hRegistryKey
  60. );
  61. return (dwError);
  62. }