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.

250 lines
13 KiB

  1. //*************************************************************
  2. //
  3. // Group Policy Processing
  4. //
  5. // Microsoft Confidential
  6. // Copyright (c) Microsoft Corporation 1997-1998
  7. // All rights reserved
  8. //
  9. // History: 28-Oct-98 SitaramR Created
  10. //
  11. //*************************************************************
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. void InitializeGPOCriticalSection();
  16. void CloseGPOCriticalSection();
  17. BOOL InitializePolicyProcessing(BOOL bMachine);
  18. #define ECP_FAIL_ON_WAIT_TIMEOUT 1
  19. HANDLE WINAPI EnterCriticalPolicySectionEx (BOOL bMachine, DWORD dwTimeOut, DWORD dwFlags );
  20. #ifdef __cplusplus
  21. }
  22. #endif
  23. //
  24. // These keys are used in gpt.c. The per user per machine keys will
  25. // be deleted when profile gets deleted. Changes in the following keys
  26. // should be reflected in the prefixes as well...
  27. //
  28. #define GP_SHADOW_KEY TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\Shadow\\%ws")
  29. #define GP_HISTORY_KEY TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\History\\%ws")
  30. #define GP_STATE_KEY TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\State\\%ws")
  31. #define GP_STATE_ROOT_KEY TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\State")
  32. #define GP_SHADOW_SID_KEY TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\%ws\\Shadow\\%ws")
  33. #define GP_HISTORY_SID_KEY TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\%ws\\History\\%ws")
  34. #define GP_EXTENSIONS_KEY TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\GPExtensions\\%ws")
  35. #define GP_EXTENSIONS_SID_KEY TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\%ws\\GPExtensions\\%ws")
  36. #define GP_HISTORY_SID_ROOT_KEY TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\%ws\\History")
  37. #define GP_MEMBERSHIP_KEY TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\%ws\\GroupMembership")
  38. #define GP_EXTENSIONS_SID_ROOT_KEY TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\%ws\\GPExtensions")
  39. #define GP_POLICY_SID_KEY TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Group Policy\\%ws")
  40. #define GP_LOGON_SID_KEY TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\%ws")
  41. #define GPCORE_GUID TEXT("{00000000-0000-0000-0000-000000000000}")
  42. //
  43. // Comon prefix for both history and shadow
  44. //
  45. #define GP_XXX_SID_PREFIX TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Group Policy")
  46. #define GP_EXTENSIONS_SID_PREFIX TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon")
  47. //
  48. // Structures
  49. //
  50. //
  51. // Structure used to represent GP status from the previous policy run.
  52. //
  53. typedef struct _GPEXTSTATUS {
  54. DWORD dwSlowLink; // Slow link when policy applied previously ?
  55. DWORD dwRsopLogging; // Rsop Logging when policy applied previously ?
  56. DWORD dwStatus; // Status returned previously
  57. HRESULT dwRsopStatus; // Rsop Status returned previously
  58. DWORD dwTime; // Time when the policy was applied previously
  59. BOOL bStatus; // If we failed to read the per ext status data
  60. BOOL bForceRefresh; // force refresh in this foreground prcessing..
  61. } GPEXTSTATUS, *LPGPEXTSTATUS;
  62. typedef struct _GPEXT {
  63. LPTSTR lpDisplayName; // Display name
  64. LPTSTR lpKeyName; // Extension name
  65. LPTSTR lpDllName; // Dll name
  66. LPSTR lpFunctionName; // Entry point name
  67. LPSTR lpRsopFunctionName; // Rsop entry point name
  68. HMODULE hInstance; // Handle to dll
  69. PFNPROCESSGROUPPOLICY pEntryPoint; // Entry point for ProcessGPO
  70. PFNPROCESSGROUPPOLICYEX pEntryPointEx; // Diagnostic mode or Ex entry point
  71. PFNGENERATEGROUPPOLICY pRsopEntryPoint; // Entry point for Rsop planning mode
  72. BOOL bNewInterface; // Are we using the new Ex entry point interface ?
  73. DWORD dwNoMachPolicy; // Mach policy setting
  74. DWORD dwNoUserPolicy; // User policy setting
  75. DWORD dwNoSlowLink; // Slow link setting
  76. DWORD dwNoBackgroundPolicy; // Background policy setting
  77. DWORD dwNoGPOChanges; // GPO changes setting
  78. DWORD dwUserLocalSetting; // Per user per machine setting
  79. DWORD dwRequireRegistry; // RequireSuccReg setting
  80. DWORD dwEnableAsynch; // Enable asynchronous processing setting
  81. DWORD dwLinkTransition; // Link speed transition setting
  82. DWORD dwMaxChangesInterval; // Max interval (mins) for which NoGpoChanges is adhered to
  83. BOOL bRegistryExt; // Is this the psuedo reg extension ?
  84. BOOL bSkipped; // Should processing be skipped for this extension ?
  85. BOOL bHistoryProcessing; // Is processing needed to clean up cached Gpos ?
  86. BOOL bForcedRefreshNextFG; // Forced refresh next time it is processed in foreground.
  87. BOOL bRsopTransition; // Rsop Transition ?
  88. GUID guid; // Guid of extension
  89. LPGPEXTSTATUS lpPrevStatus; // Previous Status
  90. LPTSTR szEventLogSources; // "(userenv,Application)\0(print,System)\0....\0"
  91. struct _GPEXT *pNext; // Singly linked list pointer
  92. } GPEXT, *LPGPEXT;
  93. typedef struct _GPOPROCDATA { // Data that is needed while processing the data
  94. BOOL bProcessGPO; // Actually add the GPOs to the processing list
  95. PLDAP pLdapHandle; // LDAP handle corresponding to the query
  96. } GPOPROCDATA, *LPGPOPROCDATA;
  97. typedef struct _EXTLIST {
  98. GUID guid; // Extension guid
  99. struct _EXTLIST *pNext; // Singly linked list pointer
  100. } EXTLIST, *LPEXTLIST;
  101. typedef struct _EXTFILTERLIST {
  102. PGROUP_POLICY_OBJECT lpGPO; // GPO
  103. LPEXTLIST lpExtList; // List of extension guids that apply to lpGPO
  104. BOOL bLogged; // Is this link logged to RSoP db ?
  105. struct _EXTFILTERLIST *pNext; // Singly linked list pointer
  106. } EXTFILTERLIST, *LPEXTFILTERLIST;
  107. typedef struct _GPLINK {
  108. LPWSTR pwszGPO; // DS path to Gpo
  109. BOOL bEnabled; // Is this link disabled ?
  110. BOOL bNoOverride; // Is Gpo enforced ?
  111. struct _GPLINK *pNext; // Gpo linked in SOM order
  112. } GPLINK, *LPGPLINK;
  113. typedef struct _SCOPEOFMGMT {
  114. LPWSTR pwszSOMId; // Dn name of SOM
  115. DWORD dwType; // Type of SOM
  116. BOOL bBlocking; // Does SOM have policies blocked from above ?
  117. BOOL bBlocked; // This SOM is blocked by a SOM below ?
  118. LPGPLINK pGpLinkList; // List of GPOs linked to this SOM
  119. struct _SCOPEOFMGMT *pNext;
  120. } SCOPEOFMGMT, *LPSCOPEOFMGMT;
  121. typedef struct _GPCONTAINER {
  122. LPWSTR pwszDSPath; // DS path to Gpo
  123. LPWSTR pwszGPOName; // Guid from of Gpo name
  124. LPWSTR pwszDisplayName; // Friendly name
  125. LPWSTR pwszFileSysPath; // Sysvol path to Gpo
  126. BOOL bFound; // Gpo found ?
  127. BOOL bAccessDenied; // Access denied ?
  128. BOOL bUserDisabled; // Disabled for user policy ?
  129. BOOL bMachDisabled; // Disabled for machine policy ?
  130. DWORD dwUserVersion; // Version # for user policy
  131. DWORD dwMachVersion; // Version # for machine policy
  132. PSECURITY_DESCRIPTOR pSD; // ACL on Gpo
  133. DWORD cbSDLen; // Length of security descriptor in bytes
  134. BOOL bFilterAllowed; // Does Gpo pass filter check ?
  135. WCHAR *pwszFilterId; // Filter id
  136. LPWSTR szSOM; // SOM that this GPO is linked to
  137. DWORD dwOptions; // GPO options
  138. struct _GPCONTAINER *pNext; // Linked list ptr
  139. } GPCONTAINER, *LPGPCONTAINER;
  140. typedef struct _GPOINFO {
  141. DWORD dwFlags;
  142. INT iMachineRole;
  143. HANDLE hToken;
  144. PRSOPTOKEN pRsopToken;
  145. WCHAR * lpDNName;
  146. HANDLE hEvent;
  147. HKEY hKeyRoot;
  148. BOOL bXferToExtList; // Has the ownership been transferred from lpGPOList to lpExtFilterList ?
  149. LPEXTFILTERLIST lpExtFilterList; // List of extensions to be filtered, cardinality is same as GetGPOList's list
  150. PGROUP_POLICY_OBJECT lpGPOList; // Filtered GPO List, can vary from one extension to next
  151. LPTSTR lpwszSidUser; // Sid of user in string form
  152. HANDLE hTriggerEvent;
  153. HANDLE hForceTriggerEvent; // force trigger event
  154. HANDLE hNotifyEvent;
  155. HANDLE hNeedFGEvent;
  156. HANDLE hDoneEvent;
  157. HANDLE hCritSection;
  158. LPGPEXT lpExtensions;
  159. BOOL bMemChanged; // Has security group membership has changed ?
  160. BOOL bUserLocalMemChanged; // Has membership changed on per user local basis ?
  161. BOOL bSidChanged; // Has the Sid changed since the last policy run?
  162. PFNSTATUSMESSAGECALLBACK pStatusCallback;
  163. LPSCOPEOFMGMT lpSOMList; // LSDOU list
  164. LPGPCONTAINER lpGpContainerList; // GP container list for Rsop logging
  165. LPSCOPEOFMGMT lpLoopbackSOMList; // Loopback LSDOU list
  166. LPGPCONTAINER lpLoopbackGpContainerList; // Loopback container list for Rsop logging
  167. BOOL bFGCoInitialized; // CoInitialize called on foreground thread ?
  168. BOOL bBGCoInitialized; // CoInitialize called on background thread ?
  169. IWbemServices * pWbemServices; // Namespace pointer for Rsop logging
  170. LPTSTR szName; // Full Name of the User/Computer
  171. LPTSTR szTargetName; // Rsop TargetName
  172. BOOL bRsopLogging; // Is Rsop Logging turned on ?
  173. BOOL bRsopCreated; // Rsop Name Space was created now ?
  174. LPWSTR szSiteName; // site name of the target
  175. } GPOINFO, *LPGPOINFO;
  176. typedef struct _ADMFILEINFO {
  177. WCHAR * pwszFile; // Adm file path
  178. WCHAR * pwszGPO; // Gpo that the adm file is in
  179. FILETIME ftWrite; // Last write time of Adm file
  180. struct _ADMFILEINFO * pNext; // Singly linked list pointer
  181. } ADMFILEINFO;
  182. typedef struct _RSOPSESSIONDATA {
  183. WCHAR * pwszTargetName; // Target user or computer
  184. WCHAR * pwszSOM; // New group of target
  185. PTOKEN_GROUPS pSecurityGroups; // Security IDs of the new groups for target
  186. BOOL bLogSecurityGroup; // Log the security groups
  187. WCHAR * pwszSite; // Site of target
  188. BOOL bMachine; // Machine or user policy processing ?
  189. BOOL bSlowLink; // policy applied over slow link?
  190. } RSOPSESSIONDATA, *LPRSOPSESSIONDATA;
  191. typedef struct _RSOPEXTSTATUS {
  192. FILETIME ftStartTime; // times between which the associated
  193. FILETIME ftEndTime; // extension was processed
  194. DWORD dwStatus; // Processing status
  195. DWORD dwLoggingStatus; // Logging Status
  196. BOOL bValid; // this struct is valid and can be used
  197. } RSOPEXTSTATUS, *LPRSOPEXTSTATUS;
  198. BOOL RsopDeleteUserNameSpace(LPTSTR szComputer, LPTSTR lpSid);
  199. DWORD SaveLoggingStatus(LPWSTR szSid, LPGPEXT lpExt, RSOPEXTSTATUS *lpRsopExtStatus);
  200. DWORD ReadLoggingStatus(LPWSTR szSid, LPWSTR szExtId, RSOPEXTSTATUS *lpRsopExtStatus);