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.

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