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.

221 lines
6.6 KiB

  1. //*************************************************************
  2. //
  3. // Copyright (c) Microsoft Corporation 1999 - 2000
  4. // All rights reserved
  5. //
  6. // log.hxx
  7. //
  8. // Contains declarations for classes related to rsop logging
  9. // for the folder redirection client-side extension
  10. //
  11. // Created: 8-01-1999 adamed
  12. //
  13. //*************************************************************
  14. #if !defined(__LOG_HXX__)
  15. #define __LOG_HXX__
  16. //
  17. // The prefix to the scope of management is always "LDAP://" --
  18. // this constant refers to the length of that prefix
  19. //
  20. #define SOMID_PREFIX_LEN 7
  21. #define REPORT_ATTRIBUTE_SET_STATUS( x , y ) \
  22. { \
  23. if (FAILED( y )) \
  24. { \
  25. DebugMsg((DM_VERBOSE, IDS_RSOP_ATTRIBUTE_FAIL, x, y)); \
  26. } \
  27. }
  28. #define WQL_INSTANCE L"NOT id = \"%s\""
  29. #define WQL_AND L" AND "
  30. #define EVERYONE_WELLKNOWN_SID L"S-1-1-0"
  31. WCHAR* StringDuplicate(WCHAR* wszOriginal);
  32. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  33. //
  34. // Class: CRedirectionPolicy
  35. //
  36. // Synopsis: This class describes each folder that could be
  37. // redirected by folder redirection policy and abstracts
  38. // its persistence operations through an rsop schema
  39. //
  40. // Notes:
  41. //
  42. //-------------------------------------------------------------
  43. class CRedirectionPolicy : public CPolicyRecord
  44. {
  45. public:
  46. CRedirectionPolicy(
  47. CFileDB* pGpoData,
  48. CRedirectInfo* rgRedirect,
  49. LONG Precedence,
  50. HRESULT* phr);
  51. ~CRedirectionPolicy();
  52. //
  53. // Operations
  54. //
  55. HRESULT Write();
  56. HRESULT Initialize();
  57. void NormalizePrecedence( LONG Scale );
  58. HRESULT CopyInheritedData( CRedirectionPolicy* pAncestralPolicy );
  59. //
  60. // Information methods
  61. //
  62. int GetFolderIndex();
  63. int GetAncestorIndex();
  64. BOOL HasAncestor();
  65. BOOL HasInheritedData();
  66. BOOL IsRedirected();
  67. //
  68. // Public data
  69. //
  70. CRedirectionPolicy* _pNext; // Used to link these objects in a list
  71. private:
  72. HRESULT GetGroupInformation(
  73. WCHAR* wszGroupRedirectionData);
  74. HRESULT ParseGroupInformation(
  75. WCHAR* wszGroupRedirectionData,
  76. LONG* pCount,
  77. WCHAR** rgwszGroups = NULL,
  78. WCHAR** rgwszPaths = NULL);
  79. HRESULT GenerateInheritedPath(
  80. WCHAR* pwszAncestorPath,
  81. WCHAR** ppwszInheritedPath);
  82. HRESULT GenerateLocalInheritedPath(
  83. WCHAR** ppwszInheritedPath );
  84. //
  85. // The following two arrays are parallel arrays
  86. //
  87. WCHAR** _rgwszGroups; // Security groups applying to this redirection
  88. WCHAR** _rgwszRedirectedPaths; // Paths to which the folder is redirected for each of the groups in _rgwszGroups
  89. LONG _cGroups; // Number of paths / security groups to which folder could be redirected
  90. LONG _Precedence; // Precedence of this redirection with respect to other redirections
  91. UNICODE_STRING _RedirectedSid; // Sid that caused this to redirect
  92. WCHAR* _wszRedirectedPath; // Location to which this folder is redirected
  93. WCHAR* _wszGPODSPath; // unique ds path of gpo from which this redirection came
  94. WCHAR* _wszDisplayName; // Display name of the folder
  95. WCHAR* _wszLocalizedName; // Localized file system name of the folder
  96. WCHAR* _wszSOMId; // Scope of management to which this policy applied
  97. DWORD _dwFlags; // Redirection flags
  98. HRESULT _hrInit; // Result of object initialization
  99. int _iFolderIndex; // Index referring to the folder
  100. int _iAncestorIndex; // Index to this folder's ancestor (parent) folder
  101. BOOL _bHasAncestor; // TRUE if this folder has an ancestor
  102. BOOL _bMissingAncestor; // TRUE if this folder has an ancestor, but
  103. // no policy was specified for that ancestor
  104. CFileDB* _pGpoData; // needed to pass to utility functions
  105. };
  106. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  107. //
  108. // Class: CPrecedenceState
  109. //
  110. // Synopsis: This class keeps track of the precedence relationships
  111. // between redirected folders. It is used to assign
  112. // precedence to each candidate redirection policy
  113. //
  114. // Notes:
  115. //
  116. //-------------------------------------------------------------
  117. class CPrecedenceState
  118. {
  119. public:
  120. CPrecedenceState();
  121. LONG UpdateFolderPrecedence( int iFolder );
  122. LONG GetFolderPrecedence( int iFolder );
  123. private:
  124. LONG _rgFolderPrecedence[ EndRedirectable ]; // stores precedence of each winning policy for each folder
  125. };
  126. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  127. //
  128. // Class: CRedirectionLog
  129. //
  130. // Synopsis: This class abstracts the logging of folder redirection
  131. // policy and provides methods to persist a representation
  132. // of the folder redirection policy via rsop schema
  133. //
  134. // Notes:
  135. //
  136. //-------------------------------------------------------------
  137. class CRedirectionLog : public CPolicyLog
  138. {
  139. public:
  140. CRedirectionLog();
  141. ~CRedirectionLog();
  142. HRESULT AddRedirectionPolicies(
  143. CFileDB* pGpoData,
  144. CRedirectInfo* pRedirectionInfo);
  145. void
  146. InitRsop( CRsopContext* pRsopContext, BOOL bForceRsop );
  147. HRESULT WriteRsopLog();
  148. HRESULT AddPreservedPolicy( WCHAR* wszFolderName );
  149. void SimulatePlanningError( DWORD Status );
  150. DWORD GetPlanningSimulatedErrorIfNecessary( DWORD Status );
  151. private:
  152. CRedirectionPolicy* GetAncestor( CRedirectionPolicy* pRedirectionPolicy );
  153. void NormalizePrecedence( CRedirectionPolicy* pRedirectionPolicy );
  154. void ClearRsopLog();
  155. HRESULT AddAncestralPolicy( CRedirectionPolicy* pRedirectionPolicy );
  156. CRedirectionPolicy* _pRedirectionList; // List of all candidate redirections
  157. CRedirectionPolicy** _ppNextRedirection; // Pointer to reference to end of list
  158. CPrecedenceState _PrecedenceState; // State of the precedence relationships among candidate redirections
  159. WCHAR* _wszDeletionQuery; // Query used to clear settings
  160. DWORD _SimulatedStatus; // Simulated error status in planning mode
  161. };
  162. #endif // __LOG_HXX__