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.

187 lines
6.9 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. REDIRECTABLE GetFolderID(void);
  66. LPCTSTR GetLocation (void);
  67. LPCTSTR GetLocalizedName (void);
  68. DWORD Redirect (HANDLE hUserToken,
  69. HKEY hKeyRoot,
  70. CFileDB* pFileDB);
  71. DWORD UpdateDescendant (void);
  72. CRedirectInfo& operator= (const CRedirectInfo& ri); //overloaded assignment : used for merging
  73. DWORD PerformRedirection (CFileDB * pFileDB,
  74. BOOL bSourceValid,
  75. WCHAR * pwszSource,
  76. WCHAR * pwszDest,
  77. SHARESTATUS StatusFrom,
  78. SHARESTATUS StatusTo,
  79. HANDLE hUserToken
  80. );
  81. void PreventRedirection (DWORD Status);
  82. void PreventDescendantRedirection (DWORD Status);
  83. DWORD ComputeEffectivePolicyRemoval (PGROUP_POLICY_OBJECT pDeletedGPOList,
  84. PGROUP_POLICY_OBJECT pChangedGPOList,
  85. CFileDB * pFileDB);
  86. BOOL HasPolicy();
  87. //private data members
  88. private:
  89. static int m_idConstructor;
  90. REDIRECTABLE m_rID;
  91. CRedirectInfo* m_pChild;
  92. CRedirectInfo* m_pParent;
  93. TCHAR* m_szLocation;
  94. DWORD m_cbLocSize;
  95. TCHAR m_szFolderRelativePath[80]; //80 characters ought to be enough for
  96. //the display name of the folder.
  97. TCHAR m_szDisplayName[80]; //the display name of the folder.
  98. TCHAR m_szLocFolderRelativePath[80]; //localized relative path.
  99. TCHAR m_szLocDisplayName[80]; //localized display name.
  100. DWORD m_dwFlags; //the redirection flags as obtained from
  101. BOOL m_bRemove; //the redirection is actually due to a policy removal
  102. BOOL m_fDataValid;
  103. PSID m_pSid; //the sid of the group that was used to redirect the user
  104. BOOL m_bValidGPO; //if a valid GPO name is stored in m_szGPOName;
  105. WCHAR m_szGPOName[50]; //the GPO name (if any) that results in the redirection
  106. //notes::::::
  107. //normally in order to determine if a child is supposed to follow the parent
  108. //one can use m_dwFlags & REDIR_FOLLOW_PARENT. However, this information
  109. //gets lost when UpdateDescendant is invoked as it sets the redirection
  110. //settings based on its parent. In fact, after this, if
  111. //m_dwFlags & REDIR_FOLLOW_PARENT still succeeds, it is an indication of
  112. //the fact that UpdateDescendant failed. Thus, in the redirection phase
  113. //we need to keep track of whether a child was supposed to follow the parent
  114. //or not so that redirection of a child is not attempted if that of the
  115. //parent fails
  116. //hence the following variable is used to keep track of whether a child
  117. //was supposed to follow the parent or not
  118. BOOL m_bFollowsParent;
  119. //the following variable is used to keep track of whether redirection has
  120. //already been attempted for this particular folder. This is necessary
  121. //because redirection of special descendants may be attempted via their
  122. //parents as well as via the normal iteration in ProcessGroupPolicy so
  123. //we don't want to attempt the redirection twice
  124. BOOL m_bRedirectionAttempted;
  125. //also, we must record the return code whenever we attempt redirection
  126. //so that we can record the same code when redirection is attempted again.
  127. //this is necessary because when redirection of a special descendant folder
  128. //is attempted via the parent, then this is the only place where its return
  129. //value is recorded. When redirection of the special descendant is attempted
  130. //again in the normal iteration in ProcessGroupPolicy, the Redirect member
  131. //function returns the value stored in m_StatusRedirection which is then
  132. //recorded by ProcessGroupPolicy and reported back to the policy engine
  133. //this ensures that the wrong value is never recorded for any folder and
  134. //that the policy engine never gets back an incorrect return value.
  135. DWORD m_StatusRedir;
  136. WCHAR* m_szGroupRedirectionData;
  137. DWORD m_iRedirectingGroup; // For RSoP -- index in the ini file
  138. // of the group causing this redirection
  139. //private helper functions
  140. private:
  141. BOOL ShouldSaveExpandedPath(void);
  142. void FreeAllocatedMem (void);
  143. };
  144. //put the extern declarations here so that redir.[ch]xx encompass all
  145. //the info. and variables related to redirection.
  146. extern const int g_lRedirInfoSize;
  147. extern CRedirectInfo gPolicyResultant[]; //size specified in redir.cxx
  148. extern CRedirectInfo gDeletedPolicyResultant[];
  149. extern CRedirectInfo gAddedPolicyResultant[];
  150. //other global vars
  151. extern WCHAR * g_szRelativePathNames[];
  152. extern WCHAR * g_szDisplayNames[];
  153. #endif //__REDIR_HXX__