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.

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