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.

621 lines
14 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. dsgetdc.h
  5. Abstract:
  6. This file contains structures, function prototypes, and definitions
  7. for the DsGetDcName API.
  8. Environment:
  9. User Mode - Win32
  10. Notes:
  11. --*/
  12. #ifndef _DSGETDC_
  13. #define _DSGETDC_
  14. #if _MSC_VER > 1000
  15. #pragma once
  16. #endif
  17. #if !defined(_DSGETDCAPI_)
  18. #define DSGETDCAPI DECLSPEC_IMPORT
  19. #else
  20. #define DSGETDCAPI
  21. #endif
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. //
  26. // Structure definitions
  27. //
  28. //
  29. // Flags to passed to DsGetDcName
  30. //
  31. #define DS_FORCE_REDISCOVERY 0x00000001
  32. #define DS_DIRECTORY_SERVICE_REQUIRED 0x00000010
  33. #define DS_DIRECTORY_SERVICE_PREFERRED 0x00000020
  34. #define DS_GC_SERVER_REQUIRED 0x00000040
  35. #define DS_PDC_REQUIRED 0x00000080
  36. #define DS_BACKGROUND_ONLY 0x00000100
  37. #define DS_IP_REQUIRED 0x00000200
  38. #define DS_KDC_REQUIRED 0x00000400
  39. #define DS_TIMESERV_REQUIRED 0x00000800
  40. #define DS_WRITABLE_REQUIRED 0x00001000
  41. #define DS_GOOD_TIMESERV_PREFERRED 0x00002000
  42. #define DS_AVOID_SELF 0x00004000
  43. #define DS_ONLY_LDAP_NEEDED 0x00008000
  44. #define DS_IS_FLAT_NAME 0x00010000
  45. #define DS_IS_DNS_NAME 0x00020000
  46. #define DS_RETURN_DNS_NAME 0x40000000
  47. #define DS_RETURN_FLAT_NAME 0x80000000
  48. #define DSGETDC_VALID_FLAGS ( \
  49. DS_FORCE_REDISCOVERY | \
  50. DS_DIRECTORY_SERVICE_REQUIRED | \
  51. DS_DIRECTORY_SERVICE_PREFERRED | \
  52. DS_GC_SERVER_REQUIRED | \
  53. DS_PDC_REQUIRED | \
  54. DS_BACKGROUND_ONLY | \
  55. DS_IP_REQUIRED | \
  56. DS_KDC_REQUIRED | \
  57. DS_TIMESERV_REQUIRED | \
  58. DS_WRITABLE_REQUIRED | \
  59. DS_GOOD_TIMESERV_PREFERRED | \
  60. DS_AVOID_SELF | \
  61. DS_ONLY_LDAP_NEEDED | \
  62. DS_IS_FLAT_NAME | \
  63. DS_IS_DNS_NAME | \
  64. DS_RETURN_FLAT_NAME | \
  65. DS_RETURN_DNS_NAME )
  66. //
  67. // Structure returned from DsGetDcName
  68. //
  69. typedef struct _DOMAIN_CONTROLLER_INFOA {
  70. LPSTR DomainControllerName;
  71. LPSTR DomainControllerAddress;
  72. ULONG DomainControllerAddressType;
  73. GUID DomainGuid;
  74. LPSTR DomainName;
  75. LPSTR DnsForestName;
  76. ULONG Flags;
  77. LPSTR DcSiteName;
  78. LPSTR ClientSiteName;
  79. } DOMAIN_CONTROLLER_INFOA, *PDOMAIN_CONTROLLER_INFOA;
  80. typedef struct _DOMAIN_CONTROLLER_INFOW {
  81. #ifdef MIDL_PASS
  82. [string,unique] wchar_t *DomainControllerName;
  83. #else // MIDL_PASS
  84. LPWSTR DomainControllerName;
  85. #endif // MIDL_PASS
  86. #ifdef MIDL_PASS
  87. [string,unique] wchar_t *DomainControllerAddress;
  88. #else // MIDL_PASS
  89. LPWSTR DomainControllerAddress;
  90. #endif // MIDL_PASS
  91. ULONG DomainControllerAddressType;
  92. GUID DomainGuid;
  93. #ifdef MIDL_PASS
  94. [string,unique] wchar_t *DomainName;
  95. #else // MIDL_PASS
  96. LPWSTR DomainName;
  97. #endif // MIDL_PASS
  98. #ifdef MIDL_PASS
  99. [string,unique] wchar_t *DnsForestName;
  100. #else // MIDL_PASS
  101. LPWSTR DnsForestName;
  102. #endif // MIDL_PASS
  103. ULONG Flags;
  104. #ifdef MIDL_PASS
  105. [string,unique] wchar_t *DcSiteName;
  106. #else // MIDL_PASS
  107. LPWSTR DcSiteName;
  108. #endif // MIDL_PASS
  109. #ifdef MIDL_PASS
  110. [string,unique] wchar_t *ClientSiteName;
  111. #else // MIDL_PASS
  112. LPWSTR ClientSiteName;
  113. #endif // MIDL_PASS
  114. } DOMAIN_CONTROLLER_INFOW, *PDOMAIN_CONTROLLER_INFOW;
  115. #ifdef UNICODE
  116. #define DOMAIN_CONTROLLER_INFO DOMAIN_CONTROLLER_INFOW
  117. #define PDOMAIN_CONTROLLER_INFO PDOMAIN_CONTROLLER_INFOW
  118. #else
  119. #define DOMAIN_CONTROLLER_INFO DOMAIN_CONTROLLER_INFOA
  120. #define PDOMAIN_CONTROLLER_INFO PDOMAIN_CONTROLLER_INFOA
  121. #endif // !UNICODE
  122. //
  123. // Values for DomainControllerAddressType
  124. //
  125. #define DS_INET_ADDRESS 1
  126. #define DS_NETBIOS_ADDRESS 2
  127. //
  128. // Values for returned Flags
  129. //
  130. #define DS_PDC_FLAG 0x00000001 // DC is PDC of Domain
  131. #define DS_GC_FLAG 0x00000004 // DC is a GC of forest
  132. #define DS_LDAP_FLAG 0x00000008 // Server supports an LDAP server
  133. #define DS_DS_FLAG 0x00000010 // DC supports a DS and is a Domain Controller
  134. #define DS_KDC_FLAG 0x00000020 // DC is running KDC service
  135. #define DS_TIMESERV_FLAG 0x00000040 // DC is running time service
  136. #define DS_CLOSEST_FLAG 0x00000080 // DC is in closest site to client
  137. #define DS_WRITABLE_FLAG 0x00000100 // DC has a writable DS
  138. #define DS_GOOD_TIMESERV_FLAG 0x00000200 // DC is running time service (and has clock hardware)
  139. #define DS_NDNC_FLAG 0x00000400 // DomainName is non-domain NC serviced by the LDAP server
  140. #define DS_PING_FLAGS 0x0000FFFF // Flags returned on ping
  141. #define DS_DNS_CONTROLLER_FLAG 0x20000000 // DomainControllerName is a DNS name
  142. #define DS_DNS_DOMAIN_FLAG 0x40000000 // DomainName is a DNS name
  143. #define DS_DNS_FOREST_FLAG 0x80000000 // DnsForestName is a DNS name
  144. //
  145. // Function Prototypes
  146. //
  147. DSGETDCAPI
  148. DWORD
  149. WINAPI
  150. DsGetDcNameA(
  151. IN LPCSTR ComputerName OPTIONAL,
  152. IN LPCSTR DomainName OPTIONAL,
  153. IN GUID *DomainGuid OPTIONAL,
  154. IN LPCSTR SiteName OPTIONAL,
  155. IN ULONG Flags,
  156. OUT PDOMAIN_CONTROLLER_INFOA *DomainControllerInfo
  157. );
  158. DSGETDCAPI
  159. DWORD
  160. WINAPI
  161. DsGetDcNameW(
  162. IN LPCWSTR ComputerName OPTIONAL,
  163. IN LPCWSTR DomainName OPTIONAL,
  164. IN GUID *DomainGuid OPTIONAL,
  165. IN LPCWSTR SiteName OPTIONAL,
  166. IN ULONG Flags,
  167. OUT PDOMAIN_CONTROLLER_INFOW *DomainControllerInfo
  168. );
  169. #ifdef UNICODE
  170. #define DsGetDcName DsGetDcNameW
  171. #else
  172. #define DsGetDcName DsGetDcNameA
  173. #endif // !UNICODE
  174. DSGETDCAPI
  175. DWORD
  176. WINAPI
  177. DsGetSiteNameA(
  178. IN LPCSTR ComputerName OPTIONAL,
  179. OUT LPSTR *SiteName
  180. );
  181. DSGETDCAPI
  182. DWORD
  183. WINAPI
  184. DsGetSiteNameW(
  185. IN LPCWSTR ComputerName OPTIONAL,
  186. OUT LPWSTR *SiteName
  187. );
  188. #ifdef UNICODE
  189. #define DsGetSiteName DsGetSiteNameW
  190. #else
  191. #define DsGetSiteName DsGetSiteNameA
  192. #endif // !UNICODE
  193. DSGETDCAPI
  194. DWORD
  195. WINAPI
  196. DsValidateSubnetNameW(
  197. IN LPCWSTR SubnetName
  198. );
  199. DSGETDCAPI
  200. DWORD
  201. WINAPI
  202. DsValidateSubnetNameA(
  203. IN LPCSTR SubnetName
  204. );
  205. #ifdef UNICODE
  206. #define DsValidateSubnetName DsValidateSubnetNameW
  207. #else
  208. #define DsValidateSubnetName DsValidateSubnetNameA
  209. #endif // !UNICODE
  210. //
  211. // Only include if winsock2.h has been included
  212. //
  213. #ifdef _WINSOCK2API_
  214. DSGETDCAPI
  215. DWORD
  216. WINAPI
  217. DsAddressToSiteNamesW(
  218. IN LPCWSTR ComputerName OPTIONAL,
  219. IN DWORD EntryCount,
  220. IN PSOCKET_ADDRESS SocketAddresses,
  221. OUT LPWSTR **SiteNames
  222. );
  223. DSGETDCAPI
  224. DWORD
  225. WINAPI
  226. DsAddressToSiteNamesA(
  227. IN LPCSTR ComputerName OPTIONAL,
  228. IN DWORD EntryCount,
  229. IN PSOCKET_ADDRESS SocketAddresses,
  230. OUT LPSTR **SiteNames
  231. );
  232. #ifdef UNICODE
  233. #define DsAddressToSiteNames DsAddressToSiteNamesW
  234. #else
  235. #define DsAddressToSiteNames DsAddressToSiteNamesA
  236. #endif // !UNICODE
  237. DSGETDCAPI
  238. DWORD
  239. WINAPI
  240. DsAddressToSiteNamesExW(
  241. IN LPCWSTR ComputerName OPTIONAL,
  242. IN DWORD EntryCount,
  243. IN PSOCKET_ADDRESS SocketAddresses,
  244. OUT LPWSTR **SiteNames,
  245. OUT LPWSTR **SubnetNames
  246. );
  247. DSGETDCAPI
  248. DWORD
  249. WINAPI
  250. DsAddressToSiteNamesExA(
  251. IN LPCSTR ComputerName OPTIONAL,
  252. IN DWORD EntryCount,
  253. IN PSOCKET_ADDRESS SocketAddresses,
  254. OUT LPSTR **SiteNames,
  255. OUT LPSTR **SubnetNames
  256. );
  257. #ifdef UNICODE
  258. #define DsAddressToSiteNamesEx DsAddressToSiteNamesExW
  259. #else
  260. #define DsAddressToSiteNamesEx DsAddressToSiteNamesExA
  261. #endif // !UNICODE
  262. #endif // _WINSOCK2API_
  263. //
  264. // API to enumerate trusted domains
  265. //
  266. typedef struct _DS_DOMAIN_TRUSTSW {
  267. //
  268. // Name of the trusted domain.
  269. //
  270. #ifdef MIDL_PASS
  271. [string] wchar_t * NetbiosDomainName;
  272. [string] wchar_t * DnsDomainName;
  273. #else // MIDL_PASS
  274. LPWSTR NetbiosDomainName;
  275. LPWSTR DnsDomainName;
  276. #endif // MIDL_PASS
  277. //
  278. // Flags defining attributes of the trust.
  279. //
  280. ULONG Flags;
  281. #define DS_DOMAIN_IN_FOREST 0x0001 // Domain is a member of the forest
  282. #define DS_DOMAIN_DIRECT_OUTBOUND 0x0002 // Domain is directly trusted
  283. #define DS_DOMAIN_TREE_ROOT 0x0004 // Domain is root of a tree in the forest
  284. #define DS_DOMAIN_PRIMARY 0x0008 // Domain is the primary domain of queried server
  285. #define DS_DOMAIN_NATIVE_MODE 0x0010 // Primary domain is running in native mode
  286. #define DS_DOMAIN_DIRECT_INBOUND 0x0020 // Domain is directly trusting
  287. #define DS_DOMAIN_VALID_FLAGS ( \
  288. DS_DOMAIN_IN_FOREST | \
  289. DS_DOMAIN_DIRECT_OUTBOUND | \
  290. DS_DOMAIN_TREE_ROOT | \
  291. DS_DOMAIN_PRIMARY | \
  292. DS_DOMAIN_NATIVE_MODE | \
  293. DS_DOMAIN_DIRECT_INBOUND )
  294. //
  295. // Index to the domain that is the parent of this domain.
  296. // Only defined if NETLOGON_DOMAIN_IN_FOREST is set and
  297. // NETLOGON_DOMAIN_TREE_ROOT is not set.
  298. //
  299. ULONG ParentIndex;
  300. //
  301. // The trust type and attributes of this trust.
  302. //
  303. // If NETLOGON_DOMAIN_DIRECTLY_TRUSTED is not set,
  304. // these value are infered.
  305. //
  306. ULONG TrustType;
  307. ULONG TrustAttributes;
  308. //
  309. // The SID of the trusted domain.
  310. //
  311. // If NETLOGON_DOMAIN_DIRECTLY_TRUSTED is not set,
  312. // this value will be NULL.
  313. //
  314. #if defined(MIDL_PASS)
  315. PISID DomainSid;
  316. #else
  317. PSID DomainSid;
  318. #endif
  319. //
  320. // The GUID of the trusted domain.
  321. //
  322. GUID DomainGuid;
  323. } DS_DOMAIN_TRUSTSW, *PDS_DOMAIN_TRUSTSW;
  324. //
  325. // ANSI version of the above struct
  326. //
  327. typedef struct _DS_DOMAIN_TRUSTSA {
  328. LPSTR NetbiosDomainName;
  329. LPSTR DnsDomainName;
  330. ULONG Flags;
  331. ULONG ParentIndex;
  332. ULONG TrustType;
  333. ULONG TrustAttributes;
  334. PSID DomainSid;
  335. GUID DomainGuid;
  336. } DS_DOMAIN_TRUSTSA, *PDS_DOMAIN_TRUSTSA;
  337. #ifdef UNICODE
  338. #define DS_DOMAIN_TRUSTS DS_DOMAIN_TRUSTSW
  339. #define PDS_DOMAIN_TRUSTS PDS_DOMAIN_TRUSTSW
  340. #else
  341. #define DS_DOMAIN_TRUSTS DS_DOMAIN_TRUSTSA
  342. #define PDS_DOMAIN_TRUSTS PDS_DOMAIN_TRUSTSA
  343. #endif // !UNICODE
  344. DSGETDCAPI
  345. DWORD
  346. WINAPI
  347. DsEnumerateDomainTrustsW (
  348. IN LPWSTR ServerName OPTIONAL,
  349. IN ULONG Flags,
  350. OUT PDS_DOMAIN_TRUSTSW *Domains,
  351. OUT PULONG DomainCount
  352. );
  353. DSGETDCAPI
  354. DWORD
  355. WINAPI
  356. DsEnumerateDomainTrustsA (
  357. IN LPSTR ServerName OPTIONAL,
  358. IN ULONG Flags,
  359. OUT PDS_DOMAIN_TRUSTSA *Domains,
  360. OUT PULONG DomainCount
  361. );
  362. #ifdef UNICODE
  363. #define DsEnumerateDomainTrusts DsEnumerateDomainTrustsW
  364. #else
  365. #define DsEnumerateDomainTrusts DsEnumerateDomainTrustsA
  366. #endif // !UNICODE
  367. //
  368. // Only define this API if the caller has #included the pre-requisite ntlsa.h
  369. #ifdef _NTLSA_
  370. DSGETDCAPI
  371. DWORD
  372. WINAPI
  373. DsGetForestTrustInformationW (
  374. IN LPCWSTR ServerName OPTIONAL,
  375. IN LPCWSTR TrustedDomainName OPTIONAL,
  376. IN DWORD Flags,
  377. OUT PLSA_FOREST_TRUST_INFORMATION *ForestTrustInfo
  378. );
  379. #define DS_GFTI_UPDATE_TDO 0x1 // Update TDO with information returned
  380. #define DS_GFTI_VALID_FLAGS 0x1 // All valid flags to DsGetForestTrustInformation
  381. DSGETDCAPI
  382. DWORD
  383. WINAPI
  384. DsMergeForestTrustInformationW(
  385. IN LPCWSTR DomainName,
  386. IN PLSA_FOREST_TRUST_INFORMATION NewForestTrustInfo,
  387. IN PLSA_FOREST_TRUST_INFORMATION OldForestTrustInfo OPTIONAL,
  388. OUT PLSA_FOREST_TRUST_INFORMATION *MergedForestTrustInfo
  389. );
  390. #endif //_NTLSA_
  391. DSGETDCAPI
  392. DWORD
  393. WINAPI
  394. DsGetDcSiteCoverageW(
  395. IN LPCWSTR ServerName OPTIONAL,
  396. OUT PULONG EntryCount,
  397. OUT LPWSTR **SiteNames
  398. );
  399. DSGETDCAPI
  400. DWORD
  401. WINAPI
  402. DsGetDcSiteCoverageA(
  403. IN LPCSTR ServerName OPTIONAL,
  404. OUT PULONG EntryCount,
  405. OUT LPSTR **SiteNames
  406. );
  407. #ifdef UNICODE
  408. #define DsGetDcSiteCoverage DsGetDcSiteCoverageW
  409. #else
  410. #define DsGetDcSiteCoverage DsGetDcSiteCoverageA
  411. #endif // !UNICODE
  412. DSGETDCAPI
  413. DWORD
  414. WINAPI
  415. DsDeregisterDnsHostRecordsW (
  416. IN LPWSTR ServerName OPTIONAL,
  417. IN LPWSTR DnsDomainName OPTIONAL,
  418. IN GUID *DomainGuid OPTIONAL,
  419. IN GUID *DsaGuid OPTIONAL,
  420. IN LPWSTR DnsHostName
  421. );
  422. DSGETDCAPI
  423. DWORD
  424. WINAPI
  425. DsDeregisterDnsHostRecordsA (
  426. IN LPSTR ServerName OPTIONAL,
  427. IN LPSTR DnsDomainName OPTIONAL,
  428. IN GUID *DomainGuid OPTIONAL,
  429. IN GUID *DsaGuid OPTIONAL,
  430. IN LPSTR DnsHostName
  431. );
  432. #ifdef UNICODE
  433. #define DsDeregisterDnsHostRecords DsDeregisterDnsHostRecordsW
  434. #else
  435. #define DsDeregisterDnsHostRecords DsDeregisterDnsHostRecordsA
  436. #endif // !UNICODE
  437. #ifdef _WINSOCK2API_ // DsGetDcOpen/Next/Close depend on winsock2.h be included
  438. //
  439. // Option flags passed to DsGetDcOpen
  440. //
  441. #define DS_ONLY_DO_SITE_NAME 0x01 // Non-site specific names should be avoided.
  442. #define DS_NOTIFY_AFTER_SITE_RECORDS 0x02 // Return ERROR_FILEMARK_DETECTED after all
  443. // site specific records have been processed.
  444. #define DS_OPEN_VALID_OPTION_FLAGS ( DS_ONLY_DO_SITE_NAME | DS_NOTIFY_AFTER_SITE_RECORDS )
  445. //
  446. // Valid DcFlags for DsGetDcOpen
  447. //
  448. #define DS_OPEN_VALID_FLAGS ( \
  449. DS_FORCE_REDISCOVERY | \
  450. DS_ONLY_LDAP_NEEDED | \
  451. DS_KDC_REQUIRED | \
  452. DS_PDC_REQUIRED | \
  453. DS_GC_SERVER_REQUIRED | \
  454. DS_WRITABLE_REQUIRED )
  455. DSGETDCAPI
  456. DWORD
  457. WINAPI
  458. DsGetDcOpenW(
  459. IN LPCWSTR DnsName,
  460. IN ULONG OptionFlags,
  461. IN LPCWSTR SiteName OPTIONAL,
  462. IN GUID *DomainGuid OPTIONAL,
  463. IN LPCWSTR DnsForestName OPTIONAL,
  464. IN ULONG DcFlags,
  465. OUT PHANDLE RetGetDcContext
  466. );
  467. DSGETDCAPI
  468. DWORD
  469. WINAPI
  470. DsGetDcOpenA(
  471. IN LPCSTR DnsName,
  472. IN ULONG OptionFlags,
  473. IN LPCSTR SiteName OPTIONAL,
  474. IN GUID *DomainGuid OPTIONAL,
  475. IN LPCSTR DnsForestName OPTIONAL,
  476. IN ULONG DcFlags,
  477. OUT PHANDLE RetGetDcContext
  478. );
  479. #ifdef UNICODE
  480. #define DsGetDcOpen DsGetDcOpenW
  481. #else
  482. #define DsGetDcOpen DsGetDcOpenA
  483. #endif // !UNICODE
  484. DSGETDCAPI
  485. DWORD
  486. WINAPI
  487. DsGetDcNextW(
  488. IN HANDLE GetDcContextHandle,
  489. OUT PULONG SockAddressCount OPTIONAL,
  490. OUT LPSOCKET_ADDRESS *SockAddresses OPTIONAL,
  491. OUT LPWSTR *DnsHostName OPTIONAL
  492. );
  493. DSGETDCAPI
  494. DWORD
  495. WINAPI
  496. DsGetDcNextA(
  497. IN HANDLE GetDcContextHandle,
  498. OUT PULONG SockAddressCount OPTIONAL,
  499. OUT LPSOCKET_ADDRESS *SockAddresses OPTIONAL,
  500. OUT LPSTR *DnsHostName OPTIONAL
  501. );
  502. #ifdef UNICODE
  503. #define DsGetDcNext DsGetDcNextW
  504. #else
  505. #define DsGetDcNext DsGetDcNextA
  506. #endif // !UNICODE
  507. DSGETDCAPI
  508. VOID
  509. WINAPI
  510. DsGetDcCloseW(
  511. IN HANDLE GetDcContextHandle
  512. );
  513. #ifdef UNICODE
  514. #define DsGetDcClose DsGetDcCloseW
  515. #else
  516. #define DsGetDcClose DsGetDcCloseW // same for ANSI
  517. #endif // !UNICODE
  518. #endif // _WINSOCK2API_
  519. #ifdef __cplusplus
  520. }
  521. #endif
  522. #endif // _DSGETDC_