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.

411 lines
11 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. // entries at the Resource Key level (not under Parameters key)
  27. //
  28. #define PARAM_NAME__NAME CLUSREG_NAME_NET_NAME
  29. #define PARAM_NAME__FLAGS CLUSREG_NAME_FLAGS
  30. #define PARAM_NAME__CORECURRENTNAME L"CoreCurrentName"
  31. #define PARAM_NAME__RENAMEORIGINALNAME L"RenameOriginalName"
  32. #define PARAM_NAME__RENAMENEWNAME L"RenameNewName"
  33. //
  34. // Resource Property constants
  35. //
  36. #define PARAM_NAME__REMAP L"RemapPipeNames"
  37. #define PARAM_DEFAULT__REMAP FALSE
  38. #define PARAM_NAME__RESOURCE_DATA L"ResourceData"
  39. #define PARAM_NAME__STATUS_NETBIOS L"StatusNetBIOS"
  40. #define PARAM_NAME__STATUS_DNS L"StatusDNS"
  41. #define PARAM_NAME__STATUS_KERBEROS L"StatusKerberos"
  42. #define PARAM_NAME__REQUIRE_DNS L"RequireDNS"
  43. #define PARAM_DEFAULT__REQUIRE_DNS 0
  44. #define PARAM_NAME__REQUIRE_KERBEROS L"RequireKerberos"
  45. #define PARAM_DEFAULT__REQUIRE_KERBEROS 0
  46. #ifdef PASSWORD_ROTATION
  47. #define PARAM_NAME__NEXT_UPDATE L"NextUpdate"
  48. #define PARAM_NAME__UPDATE_INTERVAL L"UpdateInterval"
  49. #define PARAM_DEFAULT__UPDATE_INTERVAL ( 30 ) // 30 days
  50. #define PARAM_MINIMUM__UPDATE_INTERVAL ( 0 ) // no password update is done
  51. #define PARAM_MAXIMUM__UPDATE_INTERVAL ( 0xFFFFFFFF ) // many years...
  52. #endif // PASSWORD_ROTATION
  53. #define PARAM_NAME__CREATING_DC L"CreatingDC"
  54. //
  55. // netname worker thread check frequencies for when talking to the DNS server
  56. // goes as expected and when they don't. periods are in seconds. Short periods
  57. // are for testing.
  58. //
  59. //#define _SHORT_PERIODS
  60. #ifdef _SHORT_PERIODS
  61. #define NETNAME_WORKER_NORMAL_CHECK_PERIOD 60
  62. #define NETNAME_WORKER_PROBLEM_CHECK_PERIOD 60
  63. #define NETNAME_WORKER_PENDING_PERIOD 2
  64. #else
  65. #define NETNAME_WORKER_NORMAL_CHECK_PERIOD (60 * 60 * 24) // 24 hours
  66. #define NETNAME_WORKER_PROBLEM_CHECK_PERIOD (60 * 10) // 10 minutes
  67. #define NETNAME_WORKER_PENDING_PERIOD 60
  68. #endif
  69. //
  70. // this struct is used to hold the matched set of DNS A and PTR records with
  71. // which the network name's DNS name and reverse name are registered.
  72. // {Fwd,Rev}ZoneIsDynamic is used as a validity flag in the case where the
  73. // initial DnsUpdateTest call timed out and we later discover that this server
  74. // doesn't except updates. In that case, ZoneIsDynamic is set to FALSE and the
  75. // worker thread checks for these records are skipped.
  76. //
  77. // In hind sight, each record type should have had its own DNS_LIST entry
  78. // instead of putting both A and PTR together in one structure. This has led
  79. // to constructing an invalid list of PTR records in its
  80. // DNS_RRSET. Consequently, there is some ugly code in RegisterDnsRecords that
  81. // has to build a fake DNS_RRSET in order to get the PTR records registered.
  82. //
  83. typedef struct _DNS_LISTS {
  84. DNS_RRSET A_RRSet;
  85. DNS_STATUS LastARecQueryStatus;
  86. DNS_RRSET PTR_RRSet;
  87. DNS_STATUS LastPTRRecQueryStatus; // not used
  88. PIP4_ARRAY DnsServerList;
  89. LPWSTR ConnectoidName;
  90. //
  91. // TRUE if we couldn't contact the server during record build time. This
  92. // means that the worker thread will need to call DnsUpdateTest to
  93. // determine if the server is dynamic
  94. //
  95. BOOL UpdateTestTimeout;
  96. //
  97. // used to "invalidate" this entry if we discovered after online that the
  98. // server isn't dynamic
  99. //
  100. BOOL ForwardZoneIsDynamic;
  101. //
  102. // TRUE if we've already logged an error about this entry in the system
  103. // event log
  104. //
  105. BOOL AErrorLogged;
  106. //
  107. // PTR corresponding vars with same functionality as their A counterparts
  108. //
  109. BOOL ReverseZoneIsDynamic;
  110. BOOL PTRErrorLogged;
  111. } DNS_LISTS, *PDNS_LISTS;
  112. //
  113. // set this define to one to get addt'l debug spew to see the interaction with
  114. // the DNS server and determine if the RRSet structures are getting built
  115. // correctly.
  116. //
  117. #define DBG_DNSLIST 0
  118. //
  119. // this struct is used to hold the mapping between a cluster IP address and a
  120. // DNS domain name. The FQDN is built using these domain suffixes and the
  121. // cluster netname. The connectoid name is included so we can log over which
  122. // NIC we did the registration.
  123. //
  124. typedef struct _DOMAIN_ADDRESS_MAPPING {
  125. LPWSTR ConnectoidName;
  126. LPWSTR IpAddress;
  127. LPWSTR DomainName;
  128. PIP4_ARRAY DnsServerList;
  129. } DOMAIN_ADDRESS_MAPPING, *PDOMAIN_ADDRESS_MAPPING;
  130. //
  131. // backing structure for resource properties
  132. //
  133. typedef struct _NETNAME_PARAMS {
  134. //
  135. // the name that is currently online
  136. //
  137. LPWSTR NetworkName;
  138. //
  139. // true if RemapPipeNames set to one; used by SQL to remap virtual pipe
  140. // names to the node's name (?)
  141. //
  142. DWORD NetworkRemap;
  143. //
  144. // pointer to r/o encrypted computer object password
  145. //
  146. PBYTE ResourceData;
  147. //
  148. // R/W props: if set to TRUE, the respective section must succeed for the
  149. // resource to go online. RequireKerberos implies RequireDNS.
  150. //
  151. BOOL RequireDNS;
  152. BOOL RequireKerberos;
  153. //
  154. // read-only props that reflect final status codes for the corresponding
  155. // functionality
  156. //
  157. DWORD StatusNetBIOS;
  158. DWORD StatusDNS;
  159. DWORD StatusKerberos;
  160. #ifdef PASSWORD_ROTATION
  161. //
  162. // read-only timestamp of when to perform next password update
  163. //
  164. FILETIME NextUpdate;
  165. //
  166. // R/W pwd update interval in days
  167. //
  168. DWORD UpdateInterval;
  169. #endif // PASSWORD_ROTATION
  170. //
  171. // r/o prop that holds name of DC on which computer object was created
  172. //
  173. LPWSTR CreatingDC;
  174. } NETNAME_PARAMS, *PNETNAME_PARAMS;
  175. //
  176. // netname resource context block. One per instance of a netname resource.
  177. //
  178. typedef struct {
  179. LIST_ENTRY Next;
  180. LONG RefCount; // ref count on entire resource block
  181. CLUSTER_RESOURCE_STATE State;
  182. RESOURCE_HANDLE ResourceHandle; // handle for logging to cluster log
  183. DWORD dwFlags;
  184. HANDLE * NameHandleList; // array of netbios w/s handles
  185. DWORD NameHandleCount;
  186. CLUS_WORKER PendingThread;
  187. LPWSTR NodeName;
  188. LPWSTR NodeId;
  189. //
  190. // handles to our resource key, resource's parameters key as the resource
  191. // itself
  192. //
  193. HKEY ResKey;
  194. HKEY ParametersKey;
  195. HRESOURCE ClusterResourceHandle;
  196. //
  197. // used during online pending processing so we can keep increasing the
  198. // checkpoint value for each individual resource
  199. //
  200. ULONG StatusCheckpoint;
  201. //
  202. // count and pointer to the DNS publishing information; mutex is used to
  203. // sync access to DnsLists and NumberOfDnsLists
  204. //
  205. HANDLE DnsListMutex;
  206. DWORD NumberOfDnsLists;
  207. PDNS_LISTS DnsLists;
  208. //
  209. // holder of resource properties
  210. //
  211. NETNAME_PARAMS Params;
  212. //
  213. // used to handle case where the name property has changed while the
  214. // resource is online. If TRUE, then offline processing will take
  215. // appropriate steps to handle this condition.
  216. //
  217. BOOL NameChangedWhileOnline;
  218. //
  219. // number of bytes pointed to by Params.ResourceData
  220. //
  221. DWORD ResDataSize;
  222. //
  223. // objectGUID attribute of the computer object from DS. Using the GUID
  224. // frees us from having to track object moves in the DS.
  225. //
  226. LPWSTR ObjectGUID;
  227. //
  228. // DoKerberosCheck is TRUE if Add/UpdateComputerObject was
  229. // successful. This is used by the worker thread to determine if it should
  230. // check on the computer object. The status returned by that check is
  231. // stored in KerberosStatus. VSToken is a primary token representing the
  232. // virtual computer object. It is dup'ed when another resource requests a
  233. // token representing the account.
  234. //
  235. // For upgrades to Windows Server 2003, we have to force RequireKerberos on if the
  236. // netname has a dependent MSMQ resource. The CheckForKerberosUpgrade flag
  237. // is used during online to flag the existing resources to make that check.
  238. //
  239. BOOL DoKerberosCheck;
  240. DWORD KerberosStatus;
  241. HANDLE VSToken;
  242. BOOL CheckForKerberosUpgrade;
  243. } NETNAME_RESOURCE, *PNETNAME_RESOURCE;
  244. //
  245. // public routines
  246. //
  247. DWORD
  248. GrowBlock(
  249. PCHAR * Block,
  250. DWORD UsedEntries,
  251. DWORD BlockSize,
  252. PDWORD FreeEntries
  253. );
  254. DWORD
  255. NetNameCheckNbtName(
  256. IN LPCWSTR NetName,
  257. IN DWORD NameHandleCount,
  258. IN HANDLE * NameHandleList,
  259. IN RESOURCE_HANDLE ResourceHandle
  260. );
  261. #ifdef __cplusplus
  262. extern "C" {
  263. #endif
  264. DWORD
  265. AddComputerObject(
  266. IN PCLUS_WORKER Worker,
  267. IN PNETNAME_RESOURCE Resource,
  268. OUT PWCHAR * MachinePwd
  269. );
  270. DWORD
  271. UpdateComputerObject(
  272. IN PCLUS_WORKER Worker,
  273. IN PNETNAME_RESOURCE Resource,
  274. OUT PWCHAR * MachinePwd
  275. );
  276. DWORD
  277. DisableComputerObject(
  278. IN PNETNAME_RESOURCE Resource
  279. );
  280. HRESULT
  281. CheckComputerObjectAttributes(
  282. IN PNETNAME_RESOURCE Resource,
  283. IN LPWSTR DCName OPTIONAL
  284. );
  285. HRESULT
  286. IsComputerObjectInDS(
  287. IN RESOURCE_HANDLE ResourceHandle,
  288. IN LPWSTR NodeName,
  289. IN LPWSTR NewObjectName,
  290. IN LPWSTR DCName OPTIONAL,
  291. OUT PBOOL ObjectExists,
  292. OUT LPWSTR * DistinguishedName, OPTIONAL
  293. OUT LPWSTR * HostingDCName OPTIONAL
  294. );
  295. HRESULT
  296. GetComputerObjectGuid(
  297. IN PNETNAME_RESOURCE Resource,
  298. IN LPWSTR Name OPTIONAL
  299. );
  300. HRESULT
  301. RenameComputerObject(
  302. IN PNETNAME_RESOURCE Resource,
  303. IN LPWSTR CurrentName,
  304. IN LPWSTR NewName
  305. );
  306. #ifdef PASSWORD_ROTATION
  307. DWORD
  308. UpdateCompObjPassword(
  309. IN PNETNAME_RESOURCE Resource
  310. );
  311. #endif // PASSWORD_ROTATION
  312. VOID
  313. RemoveNNCryptoCheckpoint(
  314. PNETNAME_RESOURCE Resource
  315. );
  316. BOOL
  317. DoesMsmqNeedComputerObject(
  318. VOID
  319. );
  320. DWORD
  321. UpgradeMSMQDependentNetnameToKerberos(
  322. PNETNAME_RESOURCE Resource
  323. );
  324. DWORD
  325. DuplicateVSToken(
  326. PNETNAME_RESOURCE Resource,
  327. PCLUS_NETNAME_VS_TOKEN_INFO TokenInfo,
  328. PHANDLE DuplicatedToken
  329. );
  330. #ifdef __cplusplus
  331. }
  332. #endif
  333. /* end netname.h */