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.

1369 lines
38 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. nlcommon.h
  5. Abstract:
  6. Definitions shared by logonsrv\common, logonsrv\client and logonsrv\server.
  7. Author:
  8. Cliff Van Dyke (cliffv) 20-Jun-1996
  9. Environment:
  10. User mode only.
  11. Contains NT-specific code.
  12. Requires ANSI C extensions: slash-slash comments, long external names.
  13. Revision History:
  14. --*/
  15. #include <winldap.h> // ldap_...
  16. //
  17. // netpdc.c will #include this file with NLCOMMON_ALLOCATE defined.
  18. // That will cause each of these variables to be allocated.
  19. //
  20. #undef EXTERN
  21. #ifdef NLCOMMON_ALLOCATE
  22. #define EXTERN
  23. #else
  24. #define EXTERN extern
  25. #endif
  26. //
  27. // Common registry paths to Netlogon owned sections
  28. //
  29. #define NL_PARAM_KEY "SYSTEM\\CurrentControlSet\\Services\\Netlogon\\Parameters"
  30. #define NL_GPPARAM_KEY "Software\\Policies\\Microsoft\\Netlogon\\Parameters"
  31. #define NL_GP_KEY "Software\\Policies\\Microsoft\\Netlogon"
  32. //
  33. // Internal flags to NetpDcGetName
  34. //
  35. #define DS_IS_PRIMARY_DOMAIN 0x001 // Domain specified is the domain this machine is a member of.
  36. #define DS_NAME_FORMAT_AMBIGUOUS 0x002 // Can't tell if domain name is Netbios or DNS
  37. #define DS_SITENAME_DEFAULTED 0x004 // Site name was not explicitly specified by caller
  38. #define DS_DONT_CACHE_FAILURE 0x008 // Don't cache failures of this call
  39. #define DS_CLOSE_DC_NOT_NEEDED 0x010 // Set if no extra effort to find a close DC is needed
  40. #define DS_REQUIRE_ROOT_DOMAIN 0x020 // The found DC must be in the root domain
  41. #define DS_PRIMARY_NAME_IS_WORKGROUP 0x040 // Primary domain name specified is a workgroup name
  42. #define DS_DOING_DC_DISCOVERY 0x080 // We are performing DC discovery, not just host pings
  43. #define DS_PING_DNS_HOST 0x100 // Only ping one DC whose DNS name is specified
  44. #define DS_PING_NETBIOS_HOST 0x200 // Only ping one DC whose Netbios name is specified
  45. #define DS_PING_USING_LDAP 0x400 // Ping the DC using the ldap mechanism
  46. #define DS_PING_USING_MAILSLOT 0x800 // Ping the DC using the mailslot mechanism
  47. #define DS_IS_TRUSTED_DOMAIN 0x1000 // Domain specified is trusted by this domain.
  48. #define DS_CALLER_PASSED_NULL_DOMAIN 0x2000 // The caller of DsGetDcName passed NULL domain name.
  49. //
  50. // Constants describing a DNS name.
  51. //
  52. #define NL_MAX_DNS_LENGTH 255 // Max. # of bytes in a DNS name
  53. #define NL_MAX_DNS_LABEL_LENGTH 63 // Max. # of bytes in a DNS label
  54. #define NL_DNS_COMPRESS_BYTE_MASK 0xc0
  55. #define NL_DNS_COMPRESS_WORD_MASK ((WORD)(0xc000))
  56. //
  57. // Length of an IP address text string
  58. //
  59. #define NL_IP_ADDRESS_LENGTH 15
  60. //
  61. // Length of a socket address text string
  62. // ?? increase for IPV6
  63. //
  64. #define NL_SOCK_ADDRESS_LENGTH (NL_IP_ADDRESS_LENGTH + 4)
  65. //
  66. // Names of LDAP atributes used for netlogon PING
  67. //
  68. #define NETLOGON_LDAP_ATTRIBUTE "Netlogon" // Attribute to query
  69. #define NL_FILTER_DNS_DOMAIN_NAME "DnsDomain"
  70. #define NL_FILTER_HOST_NAME "Host"
  71. #define NL_FILTER_USER_NAME "User"
  72. #define NL_FILTER_ALLOWABLE_ACCOUNT_CONTROL "AAC"
  73. #define NL_FILTER_NT_VERSION "NtVer"
  74. #define NL_FILTER_DOMAIN_SID "DomainSid"
  75. #define NL_FILTER_DOMAIN_GUID "DomainGuid"
  76. //
  77. // Constants defining time to wait between datagram sends.
  78. // (We always look for responses while we wait.)
  79. //
  80. // Minimum time to wait after ANY send (e.g., two mailslot to two IP addresses)
  81. #define NL_DC_MIN_PING_TIMEOUT 100 // 1/10 second
  82. // Median time to wait after ANY send (e.g., two mailslot to two IP addresses)
  83. #define NL_DC_MED_PING_TIMEOUT 200 // 2/10 second
  84. // Maximum time to wait after ANY send (e.g., two mailslot to two IP addresses)
  85. #define NL_DC_MAX_PING_TIMEOUT 400 // 4/10 second
  86. // Default maximum time to delay
  87. #define NL_DC_MAX_TIMEOUT 15000 // 15 seconds
  88. // Minumum amount of time to delay for any iteration
  89. // Don't make this smaller than DEFAULT_MAILSLOTDUPLICATETIMEOUT. Otherwise,
  90. // the DC will think the packets are duplicates of the previous iteration.
  91. #define NL_DC_MIN_ITERATION_TIMEOUT 2000 // 2 seconds
  92. // Number of repetitions of the datagram sends.
  93. #define MAX_DC_RETRIES 2
  94. //
  95. // Carry a single status code around with a less cryptic name
  96. //
  97. #define ERROR_DNS_NOT_CONFIGURED DNS_ERROR_NO_TCPIP
  98. #define ERROR_DNS_NOT_AVAILABLE DNS_ERROR_RCODE_SERVER_FAILURE
  99. #define ERROR_DYNAMIC_DNS_NOT_SUPPORTED DNS_ERROR_RCODE_NOT_IMPLEMENTED
  100. //
  101. // Components comprising the registered DNS names.
  102. //
  103. #define NL_DNS_LDAP_SRV "_ldap."
  104. #define NL_DNS_KDC_SRV "_kerberos."
  105. #define NL_DNS_KPWD_SRV "_kpasswd."
  106. #define NL_DNS_GC_SRV "_gc."
  107. #define NL_DNS_TCP "_tcp."
  108. #define NL_DNS_UDP "_udp."
  109. #define NL_DNS_AT_SITE "._sites."
  110. #define NL_DNS_MSDCS "_msdcs."
  111. #define NL_DNS_PDC "pdc." NL_DNS_MSDCS
  112. #define NL_DNS_DC "dc." NL_DNS_MSDCS
  113. #define NL_DNS_GC "gc." NL_DNS_MSDCS
  114. #define NL_DNS_DC_BY_GUID ".domains." NL_DNS_MSDCS
  115. #define NL_DNS_DC_IP_ADDRESS ""
  116. #define NL_DNS_DSA_IP_ADDRESS "." NL_DNS_MSDCS
  117. #define NL_DNS_GC_IP_ADDRESS NL_DNS_GC
  118. #ifndef NLCOMMON_ALLOCATE
  119. //
  120. // Different types of DCs that can be queried for.
  121. //
  122. // There is a separate cache entry for each type of DC that can be found. That
  123. // ensures that a more specific cached DC isn't used when a less specific cached
  124. // DC is being requested. For instance, if a caller has asked for and cached the
  125. // PDC of the domain, it would be inappropriate to use that cache entry when
  126. // the next caller asks for a generic DC. However, if a caller has asked for
  127. // and cached a generic DC in the domain and that DC just happens to be the PDC,
  128. // then it would be fine to return that cache entry to a subsequent caller that
  129. // needs the PDC.
  130. //
  131. // The type below defines which types of DCs are more "specific". Latter entries
  132. // are more specific.
  133. //
  134. typedef enum _NL_DC_QUERY_TYPE {
  135. NlDcQueryLdap,
  136. NlDcQueryGenericDc,
  137. NlDcQueryKdc,
  138. NlDcQueryGenericGc,
  139. NlDcQueryGc,
  140. NlDcQueryPdc,
  141. NlDcQueryTypeCount // Number of entries in this enum.
  142. #define NlDcQueryInvalid NlDcQueryTypeCount
  143. } NL_DC_QUERY_TYPE, *PNL_DC_QUERY_TYPE;
  144. //
  145. // The types of names registered in DNS.
  146. //
  147. typedef enum _NL_DNS_NAME_TYPE {
  148. //
  149. // Some of the entries below are obsolete. They are placeholders
  150. // for what used to be entries without underscores in their names.
  151. // These obsolete entries were used before NT 5 Beta 3.
  152. //
  153. NlDnsObsolete1,
  154. NlDnsObsolete2,
  155. NlDnsObsolete3,
  156. NlDnsObsolete4,
  157. NlDnsObsolete5,
  158. NlDnsObsolete6,
  159. NlDnsObsolete7,
  160. NlDnsLdapIpAddress, // <DnsDomainName>
  161. NlDnsObsolete8,
  162. NlDnsObsolete9,
  163. NlDnsObsolete10,
  164. NlDnsObsolete11,
  165. NlDnsObsolete12,
  166. NlDnsObsolete13,
  167. NlDnsObsolete14,
  168. NlDnsObsolete15,
  169. NlDnsObsolete16,
  170. NlDnsObsolete17,
  171. NlDnsObsolete18,
  172. NlDnsObsolete19,
  173. NlDnsObsolete20,
  174. // The below two entries represent LDAP servers that might not be DCs
  175. NlDnsLdap, // _ldap._tcp.<DnsDomainName>
  176. NlDnsLdapAtSite, // _ldap._tcp.<SiteName>._sites.<DnsDomainName>
  177. NlDnsPdc, // _ldap._tcp.pdc._msdcs.<DnsDomainName>
  178. // The below two entries represent GCs that are also DCs
  179. NlDnsGc, // _ldap._tcp.gc._msdcs.<DnsForestName>
  180. NlDnsGcAtSite, // _ldap._tcp.<SiteName>._sites.gc._msdcs.<DnsForestName>
  181. NlDnsDcByGuid, // _ldap._tcp.<DomainGuid>.domains._msdcs.<DnsForestName>
  182. // The one entry below might not be DCs
  183. NlDnsGcIpAddress, // _gc._msdcs.<DnsForestName>
  184. NlDnsDsaCname, // <DsaGuid>._msdcs.<DnsForestName>
  185. // The below two entries represent KDCs that are also DCs
  186. NlDnsKdc, // _kerberos._tcp.dc._msdcs.<DnsDomainName>
  187. NlDnsKdcAtSite, // _kerberos._tcp.dc._msdcs.<SiteName>._sites.<DnsDomainName>
  188. // The below two entries represent DCs
  189. NlDnsDc, // _ldap._tcp.dc._msdcs.<DnsDomainName>
  190. NlDnsDcAtSite, // _ldap._tcp.<SiteName>._sites.dc._msdcs.<DnsDomainName>
  191. // The below two entries represent KDCs that might not be DCs
  192. NlDnsRfc1510Kdc, // _kerberos._tcp.<DnsDomainName>
  193. NlDnsRfc1510KdcAtSite,// _kerberos._tcp.<SiteName>._sites.<DnsDomainName>
  194. // The below two entries represent GCs that might not be DCs
  195. NlDnsGenericGc, // _gc._tcp.<DnsForestName>
  196. NlDnsGenericGcAtSite, // _gc._tcp.<SiteName>._sites.<DnsForestName>
  197. // The below three entries are for RFC compliance only.
  198. NlDnsRfc1510UdpKdc, // _kerberos._udp.<DnsDomainName>
  199. NlDnsRfc1510Kpwd, // _kpasswd._tcp.<DnsDomainName>
  200. NlDnsRfc1510UdpKpwd, // _kpasswd._udp.<DnsDomainName>
  201. // This should always be the last entry. It represents an invalid entry.
  202. NlDnsInvalid
  203. #define NL_DNS_NAME_TYPE_COUNT NlDnsInvalid
  204. } NL_DNS_NAME_TYPE, *PNL_DNS_NAME_TYPE;
  205. //
  206. // Table of everything you wanted to know about a particular DNS Name type
  207. //
  208. typedef struct _NL_DNS_NAME_TYPE_DESC {
  209. // String describing the name
  210. WCHAR *Name;
  211. // DcQueryType for this nametype
  212. // NlDcQueryInvalid means the name is obsolete and should never be registered.
  213. NL_DC_QUERY_TYPE DcQueryType;
  214. // DnsNameType of the site specific name to lookup
  215. NL_DNS_NAME_TYPE SiteSpecificDnsNameType;
  216. // DnsNameType to lookup if this one fails
  217. NL_DNS_NAME_TYPE NextDnsNameType;
  218. // DsGetDcName Flags which controls if this name is to be registered
  219. // If 0, this name is obsolete and should never be registered
  220. ULONG DsGetDcFlags;
  221. // RR Type in DNS
  222. USHORT RrType;
  223. // Misc booleans
  224. BOOLEAN IsSiteSpecific;
  225. BOOLEAN IsForestRelative;
  226. BOOLEAN IsTcp; // FALSE if a UDP record
  227. } NL_DNS_NAME_TYPE_DESC, *PNL_DNS_NAME_TYPE_DESC;
  228. #endif // NLCOMMON_ALLOCATE
  229. //
  230. // The descriptive name of each entry must have a prefix "NlDns" since
  231. // this convention is used for DnsAvoidRegisterRecords names in registry.
  232. //
  233. EXTERN NL_DNS_NAME_TYPE_DESC NlDcDnsNameTypeDesc[]
  234. #ifdef NLCOMMON_ALLOCATE
  235. = {
  236. //Name DcQueryType SiteSpecificDnsName NextDnsNameType DsGetDcFlag RrType Site IsForest
  237. //
  238. { L"Obsolete 1", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  239. { L"Obsolete 2", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  240. { L"Obsolete 3", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  241. { L"Obsolete 4", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  242. { L"Obsolete 5", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  243. { L"Obsolete 6", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  244. { L"Obsolete 7", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  245. { L"NlDnsLdapIpAddress", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, DS_DS_FLAG|DS_NDNC_FLAG, DNS_TYPE_A, FALSE, FALSE, TRUE, },
  246. { L"Obsolete 8", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  247. { L"Obsolete 9", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  248. { L"Obsolete 10", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  249. { L"Obsolete 11", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  250. { L"Obsolete 12", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  251. { L"Obsolete 13", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  252. { L"Obsolete 14", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  253. { L"Obsolete 15", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  254. { L"Obsolete 16", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  255. { L"Obsolete 17", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  256. { L"Obsolete 18", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  257. { L"Obsolete 19", NlDcQueryGenericGc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  258. { L"Obsolete 20", NlDcQueryGenericGc, NlDnsInvalid, NlDnsInvalid, 0, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  259. { L"NlDnsLdap", NlDcQueryLdap, NlDnsLdapAtSite, NlDnsInvalid, DS_DS_FLAG|DS_NDNC_FLAG, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  260. { L"NlDnsLdapAtSite", NlDcQueryLdap, NlDnsLdapAtSite, NlDnsLdap, DS_DS_FLAG|DS_NDNC_FLAG, DNS_TYPE_SRV, TRUE, FALSE, TRUE, },
  261. { L"NlDnsPdc", NlDcQueryPdc, NlDnsInvalid, NlDnsInvalid, DS_PDC_FLAG, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  262. { L"NlDnsGc", NlDcQueryGc, NlDnsGcAtSite, NlDnsInvalid, DS_GC_FLAG, DNS_TYPE_SRV, FALSE, TRUE, TRUE, },
  263. { L"NlDnsGcAtSite", NlDcQueryGc, NlDnsGcAtSite, NlDnsGc, DS_GC_FLAG, DNS_TYPE_SRV, TRUE, TRUE, TRUE, },
  264. { L"NlDnsDcByGuid", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, DS_DS_FLAG, DNS_TYPE_SRV, FALSE, TRUE, TRUE, },
  265. { L"NlDnsGcIpAddress", NlDcQueryGc, NlDnsInvalid, NlDnsInvalid, DS_GC_FLAG, DNS_TYPE_A, FALSE, TRUE, TRUE, },
  266. { L"NlDnsDsaCname", NlDcQueryGenericDc, NlDnsInvalid, NlDnsInvalid, DS_DS_FLAG, DNS_TYPE_CNAME,FALSE, TRUE, TRUE, },
  267. { L"NlDnsKdc", NlDcQueryKdc, NlDnsKdcAtSite, NlDnsInvalid, DS_KDC_FLAG, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  268. { L"NlDnsKdcAtSite", NlDcQueryKdc, NlDnsKdcAtSite, NlDnsKdc, DS_KDC_FLAG, DNS_TYPE_SRV, TRUE, FALSE, TRUE, },
  269. { L"NlDnsDc", NlDcQueryGenericDc, NlDnsDcAtSite, NlDnsDcByGuid, DS_DS_FLAG, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  270. { L"NlDnsDcAtSite", NlDcQueryGenericDc, NlDnsDcAtSite, NlDnsDc, DS_DS_FLAG, DNS_TYPE_SRV, TRUE, FALSE, TRUE, },
  271. { L"NlDnsRfc1510Kdc", NlDcQueryKdc, NlDnsInvalid, NlDnsInvalid, DS_KDC_FLAG, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  272. { L"NlDnsRfc1510KdcAtSite",NlDcQueryKdc, NlDnsInvalid, NlDnsInvalid, DS_KDC_FLAG, DNS_TYPE_SRV, TRUE, FALSE, TRUE, },
  273. { L"NlDnsGenericGc", NlDcQueryGenericGc, NlDnsGenericGcAtSite, NlDnsInvalid, DS_GC_FLAG, DNS_TYPE_SRV, FALSE, TRUE, TRUE, },
  274. { L"NlDnsGenericGcAtSite", NlDcQueryGenericGc, NlDnsGenericGcAtSite, NlDnsGenericGc, DS_GC_FLAG, DNS_TYPE_SRV, TRUE, TRUE, TRUE, },
  275. { L"NlDnsRfc1510UdpKdc", NlDcQueryKdc, NlDnsInvalid, NlDnsInvalid, DS_KDC_FLAG, DNS_TYPE_SRV, FALSE, FALSE, FALSE, },
  276. { L"NlDnsRfc1510Kpwd", NlDcQueryKdc, NlDnsInvalid, NlDnsInvalid, DS_KDC_FLAG, DNS_TYPE_SRV, FALSE, FALSE, TRUE, },
  277. { L"NlDnsRfc1510UdpKpwd", NlDcQueryKdc, NlDnsInvalid, NlDnsInvalid, DS_KDC_FLAG, DNS_TYPE_SRV, FALSE, FALSE, FALSE, },
  278. }
  279. #endif //NLCOMMON_ALLOCATE
  280. ;
  281. //
  282. // The lenth of the "NlDns" prefix
  283. //
  284. #define NL_DNS_NAME_PREFIX_LENGTH 5
  285. //
  286. // Macros to categorize the above types.
  287. //
  288. // Names which correspond to an A record in DNS
  289. #define NlDnsARecord( _NameType ) \
  290. (NlDcDnsNameTypeDesc[_NameType].RrType == DNS_TYPE_A)
  291. // Names which correspond to a SRV record in DNS
  292. #define NlDnsSrvRecord( _NameType ) \
  293. (NlDcDnsNameTypeDesc[_NameType].RrType == DNS_TYPE_SRV)
  294. // Names which correspond to a CNAME record in DNS
  295. #define NlDnsCnameRecord( _NameType ) \
  296. (NlDcDnsNameTypeDesc[_NameType].RrType == DNS_TYPE_CNAME)
  297. // Names which correspond to a GC
  298. #define NlDnsGcName( _NameType ) \
  299. (NlDcDnsNameTypeDesc[_NameType].DsGetDcFlags == DS_GC_FLAG)
  300. // Names which have the DC GUID in them
  301. #define NlDnsDcGuid( _NameType ) \
  302. ((_NameType) == NlDnsDcByGuid )
  303. // Names which correspond to a KDC
  304. #define NlDnsKdcRecord( _NameType ) \
  305. ((NlDcDnsNameTypeDesc[_NameType].DsGetDcFlags == DS_KDC_FLAG) && !NlDnsKpwdRecord( _NameType ) )
  306. // Names which correspond to a KPASSWD server
  307. #define NlDnsKpwdRecord( _NameType ) \
  308. ((_NameType) == NlDnsRfc1510Kpwd || (_NameType) == NlDnsRfc1510UdpKpwd )
  309. // Names which do not correspond to NDNC
  310. #define NlDnsNonNdncName( _NameType ) \
  311. ( (NlDcDnsNameTypeDesc[_NameType].DsGetDcFlags & DS_NDNC_FLAG) == 0 )
  312. // Name which correspond to a PDC record
  313. #define NlDnsPdcName( _NameType ) \
  314. (NlDcDnsNameTypeDesc[_NameType].DsGetDcFlags == DS_PDC_FLAG)
  315. //
  316. // Status codes that can be returned from the API.
  317. //
  318. #define NlDcUseGenericStatus( _NetStatus ) \
  319. ( (_NetStatus) != ERROR_NOT_ENOUGH_MEMORY && \
  320. (_NetStatus) != ERROR_ACCESS_DENIED && \
  321. (_NetStatus) != ERROR_NETWORK_UNREACHABLE && \
  322. (_NetStatus) != NERR_NetNotStarted && \
  323. (_NetStatus) != NERR_WkstaNotStarted && \
  324. (_NetStatus) != NERR_ServerNotStarted && \
  325. (_NetStatus) != NERR_BrowserNotStarted && \
  326. (_NetStatus) != NERR_ServiceNotInstalled && \
  327. (_NetStatus) != NERR_BadTransactConfig )
  328. //
  329. // All of these statuses simply mean there is no such record in DNS
  330. // DNS_ERROR_RCODE_NAME_ERROR: no RR's by this name
  331. // DNS_INFO_NO_RECORDS: RR's by this name but not of the requested type
  332. // DNS_ERROR_RCODE_REFUSED: Policy prevents access to this DNS server
  333. // (Some DNS servers return this if SRV records aren't supported.)
  334. // DNS_ERROR_RCODE_NOT_IMPLEMENTED: 3rd party server that does not
  335. // support SRV records
  336. // DNS_ERROR_RCODE_FORMAT_ERROR: 3rd party DNS server that is unable
  337. // to interpret format
  338. //
  339. #define NlDcNoDnsRecord( _NetStatus ) \
  340. ( (_NetStatus) == DNS_ERROR_RCODE_NAME_ERROR || \
  341. (_NetStatus) == DNS_INFO_NO_RECORDS || \
  342. (_NetStatus) == DNS_ERROR_RCODE_REFUSED || \
  343. (_NetStatus) == DNS_ERROR_RCODE_NOT_IMPLEMENTED || \
  344. (_NetStatus) == DNS_ERROR_RCODE_FORMAT_ERROR )
  345. //
  346. // Address of a potential DC to ping.
  347. //
  348. #ifndef NLCOMMON_ALLOCATE
  349. typedef struct _NL_DC_ADDRESS {
  350. //
  351. // Link to next entry
  352. //
  353. LIST_ENTRY Next;
  354. //
  355. // The name of the server
  356. //
  357. LPWSTR DnsHostName;
  358. //
  359. // Address to ping.
  360. //
  361. SOCKET_ADDRESS SockAddress;
  362. SOCKADDR_IN SockAddrIn;
  363. CHAR SockAddrString[NL_SOCK_ADDRESS_LENGTH+1];
  364. //
  365. // Handle for doing LDAP calls on.
  366. //
  367. PLDAP LdapHandle;
  368. //
  369. // Time in milliseconds to wait for a ping response
  370. //
  371. ULONG AddressPingWait;
  372. //
  373. // Flags describing the properties of the address
  374. //
  375. ULONG AddressFlags;
  376. #define NL_DC_ADDRESS_NEVER_TRY_AGAIN 0x01 // Must not reuse this address
  377. #define NL_DC_ADDRESS_SITE_SPECIFIC 0x02 // Address was retrieved in site specific DNS lookup
  378. } NL_DC_ADDRESS, *PNL_DC_ADDRESS;
  379. //
  380. // Structure describing a cached response to a DC query.
  381. //
  382. typedef struct _NL_DC_CACHE_ENTRY {
  383. //
  384. // Number of references to this entry.
  385. //
  386. ULONG ReferenceCount;
  387. //
  388. // Time when this entry was created.
  389. //
  390. ULONG CreationTime;
  391. #define NL_DC_CACHE_ENTRY_TIMEOUT (15*60000) // 15 minutes
  392. #define NL_DC_CLOSE_SITE_TIMEOUT (15*60000) // 15 minutes
  393. //
  394. // "Quality" of this entry.
  395. //
  396. // Used to differentiate between two cache entries. The higher "quality"
  397. // entry is preserved. Each of the following attributes is worth some
  398. // quality points:
  399. // DC is a KDC
  400. // DC is a timeserv
  401. // DC is running the DS
  402. // discovery if via IP
  403. // DC is "closest"
  404. //
  405. ULONG DcQuality;
  406. //
  407. // Opcode of the response message that found this DC
  408. //
  409. // This will be one of
  410. // LOGON_PRIMARY_RESPONSE, LOGON_SAM_LOGON_RESPONSE, LOGON_SAM_USER_UNKNOWN
  411. // LOGON_SAM_PAUSE_RESPONSE
  412. //
  413. ULONG Opcode;
  414. //
  415. // Domain GUID of the domain.
  416. //
  417. GUID DomainGuid;
  418. //
  419. // Netbios name of the domain.
  420. //
  421. LPWSTR UnicodeNetbiosDomainName;
  422. //
  423. // DNS name of the domain.
  424. //
  425. LPWSTR UnicodeDnsDomainName;
  426. //
  427. // User Name queried with this discovery.
  428. //
  429. LPWSTR UnicodeUserName;
  430. //
  431. // Netbios name of the discovered DC.
  432. //
  433. LPWSTR UnicodeNetbiosDcName;
  434. //
  435. // Dns name of the discovered DC.
  436. //
  437. LPWSTR UnicodeDnsHostName;
  438. //
  439. // SocketAddress Address of the discovered DC.
  440. //
  441. SOCKET_ADDRESS SockAddr;
  442. SOCKADDR_IN SockAddrIn;
  443. //
  444. // Tree name the domain is in.
  445. //
  446. LPWSTR UnicodeDnsForestName;
  447. //
  448. // Site the discovered DC is in.
  449. //
  450. LPWSTR UnicodeDcSiteName;
  451. //
  452. // Site the client is in.
  453. LPWSTR UnicodeClientSiteName;
  454. //
  455. // Flags returned in ping message.
  456. //
  457. ULONG ReturnFlags;
  458. //
  459. // Internal flags describing the cache entry
  460. //
  461. ULONG CacheEntryFlags;
  462. #define NL_DC_CACHE_MAILSLOT 0x01 // The response was received on a mailslot
  463. #define NL_DC_CACHE_LDAP 0x02 // The response was received on a ldap port
  464. #define NL_DC_CACHE_LOCAL 0x04 // The response is local
  465. #define NL_DC_CACHE_NONCLOSE_EXPIRE 0x08 // The cache entry should expire since the DC isn't close
  466. #define NL_DC_CACHE_ENTRY_INSERTED 0x10 // The cache entry has already been inserted
  467. //
  468. // VersionFlags returned in the ping message
  469. //
  470. ULONG VersionFlags;
  471. } NL_DC_CACHE_ENTRY, *PNL_DC_CACHE_ENTRY;
  472. //
  473. // For each type of DC, the following information is cached:
  474. // Information about the DC that fits the type.
  475. // Time stamp used for negative caching (work in progress).
  476. //
  477. typedef struct _NL_EACH_DC {
  478. PNL_DC_CACHE_ENTRY NlDcCacheEntry;
  479. //
  480. // Only implement the negative cache in netlogon.dll since only it
  481. // has the ability to flush the negative cache when transports are added.
  482. //
  483. #ifdef _NETLOGON_SERVER
  484. //
  485. // Time (in ticks) when a DsGetDcName last failed.
  486. //
  487. DWORD NegativeCacheTime;
  488. //
  489. // Time (in seconds) after NegativeCacheTime when DS_BACKGROUND_ONLY callers
  490. // should be allowed to touch the wire again.
  491. //
  492. DWORD ExpBackoffPeriod;
  493. //
  494. // TRUE if the negative cache is permanent.
  495. // That is, DsGetDcName detected enough conditions to believe that subsequent
  496. // DsGetDcNames will never succeed.
  497. //
  498. BOOLEAN PermanentNegativeCache;
  499. //
  500. // Time when a first of a series of failed DsGetDcName attempts
  501. // was made.
  502. //
  503. LARGE_INTEGER BackgroundRetryInitTime;
  504. #endif // _NETLOGON_SERVER
  505. } NL_EACH_DC, *PNL_EACH_DC;
  506. //
  507. // Structure describing a domain being queried.
  508. //
  509. typedef struct _NL_DC_DOMAIN_ENTRY {
  510. //
  511. // Link for NlDcDomainList
  512. //
  513. LIST_ENTRY Next;
  514. //
  515. // Number of references to this entry.
  516. //
  517. ULONG ReferenceCount;
  518. //
  519. // Domain GUID of the domain.
  520. //
  521. GUID DomainGuid;
  522. //
  523. // Netbios name of the domain.
  524. //
  525. WCHAR UnicodeNetbiosDomainName[DNLEN+1];
  526. //
  527. // DNS name of the domain.
  528. //
  529. LPWSTR UnicodeDnsDomainName;
  530. //
  531. // Data indicating if the domain is an NT 4.0 (pre-DS) domain.
  532. //
  533. DWORD InNt4DomainTime;
  534. BOOLEAN InNt4Domain;
  535. BOOLEAN DeletedEntry;
  536. #define NL_NT4_AVOIDANCE_TIME (60 * 1000) // One minute
  537. #define NL_NT4_ONE_TRY_TIME (500) // Half second max
  538. //
  539. // There is one entry for each type of DC that can be discovered.
  540. //
  541. NL_EACH_DC Dc[NlDcQueryTypeCount];
  542. } NL_DC_DOMAIN_ENTRY, *PNL_DC_DOMAIN_ENTRY;
  543. //
  544. // Context describing progress made toward DC discovery.
  545. //
  546. typedef struct _NL_GETDC_CONTEXT {
  547. //
  548. // Type of name being queried.
  549. // Response is checked to ensure response is appropriate for this name type.
  550. //
  551. NL_DC_QUERY_TYPE DcQueryType;
  552. //
  553. // This is the original NlDnsNameType that corresponds to DcQueryType.
  554. // This isn't the type the correspons to the currnet name being looked up in DNS.
  555. NL_DNS_NAME_TYPE QueriedNlDnsNameType;
  556. //
  557. // Flags identifying the original query.
  558. //
  559. ULONG QueriedFlags;
  560. //
  561. // Internal flags identifying the original query.
  562. //
  563. ULONG QueriedInternalFlags;
  564. //
  565. // Acount being queried.
  566. // If specified, the response must include this specified account name.
  567. //
  568. LPCWSTR QueriedAccountName;
  569. //
  570. // Allowable account control bits for QueriedAccountName
  571. //
  572. ULONG QueriedAllowableAccountControlBits;
  573. //
  574. // SiteName being queried
  575. //
  576. LPCWSTR QueriedSiteName;
  577. //
  578. // Netbios domain name of the domain being queried.
  579. // Response is checked to ensure it is from this domain.
  580. //
  581. LPCWSTR QueriedNetbiosDomainName;
  582. //
  583. // DNS domain name of the domain being queried.
  584. // Response is checked to ensure it is from this domain.
  585. //
  586. LPCWSTR QueriedDnsDomainName;
  587. //
  588. // DNS tree name of the tree the queried domain is in.
  589. //
  590. LPCWSTR QueriedDnsForestName;
  591. //
  592. // Netbios or DNS Domain name to display. Guaranteed to be non-null.
  593. //
  594. LPCWSTR QueriedDisplayDomainName;
  595. //
  596. // Netbios computer name of this computer
  597. //
  598. LPCWSTR OurNetbiosComputerName;
  599. //
  600. // The name of the DC to query
  601. //
  602. LPCWSTR QueriedDcName;
  603. //
  604. // Domain guid of the domain being queried.
  605. // If specified, the response must contain this Domain GUID or no Domain GUID at all.
  606. //
  607. GUID *QueriedDomainGuid;
  608. //
  609. // Domain entry for the domain being queried.
  610. //
  611. PNL_DC_DOMAIN_ENTRY NlDcDomainEntry;
  612. //
  613. // Context to pass to NlBrowserSendDatagram.
  614. //
  615. PVOID SendDatagramContext;
  616. //
  617. // Ping message to send to a DC.
  618. //
  619. PVOID PingMessage;
  620. ULONG PingMessageSize;
  621. //
  622. // Ping message to send to a DC.
  623. // Some DC types require different message types to be sent to the DCs.
  624. // In that case, the primary message type is in PingMessage and the secondary message
  625. // type is in AlternatePingMessage
  626. //
  627. PVOID AlternatePingMessage;
  628. ULONG AlternatePingMessageSize;
  629. //
  630. // Filter sent to DC.
  631. //
  632. LPSTR LdapFilter;
  633. //
  634. // List of IP Addresses LDAP ping has been sent to
  635. //
  636. LIST_ENTRY DcAddressList;
  637. //
  638. // Count of DCs pinged whose addresses are on the above list
  639. //
  640. ULONG DcsPinged;
  641. //
  642. // Count of addresses of DCs that should be tried again.
  643. //
  644. ULONG DcAddressCount;
  645. //
  646. // Handle to a mailslot to read the ping response on.
  647. //
  648. HANDLE ResponseMailslotHandle;
  649. //
  650. // Number of retransmissions of ping message
  651. //
  652. ULONG TryCount;
  653. //
  654. // Time in milliseconds since reboot of the start of the operation.
  655. //
  656. DWORD StartTime;
  657. //
  658. // First response from a non-DS DC when a DS DC is preferred.
  659. // Or first response from a non-"good" time server whan a good timeserv is preferred.
  660. // This entry will be used only if no DS DC is available.
  661. //
  662. PNL_DC_CACHE_ENTRY ImperfectCacheEntry;
  663. BOOLEAN ImperfectUsedNetbios;
  664. //
  665. // Flags
  666. //
  667. BOOLEAN NonDsResponse; // Response from Non-DS DC returned
  668. BOOLEAN DsResponse; // Response from DS DC returned
  669. BOOLEAN AvoidNegativeCache; // At least one response returned
  670. BOOLEAN NoSuchUserResponse; // At lease one "no such user" response
  671. BOOLEAN DoingExplicitSite; // TRUE if the caller explicitly gave us a site name
  672. //
  673. // Set if we found some reason to not make the negative cache entry permanent.
  674. //
  675. BOOLEAN AvoidPermanentNegativeCache;
  676. //
  677. // Set if we got a response atleast one DNS server.
  678. //
  679. BOOLEAN ResponseFromDnsServer;
  680. //
  681. // Flags indicating the type of Context initialization required
  682. //
  683. #define NL_GETDC_CONTEXT_INITIALIZE_FLAGS 0x01
  684. #define NL_GETDC_CONTEXT_INITIALIZE_PING 0x02
  685. //
  686. // Indicate if OurNetbiosComputerName was allocated by NetpDcInitializeContext.
  687. // If so, it needs to be freed by NetpDcDeleteContext.
  688. //
  689. BOOLEAN FreeOurNetbiosComputerName;
  690. //
  691. // Flags describing various discovery states
  692. //
  693. ULONG ContextFlags;
  694. #define NL_GETDC_SITE_SPECIFIC_DNS_AVAIL 0x01 // Site specific DNS records were availble
  695. //
  696. // Buffer to read responses into.
  697. // (This buffer could be allocated on the stack ofNetpDcGetPingResponse()
  698. // except the buffer is large and we want to avoid stack overflows.)
  699. // (DWORD align it.)
  700. // DWORD ResponseBuffer[MAX_RANDOM_MAILSLOT_RESPONSE/sizeof(DWORD)];
  701. DWORD *ResponseBuffer;
  702. ULONG ResponseBufferSize;
  703. } NL_GETDC_CONTEXT, *PNL_GETDC_CONTEXT;
  704. #endif // NLCOMMON_ALLOCATE
  705. //
  706. // Macro for comparing GUIDs
  707. //
  708. #ifndef IsEqualGUID
  709. #define InlineIsEqualGUID(rguid1, rguid2) \
  710. (((PLONG) rguid1)[0] == ((PLONG) rguid2)[0] && \
  711. ((PLONG) rguid1)[1] == ((PLONG) rguid2)[1] && \
  712. ((PLONG) rguid1)[2] == ((PLONG) rguid2)[2] && \
  713. ((PLONG) rguid1)[3] == ((PLONG) rguid2)[3])
  714. #define IsEqualGUID(rguid1, rguid2) InlineIsEqualGUID(rguid1, rguid2)
  715. #endif
  716. ////////////////////////////////////////////////////////////////////////
  717. //
  718. // NlNameCompare
  719. //
  720. // I_NetNameCompare but always takes UNICODE strings
  721. //
  722. ////////////////////////////////////////////////////////////////////////
  723. #ifdef WIN32_CHICAGO
  724. #define NlNameCompare( _name1, _name2, _nametype ) \
  725. NlpChcg_wcsicmp( (_name1), (_name2) )
  726. #else // WIN32_CHICAGO
  727. #define NlNameCompare( _name1, _name2, _nametype ) \
  728. I_NetNameCompare(NULL, (_name1), (_name2), (_nametype), 0 )
  729. #endif // WIN32_CHICAGO
  730. //
  731. // Procedure forwards from netpdc.c
  732. //
  733. #if NETLOGONDBG
  734. LPSTR
  735. NlMailslotOpcode(
  736. IN WORD Opcode
  737. );
  738. LPSTR
  739. NlDgrNameType(
  740. IN DGRECEIVER_NAME_TYPE NameType
  741. );
  742. #endif // NETLOGONDBG
  743. VOID
  744. NetpIpAddressToStr(
  745. ULONG IpAddress,
  746. CHAR IpAddressString[NL_IP_ADDRESS_LENGTH+1]
  747. );
  748. VOID
  749. NetpIpAddressToWStr(
  750. ULONG IpAddress,
  751. WCHAR IpAddressString[NL_IP_ADDRESS_LENGTH+1]
  752. );
  753. NET_API_STATUS
  754. NetpSockAddrToWStr(
  755. PSOCKADDR SockAddr,
  756. ULONG SockAddrSize,
  757. WCHAR SockAddrString[NL_SOCK_ADDRESS_LENGTH+1]
  758. );
  759. LPWSTR
  760. NetpAllocWStrFromUtf8Str(
  761. IN LPSTR Utf8String
  762. );
  763. LPWSTR
  764. NetpAllocWStrFromUtf8StrEx(
  765. IN LPSTR Utf8String,
  766. IN ULONG Length
  767. );
  768. NET_API_STATUS
  769. NetpAllocWStrFromUtf8StrAsRequired(
  770. IN LPSTR Utf8String,
  771. IN ULONG Utf8StringLength,
  772. IN ULONG UnicodeStringBufferSize,
  773. OUT LPWSTR UnicodeStringBuffer OPTIONAL,
  774. OUT LPWSTR *AllocatedUnicodeString OPTIONAL
  775. );
  776. LPSTR
  777. NetpAllocUtf8StrFromWStr(
  778. IN LPCWSTR UnicodeString
  779. );
  780. LPSTR
  781. NetpAllocUtf8StrFromUnicodeString(
  782. IN PUNICODE_STRING UnicodeString
  783. );
  784. ULONG
  785. NetpDcElapsedTime(
  786. IN ULONG StartTime
  787. );
  788. BOOL
  789. NetpLogonGetCutf8String(
  790. IN PVOID Message,
  791. IN DWORD MessageSize,
  792. IN OUT PCHAR *Where,
  793. OUT LPSTR *Data
  794. );
  795. NET_API_STATUS
  796. NlpUnicodeToCutf8(
  797. IN LPBYTE MessageBuffer,
  798. IN LPCWSTR OrigUnicodeString,
  799. IN BOOLEAN IgnoreDot,
  800. IN OUT LPBYTE *Utf8String,
  801. IN OUT PULONG Utf8StringSize,
  802. IN OUT PULONG CompressCount,
  803. IN OUT LPWORD CompressOffset,
  804. IN OUT CHAR **CompressUtf8String
  805. );
  806. NET_API_STATUS
  807. NlpUtf8ToCutf8(
  808. IN LPBYTE MessageBuffer,
  809. IN LPCSTR OrigUtf8String,
  810. IN BOOLEAN IgnoreDots,
  811. IN OUT LPBYTE *Utf8String,
  812. IN OUT PULONG Utf8StringSize,
  813. IN OUT PULONG CompressCount,
  814. IN OUT LPWORD CompressOffset,
  815. IN OUT CHAR **CompressUtf8String
  816. );
  817. BOOL
  818. NetpDcValidDnsDomain(
  819. IN LPCWSTR DnsDomainName
  820. );
  821. BOOL
  822. NlEqualDnsName(
  823. IN LPCWSTR Name1,
  824. IN LPCWSTR Name2
  825. );
  826. BOOL
  827. NlEqualDnsNameU(
  828. IN PUNICODE_STRING Name1,
  829. IN PUNICODE_STRING Name2
  830. );
  831. BOOL
  832. NlEqualDnsNameUtf8(
  833. IN LPCSTR Name1,
  834. IN LPCSTR Name2
  835. );
  836. NET_API_STATUS
  837. NetpDcBuildDnsName(
  838. IN NL_DNS_NAME_TYPE NlDnsNameType,
  839. IN GUID *DomainGuid OPTIONAL,
  840. IN LPCWSTR SiteName OPTIONAL,
  841. IN LPCSTR DnsDomainName,
  842. OUT char DnsName[NL_MAX_DNS_LENGTH+1]
  843. );
  844. NET_API_STATUS
  845. NetpDcParsePingResponse(
  846. IN LPCWSTR DisplayDomainName,
  847. IN PVOID Message,
  848. IN ULONG MessageSize,
  849. OUT PNL_DC_CACHE_ENTRY *NlDcCacheEntry
  850. );
  851. DWORD
  852. NetpDcInitializeContext(
  853. IN PVOID SendDatagramContext OPTIONAL,
  854. IN LPCWSTR ComputerName OPTIONAL,
  855. IN LPCWSTR AccountName OPTIONAL,
  856. IN ULONG AllowableAccountControlBits,
  857. IN LPCWSTR NetbiosDomainName OPTIONAL,
  858. IN LPCWSTR DnsDomainName OPTIONAL,
  859. IN LPCWSTR DnsForestName OPTIONAL,
  860. IN PSID RequestedDomainSid OPTIONAL,
  861. IN GUID *DomainGuid OPTIONAL,
  862. IN LPCWSTR SiteName OPTIONAL,
  863. IN LPCWSTR DcNameToPing OPTIONAL,
  864. IN PSOCKET_ADDRESS DcSockAddressList OPTIONAL,
  865. IN ULONG DcSocketAddressCount,
  866. IN ULONG Flags,
  867. IN ULONG InternalFlags,
  868. IN ULONG InitializationType,
  869. OUT PNL_GETDC_CONTEXT Context
  870. );
  871. VOID
  872. NetpDcUninitializeContext(
  873. IN OUT PNL_GETDC_CONTEXT Context
  874. );
  875. NET_API_STATUS
  876. NetpDcPingIp(
  877. IN PNL_GETDC_CONTEXT Context,
  878. OUT PULONG DcPingCount
  879. );
  880. NET_API_STATUS
  881. NetpDcGetPingResponse(
  882. IN PNL_GETDC_CONTEXT Context,
  883. IN ULONG Timeout,
  884. OUT PNL_DC_CACHE_ENTRY *NlDcCacheEntry,
  885. OUT PBOOL UsedNetbios
  886. );
  887. VOID
  888. NetpDcDerefCacheEntry(
  889. IN PNL_DC_CACHE_ENTRY NlDcCacheEntry
  890. );
  891. DWORD
  892. NetpDcGetName(
  893. IN PVOID SendDatagramContext OPTIONAL,
  894. IN LPCWSTR ComputerName OPTIONAL,
  895. IN LPCWSTR AccountName OPTIONAL,
  896. IN ULONG AllowableAccountControlBits,
  897. IN LPCWSTR NetbiosDomainName OPTIONAL,
  898. IN LPCWSTR DnsDomainName OPTIONAL,
  899. IN LPCWSTR DnsForestName OPTIONAL,
  900. IN PSID RequestedDomainSid OPTIONAL,
  901. IN GUID *DomainGuid OPTIONAL,
  902. IN LPCWSTR SiteName OPTIONAL,
  903. IN ULONG Flags,
  904. IN ULONG InternalFlags,
  905. IN DWORD Timeout,
  906. IN DWORD RetryCount,
  907. OUT PDOMAIN_CONTROLLER_INFOW *DomainControllerInfo OPTIONAL,
  908. OUT PNL_DC_CACHE_ENTRY *DomainControllerCacheEntry OPTIONAL
  909. );
  910. DWORD
  911. DsIGetDcName(
  912. IN LPCWSTR ComputerName OPTIONAL,
  913. IN LPCWSTR AccountName OPTIONAL,
  914. IN ULONG AllowableAccountControlBits,
  915. IN LPCWSTR DomainName OPTIONAL,
  916. IN LPCWSTR DnsForestName OPTIONAL,
  917. IN GUID *DomainGuid OPTIONAL,
  918. IN LPCWSTR SiteName OPTIONAL,
  919. IN ULONG Flags,
  920. IN ULONG InternalFlags,
  921. IN PVOID SendDatagramContext OPTIONAL,
  922. IN DWORD Timeout,
  923. IN LPWSTR NetbiosPrimaryDomainName OPTIONAL,
  924. IN LPWSTR DnsPrimaryDomainName OPTIONAL,
  925. IN GUID *PrimaryDomainGuid OPTIONAL,
  926. IN LPWSTR DnsTrustedDomainName OPTIONAL,
  927. IN LPWSTR NetbiosTrustedDomainName OPTIONAL,
  928. OUT PDOMAIN_CONTROLLER_INFOW *DomainControllerInfo
  929. );
  930. NET_API_STATUS
  931. NlParseSubnetString(
  932. IN LPCWSTR SubnetName,
  933. OUT PULONG SubnetAddress,
  934. OUT PULONG SubnetMask,
  935. OUT LPBYTE SubnetBitCount
  936. );
  937. VOID
  938. NetpDcFlushNegativeCache(
  939. VOID
  940. );
  941. NET_API_STATUS
  942. NetpDcInitializeCache(
  943. VOID
  944. );
  945. VOID
  946. NetpDcUninitializeCache(
  947. VOID
  948. );
  949. VOID
  950. NetpDcInsertCacheEntry(
  951. IN PNL_GETDC_CONTEXT Context,
  952. IN PNL_DC_CACHE_ENTRY NlDcCacheEntry
  953. );
  954. NET_API_STATUS
  955. NetpDcGetDcOpen(
  956. IN LPCSTR DnsName,
  957. IN ULONG OptionFlags,
  958. IN LPCWSTR SiteName OPTIONAL,
  959. IN GUID *DomainGuid OPTIONAL,
  960. IN LPCSTR DnsForestName OPTIONAL,
  961. IN ULONG Flags,
  962. OUT PHANDLE RetGetDcContext
  963. );
  964. NET_API_STATUS
  965. NetpDcGetDcNext(
  966. IN HANDLE GetDcContextHandle,
  967. OUT PULONG SockAddressCount OPTIONAL,
  968. OUT LPSOCKET_ADDRESS *SockAddresses OPTIONAL,
  969. OUT LPSTR *DnsHostName OPTIONAL
  970. );
  971. VOID
  972. NetpDcGetDcClose(
  973. IN HANDLE GetDcContextHandle
  974. );
  975. VOID
  976. NetpDcFreeAddressList(
  977. IN PNL_GETDC_CONTEXT Context
  978. );
  979. NET_API_STATUS
  980. NetpDcProcessAddressList(
  981. IN PNL_GETDC_CONTEXT Context,
  982. IN LPWSTR DnsHostName OPTIONAL,
  983. IN PSOCKET_ADDRESS SockAddressList,
  984. IN ULONG SockAddressCount,
  985. IN BOOLEAN SiteSpecificAddress,
  986. OUT PNL_DC_ADDRESS *FirstAddressInserted OPTIONAL
  987. );
  988. //
  989. // Procedure forwards from nlcommon.c
  990. //
  991. NTSTATUS
  992. NlAllocateForestTrustListEntry (
  993. IN PBUFFER_DESCRIPTOR BufferDescriptor,
  994. IN PUNICODE_STRING InNetbiosDomainName OPTIONAL,
  995. IN PUNICODE_STRING InDnsDomainName OPTIONAL,
  996. IN ULONG Flags,
  997. IN ULONG ParentIndex,
  998. IN ULONG TrustType,
  999. IN ULONG TrustAttributes,
  1000. IN PSID DomainSid OPTIONAL,
  1001. IN GUID *DomainGuid,
  1002. OUT PULONG RetSize,
  1003. OUT PDS_DOMAIN_TRUSTSW *RetTrustedDomain
  1004. );
  1005. NTSTATUS
  1006. NlGetNt4TrustedDomainList (
  1007. IN LPWSTR UncDcName,
  1008. IN PUNICODE_STRING InNetbiosDomainName OPTIONAL,
  1009. IN PUNICODE_STRING InDnsDomainName OPTIONAL,
  1010. IN PSID DomainSid OPTIONAL,
  1011. IN GUID *DomainGuid OPTIONAL,
  1012. OUT PDS_DOMAIN_TRUSTSW *ForestTrustList,
  1013. OUT PULONG ForestTrustListSize,
  1014. OUT PULONG ForestTrustListCount
  1015. );
  1016. NET_API_STATUS
  1017. NlPingDcNameWithContext (
  1018. IN PNL_GETDC_CONTEXT Context,
  1019. IN ULONG NumberOfPings,
  1020. IN BOOLEAN WaitForResponse,
  1021. IN ULONG Timeout,
  1022. OUT PBOOL UsedNetbios OPTIONAL,
  1023. OUT PNL_DC_CACHE_ENTRY *NlDcCacheEntry OPTIONAL
  1024. );
  1025. //
  1026. // Procedures defined differently in logonsrv\client and logonsrv\server
  1027. //
  1028. NTSTATUS
  1029. NlBrowserSendDatagram(
  1030. IN PVOID ContextDomainInfo,
  1031. IN ULONG IpAddress,
  1032. IN LPWSTR UnicodeDestinationName,
  1033. IN DGRECEIVER_NAME_TYPE NameType,
  1034. IN LPWSTR TransportName,
  1035. IN LPSTR OemMailslotName,
  1036. IN PVOID Buffer,
  1037. IN ULONG BufferSize,
  1038. IN OUT PBOOL FlushNameOnOneIpTransport OPTIONAL
  1039. );
  1040. VOID
  1041. NlSetDynamicSiteName(
  1042. IN LPWSTR SiteName
  1043. );
  1044. #define ALL_IP_TRANSPORTS 0xFFFFFFFF
  1045. NET_API_STATUS
  1046. NlGetLocalPingResponse(
  1047. IN LPCWSTR TransportName,
  1048. IN BOOL LdapPing,
  1049. IN LPCWSTR NetbiosDomainName OPTIONAL,
  1050. IN LPCSTR DnsDomainName OPTIONAL,
  1051. IN GUID *DomainGuid OPTIONAL,
  1052. IN PSID DomainSid OPTIONAL,
  1053. IN BOOL PdcOnly,
  1054. IN LPCWSTR UnicodeComputerName,
  1055. IN LPCWSTR UnicodeUserName OPTIONAL,
  1056. IN ULONG AllowableAccountControlBits,
  1057. IN ULONG NtVersion,
  1058. IN ULONG NtVersionFlags,
  1059. IN PSOCKADDR ClientSockAddr OPTIONAL,
  1060. OUT PVOID *Message,
  1061. OUT PULONG MessageSize
  1062. );
  1063. BOOLEAN
  1064. NlReadDwordHklmRegValue(
  1065. IN LPCSTR SubKey,
  1066. IN LPCSTR ValueName,
  1067. OUT PDWORD ValueRead
  1068. );
  1069. BOOLEAN
  1070. NlReadDwordNetlogonRegValue(
  1071. IN LPCSTR ValueName,
  1072. OUT PDWORD Value
  1073. );
  1074. BOOLEAN
  1075. NlDoingSetup(
  1076. VOID
  1077. );
  1078. #undef EXTERN