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.

171 lines
5.7 KiB

  1. class CGroupPolicyObject;
  2. typedef struct _GLPARAM
  3. {
  4. BOOL fFinding;
  5. BOOL fAbort;
  6. CGroupPolicyObject * pGPO;
  7. } GLPARAM;
  8. typedef struct _GLTHREADPARAM
  9. {
  10. HWND hDlg;
  11. BOOL * pfAbort;
  12. CGroupPolicyObject * pGPO;
  13. LPOLESTR pszLDAPName;
  14. } GLTHREADPARAM;
  15. #define PDM_CHANGEBUTTONTEXT (WM_USER + 1000)
  16. //
  17. // CGroupPolicyObject class
  18. //
  19. class CGroupPolicyObject : public IGroupPolicyObject
  20. {
  21. public:
  22. CGroupPolicyObject();
  23. ~CGroupPolicyObject();
  24. //
  25. // IUnknown methods
  26. //
  27. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  28. STDMETHODIMP_(ULONG) AddRef();
  29. STDMETHODIMP_(ULONG) Release();
  30. //
  31. // Implemented IGroupPolicyObject methods
  32. //
  33. STDMETHOD(New) (LPOLESTR pszDomainName, LPOLESTR pszDisplayName, DWORD dwFlags);
  34. STDMETHOD(OpenDSGPO) (LPOLESTR pszPath, DWORD dwFlags);
  35. STDMETHOD(OpenLocalMachineGPO) (DWORD dwFlags);
  36. STDMETHOD(OpenRemoteMachineGPO) (LPOLESTR pszCompterName, DWORD dwFlags);
  37. STDMETHOD(Save) (BOOL bMachine, BOOL bAdd, GUID *pGuidExtension, GUID *pGuidSnapin );
  38. STDMETHOD(Delete) (void);
  39. STDMETHOD(GetName) (LPOLESTR pszName, int cchMaxLength);
  40. STDMETHOD(GetDisplayName) (LPOLESTR pszName, int cchMaxLength);
  41. STDMETHOD(SetDisplayName) (LPOLESTR pszName);
  42. STDMETHOD(GetPath) (LPOLESTR pszPath, int cchMaxPath);
  43. STDMETHOD(GetDSPath) (DWORD dwSection, LPOLESTR pszPath, int cchMaxPath);
  44. STDMETHOD(GetFileSysPath) (DWORD dwSection, LPOLESTR pszPath, int cchMaxPath);
  45. STDMETHOD(GetRegistryKey) (DWORD dwSection, HKEY *hKey);
  46. STDMETHOD(GetOptions) (DWORD *dwOptions);
  47. STDMETHOD(SetOptions) (DWORD dwOptions, DWORD dwMask);
  48. STDMETHOD(GetType) (GROUP_POLICY_OBJECT_TYPE *gpoType);
  49. STDMETHOD(GetMachineName) (LPOLESTR pszName, int cchMaxLength);
  50. STDMETHOD(GetPropertySheetPages) (HPROPSHEETPAGE **hPages, UINT *uPageCount);
  51. //
  52. // Internal methods
  53. //
  54. STDMETHOD(CreateContainer) (LPOLESTR lpParent, LPOLESTR lpCommonName, BOOL bGPC);
  55. STDMETHOD(SetDisplayNameI) (IADs * pADs, LPOLESTR lpDisplayName,
  56. LPOLESTR lpGPTPath, BOOL bUpdateDisplayVar);
  57. STDMETHOD(SetGPOInfo) (LPOLESTR lpGPO, LPOLESTR lpDisplayName, LPOLESTR lpGPTPath);
  58. STDMETHOD(CheckFSWriteAccess) (LPOLESTR lpLocalGPO);
  59. STDMETHOD(GetSecurityDescriptor) (IADs *pADs, SECURITY_INFORMATION si,
  60. PSECURITY_DESCRIPTOR *pSD);
  61. BOOL EnableSecurityPrivs(void);
  62. DWORD EnableInheritance (PACL pAcl);
  63. DWORD SetSysvolSecurity (LPTSTR lpFileSysPath, SECURITY_INFORMATION si,
  64. PSECURITY_DESCRIPTOR pSD);
  65. STDMETHOD(CleanUp) (void);
  66. STDMETHOD(RefreshGroupPolicy) (BOOL bMachine);
  67. static HRESULT WINAPI ReadSecurityDescriptor (LPCWSTR lpGPOPath, SECURITY_INFORMATION si, PSECURITY_DESCRIPTOR *pSD, LPARAM lpContext);
  68. static HRESULT WINAPI WriteSecurityDescriptor (LPCWSTR lpGPOPath, SECURITY_INFORMATION si, PSECURITY_DESCRIPTOR pSD, LPARAM lpContext);
  69. static INT_PTR CALLBACK WQLFilterDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  70. static INT_PTR CALLBACK PropertiesDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  71. static INT_PTR CALLBACK GPELinksDlgProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  72. static DWORD WINAPI GLThreadFunc(GLTHREADPARAM * pgltp);
  73. DWORD WINAPI FindLinkInDomain(GLTHREADPARAM * pgltp, LPTSTR lpGPO);
  74. DWORD WINAPI FindLinkInSite(GLTHREADPARAM * pgltp, LPTSTR lpGPO);
  75. BOOL FillDomainList (HWND hWndCombo);
  76. private:
  77. HRESULT GetProperty( TCHAR *pszProp, XPtrST<TCHAR>& xValueIn );
  78. HRESULT SetProperty( TCHAR *pszProp, TCHAR *pszPropValue );
  79. ULONG m_cRef;
  80. BOOL m_bInitialized;
  81. IADs *m_pADs;
  82. GROUP_POLICY_OBJECT_TYPE m_gpoType;
  83. DWORD m_dwFlags;
  84. LPOLESTR m_pName;
  85. LPOLESTR m_pDisplayName;
  86. LPOLESTR m_pMachineName;
  87. CRegistryHive *m_pUser;
  88. CRegistryHive *m_pMachine;
  89. HINSTANCE m_hinstDSSec;
  90. PFNDSCREATESECPAGE m_pfnDSCreateSecurityPage;
  91. LPTSTR m_pTempFilterString;
  92. public:
  93. LPOLESTR m_pDSPath;
  94. LPOLESTR m_pFileSysPath;
  95. };
  96. //
  97. // GroupPolicyObject class factory
  98. //
  99. class CGroupPolicyObjectCF : public IClassFactory
  100. {
  101. protected:
  102. ULONG m_cRef;
  103. public:
  104. CGroupPolicyObjectCF();
  105. ~CGroupPolicyObjectCF();
  106. // IUnknown methods
  107. STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  108. STDMETHODIMP_(ULONG) AddRef();
  109. STDMETHODIMP_(ULONG) Release();
  110. // IClassFactory methods
  111. STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *);
  112. STDMETHODIMP LockServer(BOOL);
  113. };
  114. //
  115. // Strings
  116. //
  117. #define GPO_VERSION_PROPERTY L"versionNumber"
  118. #define GPT_PATH_PROPERTY L"gPCFileSysPath"
  119. #define GPO_NAME_PROPERTY L"displayName"
  120. #define GPO_OPTIONS_PROPERTY L"flags"
  121. #define GPO_FUNCTION_PROPERTY L"gPCFunctionalityVersion"
  122. #define GPO_WQLFILTER_PROPERTY L"gPCWQLFilter"
  123. #define GPO_USEREXTENSION_NAMES L"gPCUserExtensionNames"
  124. #define GPO_MACHEXTENSION_NAMES L"gPCMachineExtensionNames"
  125. #define LOCAL_GPO_DIRECTORY TEXT("%SystemRoot%\\System32\\GroupPolicy")
  126. #define REMOTE_GPO_DIRECTORY TEXT("\\\\%s\\ADMIN$\\System32\\GroupPolicy")
  127. #define SITE_NAME_PROPERTY L"name"
  128. #define DOMAIN_NAME_PROPERTY L"name"
  129. //
  130. // Functionality version
  131. //
  132. #define GPO_FUNCTIONALITY_VERSION 2