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.

352 lines
9.3 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. netname.h
  5. Abstract:
  6. defines for netname resource DLL
  7. Author:
  8. Charlie Wickham (charlwi) 21-Jan-2001
  9. Environment:
  10. User Mode
  11. Revision History:
  12. --*/
  13. #include <windns.h>
  14. #include <dsgetdc.h>
  15. //
  16. // local defines
  17. //
  18. #define COUNT_OF( x ) ( sizeof( x ) / sizeof( x[0] ))
  19. #define NetNameLogEvent ClusResLogEvent
  20. //
  21. // module externs
  22. //
  23. extern ULONG NetNameWorkerCheckPeriod;
  24. extern LPWSTR NetNameCompObjAccountDesc;
  25. //
  26. // Resource Property constants
  27. //
  28. #define PARAM_NAME__NAME CLUSREG_NAME_NET_NAME
  29. #define PARAM_NAME__FLAGS CLUSREG_NAME_FLAGS
  30. #define PARAM_NAME__REMAP L"RemapPipeNames"
  31. #define PARAM_DEFAULT__REMAP FALSE
  32. #define PARAM_NAME__RANDOM L"Random"
  33. #define PARAM_NAME__LASTNAME L"LastName"
  34. #define PARAM_NAME__STATUS_NETBIOS L"StatusNetBIOS"
  35. #define PARAM_NAME__STATUS_DNS L"StatusDNS"
  36. #define PARAM_NAME__STATUS_KERBEROS L"StatusKerberos"
  37. #define PARAM_NAME__REQUIRE_DNS L"RequireDNS"
  38. #define PARAM_DEFAULT__REQUIRE_DNS 0
  39. #define PARAM_NAME__REQUIRE_KERBEROS L"RequireKerberos"
  40. #define PARAM_DEFAULT__REQUIRE_KERBEROS 0
  41. #define PARAM_NAME__NEXT_UPDATE L"NextUpdate"
  42. #define PARAM_NAME__UPDATE_INTERVAL L"UpdateInterval"
  43. #define PARAM_DEFAULT__UPDATE_INTERVAL ( 60 * 24 * 7 ) // 1 week
  44. #define PARAM_MINIMUM__UPDATE_INTERVAL ( 60 ) // 1 hour
  45. #define PARAM_MAXIMUM__UPDATE_INTERVAL ( 60 * 24 * 7 * 365 ) // 1 year
  46. //
  47. // netname worker thread check frequencies for when talking to the DNS server
  48. // goes as expected and when they don't. periods are in seconds. Short periods
  49. // are for testing.
  50. //
  51. //#define _SHORT_PERIODS
  52. #ifdef _SHORT_PERIODS
  53. #define NETNAME_WORKER_NORMAL_CHECK_PERIOD 60
  54. #define NETNAME_WORKER_PROBLEM_CHECK_PERIOD 60
  55. #define NETNAME_WORKER_PENDING_PERIOD 2
  56. #else
  57. #define NETNAME_WORKER_NORMAL_CHECK_PERIOD (60 * 60 * 24) // 24 hours
  58. #define NETNAME_WORKER_PROBLEM_CHECK_PERIOD (60 * 10) // 10 minutes
  59. #define NETNAME_WORKER_PENDING_PERIOD 60
  60. #endif
  61. //
  62. // this struct is used to hold the matched set of DNS A and PTR records with
  63. // which the network name's DNS name and reverse name are registered.
  64. // {Fwd,Rev}ZoneIsDynamic is used as a validity flag in the case where the
  65. // initial DnsUpdateTest call timed out and we later discover that this server
  66. // doesn't except updates. In that case, ZoneIsDynamic is set to FALSE and the
  67. // worker thread checks for these records are skipped.
  68. //
  69. // In hind sight, each record type should have had its own DNS_LIST entry
  70. // instead of putting both A and PTR together in one structure. This has led
  71. // to constructing an invalid list of PTR records in its
  72. // DNS_RRSET. Consequently, there is some ugly code in RegisterDnsRecords that
  73. // has to build a fake DNS_RRSET in order to get the PTR records registered.
  74. //
  75. typedef struct _DNS_LISTS {
  76. DNS_RRSET A_RRSet;
  77. DNS_STATUS LastARecQueryStatus;
  78. DNS_RRSET PTR_RRSet;
  79. DNS_STATUS LastPTRRecQueryStatus; // not used
  80. PIP4_ARRAY DnsServerList;
  81. LPWSTR ConnectoidName;
  82. //
  83. // TRUE if we couldn't contact the server during record build time. This
  84. // means that the worker thread will need to call DnsUpdateTest to
  85. // determine if the server is dynamic
  86. //
  87. BOOL UpdateTestTimeout;
  88. //
  89. // used to "invalidate" this entry if we discovered after online that the
  90. // server isn't dynamic
  91. //
  92. BOOL ForwardZoneIsDynamic;
  93. //
  94. // TRUE if we've already logged an error about this entry in the system
  95. // event log
  96. //
  97. BOOL AErrorLogged;
  98. //
  99. // PTR corresponding vars with same functionality as their A counterparts
  100. //
  101. BOOL ReverseZoneIsDynamic;
  102. BOOL PTRErrorLogged;
  103. } DNS_LISTS, *PDNS_LISTS;
  104. //
  105. // set this define to one to get addt'l debug spew to see the interaction with
  106. // the DNS server and determine if the RRSet structures are getting built
  107. // correctly.
  108. //
  109. #define DBG_DNSLIST 0
  110. //
  111. // this struct is used to hold the mapping between a cluster IP address and a
  112. // DNS domain name. The FQDN is built using these domain suffixes and the
  113. // cluster netname. The connectoid name is included so we can log over which
  114. // NIC we did the registration.
  115. //
  116. typedef struct _DOMAIN_ADDRESS_MAPPING {
  117. LPWSTR ConnectoidName;
  118. LPWSTR IpAddress;
  119. LPWSTR DomainName;
  120. PIP4_ARRAY DnsServerList;
  121. } DOMAIN_ADDRESS_MAPPING, *PDOMAIN_ADDRESS_MAPPING;
  122. //
  123. // backing structure for resource properties
  124. //
  125. typedef struct _NETNAME_PARAMS {
  126. //
  127. // the name that is currently online
  128. //
  129. LPWSTR NetworkName;
  130. //
  131. // true if RemapPipeNames set to one; used by SQL to remap virtual pipe
  132. // names to the node's name (?)
  133. //
  134. DWORD NetworkRemap;
  135. //
  136. // pointer to r/o encrypted computer object password
  137. //
  138. PBYTE NetworkRandom;
  139. //
  140. // R/W props: if set to TRUE, the respective section must succeed for the
  141. // resource to go online. RequireKerberos implies RequireDNS.
  142. //
  143. BOOL RequireDNS;
  144. BOOL RequireKerberos;
  145. //
  146. // read-only props that reflect final status codes for the corresponding
  147. // functionality
  148. //
  149. DWORD StatusNetBIOS;
  150. DWORD StatusDNS;
  151. DWORD StatusKerberos;
  152. //
  153. // read-only timestamp of when to perform next password update
  154. //
  155. FILETIME NextUpdate;
  156. //
  157. // R/W pwd update interval in minutes
  158. //
  159. // ISSUE: units should be changed to hours and maybe even days
  160. //
  161. DWORD UpdateInterval;
  162. } NETNAME_PARAMS, *PNETNAME_PARAMS;
  163. //
  164. // netname resource context block. One per instance of a netname resource.
  165. //
  166. typedef struct {
  167. LIST_ENTRY Next;
  168. LONG RefCount; // ref count on entire resource block
  169. CLUSTER_RESOURCE_STATE State;
  170. RESOURCE_HANDLE ResourceHandle; // handle to ourselves
  171. DWORD dwFlags;
  172. HANDLE * NameHandleList; // array of netbios w/s handles
  173. DWORD NameHandleCount;
  174. CLUS_WORKER PendingThread;
  175. LPWSTR NodeName;
  176. LPWSTR NodeId;
  177. //
  178. // handles to our resource key, resource parameters key and node
  179. // parameters keys as well as the resource itself
  180. //
  181. HKEY ResKey;
  182. HKEY ParametersKey;
  183. HKEY NodeParametersKey;
  184. HRESOURCE ClusterResourceHandle;
  185. //
  186. // used during online pending processing so we can keep increasing the
  187. // checkpoint value for each individual resource
  188. //
  189. ULONG StatusCheckpoint;
  190. //
  191. // count and pointer to the DNS publishing information; mutex is used to
  192. // sync access to DnsLists and NumberOfDnsLists
  193. //
  194. HANDLE DnsListMutex;
  195. DWORD NumberOfDnsLists;
  196. PDNS_LISTS DnsLists;
  197. //
  198. // holder of resource properties
  199. //
  200. NETNAME_PARAMS Params;
  201. //
  202. // used to handle case where the name property has changed while the
  203. // resource is online. If TRUE, then offline processing will take
  204. // appropriate steps to handle this condition.
  205. //
  206. BOOL NameChangedWhileOnline;
  207. //
  208. // number of bytes pointed to by Params.NetworkRandom
  209. //
  210. DWORD RandomSize;
  211. //
  212. // objectGUID attribute of the computer object from DS. Using the GUID
  213. // frees us from having to track object moves in the DS.
  214. //
  215. LPWSTR ObjectGUID;
  216. //
  217. // DoKerberosCheck is TRUE if AddComputerObject was successful. This is
  218. // used by the worker thread to check on the computer object. The status
  219. // returned by that check is stored in KerberosStatus.
  220. //
  221. BOOL DoKerberosCheck;
  222. DWORD KerberosStatus;
  223. //
  224. // used to track if we should delete the computer account at the DS when
  225. // the resource goes offline. This happens when RequireKerberos is changed
  226. // from one to zero. If we don't do this, client's will not fallback to
  227. // NTLM authentication when negotiating a security context.
  228. //
  229. BOOL DeleteCOWhenOffline;
  230. } NETNAME_RESOURCE, *PNETNAME_RESOURCE;
  231. //
  232. // public routines
  233. //
  234. DWORD
  235. GrowBlock(
  236. PCHAR * Block,
  237. DWORD UsedEntries,
  238. DWORD BlockSize,
  239. PDWORD FreeEntries
  240. );
  241. DWORD
  242. NetNameCheckNbtName(
  243. IN LPCWSTR NetName,
  244. IN DWORD NameHandleCount,
  245. IN HANDLE * NameHandleList,
  246. IN RESOURCE_HANDLE ResourceHandle
  247. );
  248. #ifdef __cplusplus
  249. extern "C" {
  250. #endif
  251. DWORD
  252. NetNameAddComputerObject(
  253. IN PCLUS_WORKER Worker,
  254. IN PNETNAME_RESOURCE Resource,
  255. OUT PWCHAR * MachinePwd
  256. );
  257. DWORD
  258. NetNameDeleteComputerObject(
  259. IN PNETNAME_RESOURCE Resource
  260. );
  261. HRESULT
  262. CheckComputerObjectAttributes(
  263. IN PNETNAME_RESOURCE Resource
  264. );
  265. DWORD
  266. IsComputerObjectInDS(
  267. IN LPWSTR NodeName,
  268. IN LPWSTR NewObjectName,
  269. OUT PBOOL ObjectExists
  270. );
  271. HRESULT
  272. GetComputerObjectGuid(
  273. IN PNETNAME_RESOURCE Resource
  274. );
  275. HRESULT
  276. RenameComputerObject(
  277. IN PNETNAME_RESOURCE Resource,
  278. IN LPWSTR NewName OPTIONAL
  279. );
  280. DWORD
  281. UpdateCompObjPassword(
  282. IN PNETNAME_RESOURCE Resource
  283. );
  284. #ifdef __cplusplus
  285. }
  286. #endif
  287. /* end netname.h */