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.

623 lines
15 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
  369. // ntlsa.h or ntsecapi.h
  370. //
  371. #if defined(_NTLSA_) || defined(_NTSECAPI_)
  372. DSGETDCAPI
  373. DWORD
  374. WINAPI
  375. DsGetForestTrustInformationW (
  376. IN LPCWSTR ServerName OPTIONAL,
  377. IN LPCWSTR TrustedDomainName OPTIONAL,
  378. IN DWORD Flags,
  379. OUT PLSA_FOREST_TRUST_INFORMATION *ForestTrustInfo
  380. );
  381. #define DS_GFTI_UPDATE_TDO 0x1 // Update TDO with information returned
  382. #define DS_GFTI_VALID_FLAGS 0x1 // All valid flags to DsGetForestTrustInformation
  383. DSGETDCAPI
  384. DWORD
  385. WINAPI
  386. DsMergeForestTrustInformationW(
  387. IN LPCWSTR DomainName,
  388. IN PLSA_FOREST_TRUST_INFORMATION NewForestTrustInfo,
  389. IN PLSA_FOREST_TRUST_INFORMATION OldForestTrustInfo OPTIONAL,
  390. OUT PLSA_FOREST_TRUST_INFORMATION *MergedForestTrustInfo
  391. );
  392. #endif // _NTLSA_ || _NTSECAPI_
  393. DSGETDCAPI
  394. DWORD
  395. WINAPI
  396. DsGetDcSiteCoverageW(
  397. IN LPCWSTR ServerName OPTIONAL,
  398. OUT PULONG EntryCount,
  399. OUT LPWSTR **SiteNames
  400. );
  401. DSGETDCAPI
  402. DWORD
  403. WINAPI
  404. DsGetDcSiteCoverageA(
  405. IN LPCSTR ServerName OPTIONAL,
  406. OUT PULONG EntryCount,
  407. OUT LPSTR **SiteNames
  408. );
  409. #ifdef UNICODE
  410. #define DsGetDcSiteCoverage DsGetDcSiteCoverageW
  411. #else
  412. #define DsGetDcSiteCoverage DsGetDcSiteCoverageA
  413. #endif // !UNICODE
  414. DSGETDCAPI
  415. DWORD
  416. WINAPI
  417. DsDeregisterDnsHostRecordsW (
  418. IN LPWSTR ServerName OPTIONAL,
  419. IN LPWSTR DnsDomainName OPTIONAL,
  420. IN GUID *DomainGuid OPTIONAL,
  421. IN GUID *DsaGuid OPTIONAL,
  422. IN LPWSTR DnsHostName
  423. );
  424. DSGETDCAPI
  425. DWORD
  426. WINAPI
  427. DsDeregisterDnsHostRecordsA (
  428. IN LPSTR ServerName OPTIONAL,
  429. IN LPSTR DnsDomainName OPTIONAL,
  430. IN GUID *DomainGuid OPTIONAL,
  431. IN GUID *DsaGuid OPTIONAL,
  432. IN LPSTR DnsHostName
  433. );
  434. #ifdef UNICODE
  435. #define DsDeregisterDnsHostRecords DsDeregisterDnsHostRecordsW
  436. #else
  437. #define DsDeregisterDnsHostRecords DsDeregisterDnsHostRecordsA
  438. #endif // !UNICODE
  439. #ifdef _WINSOCK2API_ // DsGetDcOpen/Next/Close depend on winsock2.h be included
  440. //
  441. // Option flags passed to DsGetDcOpen
  442. //
  443. #define DS_ONLY_DO_SITE_NAME 0x01 // Non-site specific names should be avoided.
  444. #define DS_NOTIFY_AFTER_SITE_RECORDS 0x02 // Return ERROR_FILEMARK_DETECTED after all
  445. // site specific records have been processed.
  446. #define DS_OPEN_VALID_OPTION_FLAGS ( DS_ONLY_DO_SITE_NAME | DS_NOTIFY_AFTER_SITE_RECORDS )
  447. //
  448. // Valid DcFlags for DsGetDcOpen
  449. //
  450. #define DS_OPEN_VALID_FLAGS ( \
  451. DS_FORCE_REDISCOVERY | \
  452. DS_ONLY_LDAP_NEEDED | \
  453. DS_KDC_REQUIRED | \
  454. DS_PDC_REQUIRED | \
  455. DS_GC_SERVER_REQUIRED | \
  456. DS_WRITABLE_REQUIRED )
  457. DSGETDCAPI
  458. DWORD
  459. WINAPI
  460. DsGetDcOpenW(
  461. IN LPCWSTR DnsName,
  462. IN ULONG OptionFlags,
  463. IN LPCWSTR SiteName OPTIONAL,
  464. IN GUID *DomainGuid OPTIONAL,
  465. IN LPCWSTR DnsForestName OPTIONAL,
  466. IN ULONG DcFlags,
  467. OUT PHANDLE RetGetDcContext
  468. );
  469. DSGETDCAPI
  470. DWORD
  471. WINAPI
  472. DsGetDcOpenA(
  473. IN LPCSTR DnsName,
  474. IN ULONG OptionFlags,
  475. IN LPCSTR SiteName OPTIONAL,
  476. IN GUID *DomainGuid OPTIONAL,
  477. IN LPCSTR DnsForestName OPTIONAL,
  478. IN ULONG DcFlags,
  479. OUT PHANDLE RetGetDcContext
  480. );
  481. #ifdef UNICODE
  482. #define DsGetDcOpen DsGetDcOpenW
  483. #else
  484. #define DsGetDcOpen DsGetDcOpenA
  485. #endif // !UNICODE
  486. DSGETDCAPI
  487. DWORD
  488. WINAPI
  489. DsGetDcNextW(
  490. IN HANDLE GetDcContextHandle,
  491. OUT PULONG SockAddressCount OPTIONAL,
  492. OUT LPSOCKET_ADDRESS *SockAddresses OPTIONAL,
  493. OUT LPWSTR *DnsHostName OPTIONAL
  494. );
  495. DSGETDCAPI
  496. DWORD
  497. WINAPI
  498. DsGetDcNextA(
  499. IN HANDLE GetDcContextHandle,
  500. OUT PULONG SockAddressCount OPTIONAL,
  501. OUT LPSOCKET_ADDRESS *SockAddresses OPTIONAL,
  502. OUT LPSTR *DnsHostName OPTIONAL
  503. );
  504. #ifdef UNICODE
  505. #define DsGetDcNext DsGetDcNextW
  506. #else
  507. #define DsGetDcNext DsGetDcNextA
  508. #endif // !UNICODE
  509. DSGETDCAPI
  510. VOID
  511. WINAPI
  512. DsGetDcCloseW(
  513. IN HANDLE GetDcContextHandle
  514. );
  515. #ifdef UNICODE
  516. #define DsGetDcClose DsGetDcCloseW
  517. #else
  518. #define DsGetDcClose DsGetDcCloseW // same for ANSI
  519. #endif // !UNICODE
  520. #endif // _WINSOCK2API_
  521. #ifdef __cplusplus
  522. }
  523. #endif
  524. #endif // _DSGETDC_