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.

276 lines
5.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: domcache.h
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 3-29-96 RichardW Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifdef DATA_TYPES_ONLY
  18. //
  19. // Domain specific types
  20. //
  21. //
  22. // Define the structure that controls the trusted domain cache
  23. //
  24. typedef enum _DOMAIN_ENTRY_TYPE {
  25. DomainInvalid, // 0 never valid
  26. DomainUPN, // Special UPN domain
  27. DomainMachine, // Local machine domain
  28. DomainNt4, // An NT4 domain
  29. DomainNt5, // An NT5 domain
  30. DomainMitRealm, // An MIT realm
  31. DomainMitUntrusted, // An untrusted MIT realm
  32. DomainNetworkProvider, // A fake entry
  33. DomainTypeMax
  34. } DOMAIN_ENTRY_TYPE ;
  35. typedef struct _DOMAIN_CACHE_ENTRY {
  36. LONG RefCount ; // Ref Count
  37. ULONG Flags ; // Flags (below)
  38. DOMAIN_ENTRY_TYPE Type ; // Type of entry
  39. UNICODE_STRING FlatName ; // Flat name of object (OPTIONAL)
  40. UNICODE_STRING DnsName ; // Dns name of object (OPTIONAL)
  41. UNICODE_STRING DisplayName ; // Display Name
  42. } DOMAIN_CACHE_ENTRY, * PDOMAIN_CACHE_ENTRY ;
  43. #define DCE_DEFAULT_ENTRY 0x00000001 // This is displayed by default
  44. #define DCE_REACHABLE_MIT 0x00000002 // This MIT realm is reachable
  45. #define DCacheReferenceEntry( x ) InterlockedIncrement( &(x)->RefCount );
  46. typedef struct _DOMAIN_CACHE_ARRAY {
  47. ULONG Count ;
  48. ULONG MaxCount ;
  49. BOOL Sorted ;
  50. PDOMAIN_CACHE_ENTRY * List ;
  51. } DOMAIN_CACHE_ARRAY, * PDOMAIN_CACHE_ARRAY ;
  52. //
  53. // Keep these in order. They're used to determine UI behavior
  54. //
  55. typedef enum _DOMAIN_CACHE_STATE {
  56. DomainCacheEmpty, // got nothing
  57. DomainCacheDefaultOnly, // default values only (machine and primary domain)
  58. DomainCacheRegistryCache, // default + cached values
  59. DomainCacheReady // Fully up-to-date.
  60. } DOMAIN_CACHE_STATE ;
  61. typedef struct _DOMAIN_CACHE {
  62. //
  63. // Critical section that protects the data in this structure
  64. //
  65. CRITICAL_SECTION CriticalSection;
  66. //
  67. // Fields protected by that critical section:
  68. //
  69. //
  70. // Task that gets invoked if the domain changes.
  71. //
  72. HANDLE Task ;
  73. //
  74. // Window to be notified when the update thread completes
  75. //
  76. HWND UpdateNotifyWindow;
  77. UINT Message;
  78. //
  79. // last update time
  80. //
  81. LARGE_INTEGER CacheUpdateTime;
  82. LARGE_INTEGER RegistryUpdateTime ;
  83. HANDLE Key ;
  84. DOMAIN_CACHE_STATE State ;
  85. //
  86. // Default domain. Used only when there is an async thread running
  87. // so it can set the appropriate default name.
  88. //
  89. PWSTR DefaultDomain ;
  90. //
  91. // Flag indicating if we are in a MIT or Safemode state, which means
  92. // we shouldn't pester netlogon about trusted domains.
  93. //
  94. ULONG Flags ;
  95. #define DCACHE_MIT_MODE 0x00000001 // In MIT mode
  96. #define DCACHE_READ_ONLY 0x00000002 // Read-only copy of cache
  97. #define DCACHE_ASYNC_UPDATE 0x00000004 // Async thread running
  98. #define DCACHE_MEMBER 0x00000008 // This is a domain member
  99. #define DCACHE_NO_CACHE 0x00000010 // No cache was found
  100. #define DCACHE_DEF_UNKNOWN 0x00000020 // The default domain could not be found
  101. //
  102. // This pointer may *only* be accessed under the critical
  103. // section. This array will get swapped in and out, and
  104. // only references to it while it is locked are safe.
  105. //
  106. PDOMAIN_CACHE_ARRAY Array ;
  107. } DOMAIN_CACHE, *PDOMAIN_CACHE;
  108. #define DCACHE_UPDATE_CONFLICT 3
  109. #define DCACHE_UPDATE_COMBOBOX 2
  110. #define DCACHE_UPDATE_SUCCESSFUL 1
  111. #define DCACHE_UPDATE_FAILURE 0
  112. #else // DATA_TYPES_ONLY
  113. #define WM_CACHE_UPDATE_COMPLETE WM_USER+256
  114. //
  115. // Exported function prototypes
  116. //
  117. BOOL
  118. DCacheInitialize(
  119. VOID
  120. );
  121. VOID
  122. DCacheDereferenceEntry(
  123. PDOMAIN_CACHE_ENTRY Entry
  124. );
  125. PDOMAIN_CACHE_ENTRY
  126. DCacheSearchArray(
  127. PDOMAIN_CACHE_ARRAY Array,
  128. PUNICODE_STRING DomainName
  129. );
  130. PDOMAIN_CACHE
  131. DCacheCreate(
  132. VOID
  133. );
  134. PDOMAIN_CACHE_ENTRY
  135. DCacheCreateEntry(
  136. DOMAIN_ENTRY_TYPE Type,
  137. PUNICODE_STRING FlatName OPTIONAL,
  138. PUNICODE_STRING DnsName OPTIONAL,
  139. PUNICODE_STRING DisplayName OPTIONAL
  140. );
  141. BOOL
  142. DCacheUpdateMinimal(
  143. PDOMAIN_CACHE Cache,
  144. PWSTR DefaultDomain OPTIONAL,
  145. BOOL CompleteAsync
  146. );
  147. BOOL
  148. DCacheUpdateFull(
  149. PDOMAIN_CACHE Cache,
  150. PWSTR Default OPTIONAL
  151. );
  152. PDOMAIN_CACHE_ARRAY
  153. DCacheCopyCacheArray(
  154. PDOMAIN_CACHE Cache
  155. );
  156. VOID
  157. DCacheFreeArray(
  158. PDOMAIN_CACHE_ARRAY Array
  159. );
  160. BOOL
  161. DCacheSetNotifyWindowIfNotReady(
  162. PDOMAIN_CACHE Cache,
  163. HWND Window,
  164. UINT Message
  165. );
  166. BOOL
  167. DCachePopulateListBoxFromArray(
  168. PDOMAIN_CACHE_ARRAY Array,
  169. HWND ComboBox,
  170. LPWSTR LastKey OPTIONAL
  171. );
  172. BOOL
  173. DCacheAddNetworkProviders(
  174. PDOMAIN_CACHE_ARRAY Array
  175. );
  176. BOOL
  177. DCacheValidateCache(
  178. PDOMAIN_CACHE Cache
  179. );
  180. DOMAIN_CACHE_STATE
  181. DCacheGetCacheState(
  182. PDOMAIN_CACHE Cache
  183. );
  184. ULONG
  185. DCacheGetFlags(
  186. PDOMAIN_CACHE Cache
  187. );
  188. BOOL
  189. DCacheAddNetworkProviders(
  190. PDOMAIN_CACHE_ARRAY Array
  191. );
  192. BOOL
  193. DCacheSetDefaultEntry(
  194. PDOMAIN_CACHE Cache,
  195. PWSTR FlatName OPTIONAL,
  196. PWSTR DnsName OPTIONAL
  197. );
  198. PDOMAIN_CACHE_ENTRY
  199. DCacheLocateEntry(
  200. PDOMAIN_CACHE Cache,
  201. PWSTR Domain
  202. );
  203. #endif