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.

186 lines
6.6 KiB

  1. /*++
  2. Microsoft Windows
  3. Copyright (C) Microsoft Corporation, 1981 - 1998
  4. Module Name:
  5. redir.hxx
  6. Abstract:
  7. See comments in redir.cxx
  8. Author:
  9. Rahul Thombre (RahulTh) 8/11/1998
  10. Revision History:
  11. 8/11/1998 RahulTh Created this module.
  12. --*/
  13. #ifndef __REDIR_HXX__
  14. #define __REDIR_HXX__
  15. // Homedir variable
  16. #define HOMEDIR_STR L"%HOMESHARE%%HOMEPATH%"
  17. //enumeration type to keep track of whether shares are online/offline/local
  18. typedef enum tagSHARESTATUS
  19. {
  20. PathLocal,
  21. ShareOffline,
  22. ShareOnline,
  23. NoCSC
  24. } SHARESTATUS;
  25. //the redirection flags in the ini file.
  26. typedef enum tagREDIR
  27. {
  28. REDIR_MOVE_CONTENTS = 0x1, //move contents of the folder
  29. REDIR_FOLLOW_PARENT = 0x2, //special descendants should follow the parent
  30. REDIR_DONT_CARE = 0x4, //policy has no effect on the location
  31. REDIR_SCALEABLE = 0x8, //only used by the snapin ui
  32. REDIR_SETACLS = 0x10, //if set, acl check will be performed
  33. REDIR_RELOCATEONREMOVE= 0x20 //if set, it means that the contents should not be orphaned upon policy removal
  34. } REDIR;
  35. //an enumeration of the folders that can be redirected.
  36. //note: parent folders must appear before their children.
  37. typedef enum tagRedirectable
  38. {
  39. Desktop = 0,
  40. MyDocs,
  41. MyPics,
  42. StartMenu,
  43. Programs,
  44. Startup,
  45. AppData,
  46. EndRedirectable
  47. } REDIRECTABLE;
  48. //forward declarations
  49. class CFileDB;
  50. class CSavedSettings;
  51. class CRedirectInfo
  52. {
  53. friend CRedirectInfo; //useful in merging using overloaded assignment methods
  54. friend class CRedirectionPolicy;
  55. public:
  56. CRedirectInfo();
  57. ~CRedirectInfo();
  58. static REDIRECTABLE GetFolderIndex (LPCTSTR szFldrName);
  59. void ResetMembers (void);
  60. DWORD LoadLocalizedNames (void);
  61. DWORD GatherRedirectionInfo (CFileDB * pFileDB, DWORD dwFlags, BOOL bRemove);
  62. const DWORD GetFlags (void);
  63. const DWORD GetRedirStatus (void);
  64. const BOOL WasRedirectionAttempted (void);
  65. LPCTSTR GetLocation (void);
  66. LPCTSTR GetLocalizedName (void);
  67. DWORD Redirect (HANDLE hUserToken,
  68. HKEY hKeyRoot,
  69. CFileDB* pFileDB);
  70. void UpdateDescendant (void);
  71. CRedirectInfo& operator= (const CRedirectInfo& ri); //overloaded assignment : used for merging
  72. DWORD PerformRedirection (CFileDB * pFileDB,
  73. BOOL bSourceValid,
  74. WCHAR * pwszSource,
  75. WCHAR * pwszDest,
  76. SHARESTATUS StatusFrom,
  77. SHARESTATUS StatusTo,
  78. HANDLE hUserToken
  79. );
  80. void PreventRedirection (DWORD Status);
  81. void PreventDescendantRedirection (DWORD Status);
  82. DWORD ComputeEffectivePolicyRemoval (PGROUP_POLICY_OBJECT pDeletedGPOList,
  83. PGROUP_POLICY_OBJECT pChangedGPOList,
  84. CFileDB * pFileDB);
  85. BOOL HasPolicy();
  86. //private data members
  87. private:
  88. static int m_idConstructor;
  89. REDIRECTABLE m_rID;
  90. CRedirectInfo* m_pChild;
  91. CRedirectInfo* m_pParent;
  92. TCHAR* m_szLocation;
  93. DWORD m_cbLocSize;
  94. TCHAR m_szFolderRelativePath[80]; //80 characters ought to be enough for
  95. //the display name of the folder.
  96. TCHAR m_szDisplayName[80]; //the display name of the folder.
  97. TCHAR m_szLocFolderRelativePath[80]; //localized relative path.
  98. TCHAR m_szLocDisplayName[80]; //localized display name.
  99. DWORD m_dwFlags; //the redirection flags as obtained from
  100. BOOL m_bRemove; //the redirection is actually due to a policy removal
  101. BOOL m_fDataValid;
  102. PSID m_pSid; //the sid of the group that was used to redirect the user
  103. BOOL m_bValidGPO; //if a valid GPO name is stored in m_szGPOName;
  104. WCHAR m_szGPOName[50]; //the GPO name (if any) that results in the redirection
  105. //notes::::::
  106. //normally in order to determine if a child is supposed to follow the parent
  107. //one can use m_dwFlags & REDIR_FOLLOW_PARENT. However, this information
  108. //gets lost when UpdateDescendant is invoked as it sets the redirection
  109. //settings based on its parent. In fact, after this, if
  110. //m_dwFlags & REDIR_FOLLOW_PARENT still succeeds, it is an indication of
  111. //the fact that UpdateDescendant failed. Thus, in the redirection phase
  112. //we need to keep track of whether a child was supposed to follow the parent
  113. //or not so that redirection of a child is not attempted if that of the
  114. //parent fails
  115. //hence the following variable is used to keep track of whether a child
  116. //was supposed to follow the parent or not
  117. BOOL m_bFollowsParent;
  118. //the following variable is used to keep track of whether redirection has
  119. //already been attempted for this particular folder. This is necessary
  120. //because redirection of special descendants may be attempted via their
  121. //parents as well as via the normal iteration in ProcessGroupPolicy so
  122. //we don't want to attempt the redirection twice
  123. BOOL m_bRedirectionAttempted;
  124. //also, we must record the return code whenever we attempt redirection
  125. //so that we can record the same code when redirection is attempted again.
  126. //this is necessary because when redirection of a special descendant folder
  127. //is attempted via the parent, then this is the only place where its return
  128. //value is recorded. When redirection of the special descendant is attempted
  129. //again in the normal iteration in ProcessGroupPolicy, the Redirect member
  130. //function returns the value stored in m_StatusRedirection which is then
  131. //recorded by ProcessGroupPolicy and reported back to the policy engine
  132. //this ensures that the wrong value is never recorded for any folder and
  133. //that the policy engine never gets back an incorrect return value.
  134. DWORD m_StatusRedir;
  135. WCHAR* m_szGroupRedirectionData;
  136. DWORD m_iRedirectingGroup; // For RSoP -- index in the ini file
  137. // of the group causing this redirection
  138. //private helper functions
  139. private:
  140. BOOL ShouldSaveExpandedPath(void);
  141. void FreeAllocatedMem (void);
  142. };
  143. //put the extern declarations here so that redir.[ch]xx encompass all
  144. //the info. and variables related to redirection.
  145. extern const int g_lRedirInfoSize;
  146. extern CRedirectInfo gPolicyResultant[]; //size specified in redir.cxx
  147. extern CRedirectInfo gDeletedPolicyResultant[];
  148. extern CRedirectInfo gAddedPolicyResultant[];
  149. //other global vars
  150. extern WCHAR * g_szRelativePathNames[];
  151. extern WCHAR * g_szDisplayNames[];
  152. #endif //__REDIR_HXX__