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.

2164 lines
66 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. ntdsapi.h
  5. Abstract:
  6. This file contains structures, function prototypes, and definitions
  7. for public NTDS APIs other than directory interfaces like LDAP.
  8. Environment:
  9. User Mode - Win32
  10. Notes:
  11. --*/
  12. #ifndef _NTDSAPI_H_
  13. #define _NTDSAPI_H_
  14. #if _MSC_VER > 1000
  15. #pragma once
  16. #endif
  17. #include <schedule.h>
  18. #if !defined(_NTDSAPI_)
  19. #define NTDSAPI DECLSPEC_IMPORT
  20. #else
  21. #define NTDSAPI
  22. #endif
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. //////////////////////////////////////////////////////////////////////////
  27. // //
  28. // Data definitions //
  29. // //
  30. //////////////////////////////////////////////////////////////////////////
  31. #ifdef MIDL_PASS
  32. typedef GUID UUID;
  33. typedef void * RPC_AUTH_IDENTITY_HANDLE;
  34. typedef void VOID;
  35. #endif
  36. #define DS_DEFAULT_LOCALE \
  37. (MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), \
  38. SORT_DEFAULT))
  39. #define DS_DEFAULT_LOCALE_COMPARE_FLAGS (NORM_IGNORECASE | \
  40. NORM_IGNOREKANATYPE | \
  41. NORM_IGNORENONSPACE | \
  42. NORM_IGNOREWIDTH)
  43. // When booted to DS mode, this event is signalled when the DS has completed
  44. // its initial sync attempts. The period of time between system startup and
  45. // this event's state being set is indeterminate from the local service's
  46. // standpoint. In the meantime the contents of the DS should be considered
  47. // incomplete / out-dated, and the machine will not be advertised as a domain
  48. // controller to off-machine clients. Other local services that rely on
  49. // information published in the DS should avoid accessing (or at least
  50. // relying on) the contents of the DS until this event is set.
  51. #define DS_SYNCED_EVENT_NAME "NTDSInitialSyncsCompleted"
  52. #define DS_SYNCED_EVENT_NAME_W L"NTDSInitialSyncsCompleted"
  53. // Permissions bits used in security descriptors in the directory.
  54. #ifndef _DS_CONTROL_BITS_DEFINED_
  55. #define _DS_CONTROL_BITS_DEFINED_
  56. #define ACTRL_DS_OPEN 0x00000000
  57. #define ACTRL_DS_CREATE_CHILD 0x00000001
  58. #define ACTRL_DS_DELETE_CHILD 0x00000002
  59. #define ACTRL_DS_LIST 0x00000004
  60. #define ACTRL_DS_SELF 0x00000008
  61. #define ACTRL_DS_READ_PROP 0x00000010
  62. #define ACTRL_DS_WRITE_PROP 0x00000020
  63. #define ACTRL_DS_DELETE_TREE 0x00000040
  64. #define ACTRL_DS_LIST_OBJECT 0x00000080
  65. #define ACTRL_DS_CONTROL_ACCESS 0x00000100
  66. #endif
  67. typedef enum
  68. {
  69. // unknown name type
  70. DS_UNKNOWN_NAME = 0,
  71. // eg: CN=Spencer Katt,OU=Users,DC=Engineering,DC=Widget,DC=Com
  72. DS_FQDN_1779_NAME = 1,
  73. // eg: Engineering\SpencerK
  74. // Domain-only version includes trailing '\\'.
  75. DS_NT4_ACCOUNT_NAME = 2,
  76. // Probably "Spencer Katt" but could be something else. I.e. The
  77. // display name is not necessarily the defining RDN.
  78. DS_DISPLAY_NAME = 3,
  79. // obsolete - see #define later
  80. // DS_DOMAIN_SIMPLE_NAME = 4,
  81. // obsolete - see #define later
  82. // DS_ENTERPRISE_SIMPLE_NAME = 5,
  83. // String-ized GUID as returned by IIDFromString().
  84. // eg: {4fa050f0-f561-11cf-bdd9-00aa003a77b6}
  85. DS_UNIQUE_ID_NAME = 6,
  86. // eg: engineering.widget.com/software/spencer katt
  87. // Domain-only version includes trailing '/'.
  88. DS_CANONICAL_NAME = 7,
  89. // eg: [email protected]
  90. DS_USER_PRINCIPAL_NAME = 8,
  91. // Same as DS_CANONICAL_NAME except that rightmost '/' is
  92. // replaced with '\n' - even in domain-only case.
  93. // eg: engineering.widget.com/software\nspencer katt
  94. DS_CANONICAL_NAME_EX = 9,
  95. // eg: www/[email protected] - generalized service principal
  96. // names.
  97. DS_SERVICE_PRINCIPAL_NAME = 10
  98. } DS_NAME_FORMAT;
  99. // Map old name formats to closest new format so that old code builds
  100. // against new headers w/o errors and still gets (almost) correct result.
  101. #define DS_DOMAIN_SIMPLE_NAME DS_USER_PRINCIPAL_NAME
  102. #define DS_ENTERPRISE_SIMPLE_NAME DS_USER_PRINCIPAL_NAME
  103. typedef enum
  104. {
  105. DS_NAME_NO_FLAGS = 0x0,
  106. // Perform a syntactical mapping at the client (if possible) without
  107. // going out on the wire. Returns DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING
  108. // if a purely syntactical mapping is not possible.
  109. DS_NAME_FLAG_SYNTACTICAL_ONLY = 0x1,
  110. // Force a trip to the DC for evaluation, even if this could be
  111. // locally cracked syntactically.
  112. DS_NAME_FLAG_EVAL_AT_DC = 0x2
  113. } DS_NAME_FLAGS;
  114. typedef enum
  115. {
  116. DS_NAME_NO_ERROR = 0,
  117. // Generic processing error.
  118. DS_NAME_ERROR_RESOLVING = 1,
  119. // Couldn't find the name at all - or perhaps caller doesn't have
  120. // rights to see it.
  121. DS_NAME_ERROR_NOT_FOUND = 2,
  122. // Input name mapped to more than one output name.
  123. DS_NAME_ERROR_NOT_UNIQUE = 3,
  124. // Input name found, but not the associated output format.
  125. // Can happen if object doesn't have all the required attributes.
  126. DS_NAME_ERROR_NO_MAPPING = 4,
  127. // Unable to resolve entire name, but was able to determine which
  128. // domain object resides in. Thus DS_NAME_RESULT_ITEM?.pDomain
  129. // is valid on return.
  130. DS_NAME_ERROR_DOMAIN_ONLY = 5,
  131. // Unable to perform a purely syntactical mapping at the client
  132. // without going out on the wire.
  133. DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING = 6
  134. } DS_NAME_ERROR;
  135. #define DS_NAME_LEGAL_FLAGS (DS_NAME_FLAG_SYNTACTICAL_ONLY)
  136. typedef enum {
  137. // "paulle-nec.ntwksta.ms.com"
  138. DS_SPN_DNS_HOST = 0,
  139. // "cn=paulle-nec,ou=computers,dc=ntwksta,dc=ms,dc=com"
  140. DS_SPN_DN_HOST = 1,
  141. // "paulle-nec"
  142. DS_SPN_NB_HOST = 2,
  143. // "ntdev.ms.com"
  144. DS_SPN_DOMAIN = 3,
  145. // "ntdev"
  146. DS_SPN_NB_DOMAIN = 4,
  147. // "cn=anRpcService,cn=RPC Services,cn=system,dc=ms,dc=com"
  148. // "cn=aWsService,cn=Winsock Services,cn=system,dc=ms,dc=com"
  149. // "cn=aService,dc=itg,dc=ms,dc=com"
  150. // "www.ms.com", "ftp.ms.com", "ldap.ms.com"
  151. // "products.ms.com"
  152. DS_SPN_SERVICE = 5
  153. } DS_SPN_NAME_TYPE;
  154. typedef enum { // example:
  155. DS_SPN_ADD_SPN_OP = 0, // add SPNs
  156. DS_SPN_REPLACE_SPN_OP = 1, // set all SPNs
  157. DS_SPN_DELETE_SPN_OP = 2 // Delete SPNs
  158. } DS_SPN_WRITE_OP;
  159. typedef struct
  160. {
  161. DWORD status; // DS_NAME_ERROR
  162. #ifdef MIDL_PASS
  163. [string,unique] CHAR *pDomain; // DNS domain
  164. [string,unique] CHAR *pName; // name in requested format
  165. #else
  166. LPSTR pDomain; // DNS domain
  167. LPSTR pName; // name in requested format
  168. #endif
  169. } DS_NAME_RESULT_ITEMA, *PDS_NAME_RESULT_ITEMA;
  170. typedef struct
  171. {
  172. DWORD cItems; // item count
  173. #ifdef MIDL_PASS
  174. [size_is(cItems)] PDS_NAME_RESULT_ITEMA rItems;
  175. #else
  176. PDS_NAME_RESULT_ITEMA rItems; // item array
  177. #endif
  178. } DS_NAME_RESULTA, *PDS_NAME_RESULTA;
  179. typedef struct
  180. {
  181. DWORD status; // DS_NAME_ERROR
  182. #ifdef MIDL_PASS
  183. [string,unique] WCHAR *pDomain; // DNS domain
  184. [string,unique] WCHAR *pName; // name in requested format
  185. #else
  186. LPWSTR pDomain; // DNS domain
  187. LPWSTR pName; // name in requested format
  188. #endif
  189. } DS_NAME_RESULT_ITEMW, *PDS_NAME_RESULT_ITEMW;
  190. typedef struct
  191. {
  192. DWORD cItems; // item count
  193. #ifdef MIDL_PASS
  194. [size_is(cItems)] PDS_NAME_RESULT_ITEMW rItems;
  195. #else
  196. PDS_NAME_RESULT_ITEMW rItems; // item array
  197. #endif
  198. } DS_NAME_RESULTW, *PDS_NAME_RESULTW;
  199. #ifdef UNICODE
  200. #define DS_NAME_RESULT DS_NAME_RESULTW
  201. #define PDS_NAME_RESULT PDS_NAME_RESULTW
  202. #define DS_NAME_RESULT_ITEM DS_NAME_RESULT_ITEMW
  203. #define PDS_NAME_RESULT_ITEM PDS_NAME_RESULT_ITEMW
  204. #else
  205. #define DS_NAME_RESULT DS_NAME_RESULTA
  206. #define PDS_NAME_RESULT PDS_NAME_RESULTA
  207. #define DS_NAME_RESULT_ITEM DS_NAME_RESULT_ITEMA
  208. #define PDS_NAME_RESULT_ITEM PDS_NAME_RESULT_ITEMA
  209. #endif
  210. // Public replication option flags
  211. // ********************
  212. // Replica Sync flags
  213. // ********************
  214. // Perform this operation asynchronously.
  215. // Required when using DS_REPSYNC_ALL_SOURCES
  216. #define DS_REPSYNC_ASYNCHRONOUS_OPERATION 0x00000001
  217. // Writeable replica. Otherwise, read-only.
  218. #define DS_REPSYNC_WRITEABLE 0x00000002
  219. // This is a periodic sync request as scheduled by the admin.
  220. #define DS_REPSYNC_PERIODIC 0x00000004
  221. // Use inter-site messaging
  222. #define DS_REPSYNC_INTERSITE_MESSAGING 0x00000008
  223. // Sync from all sources.
  224. #define DS_REPSYNC_ALL_SOURCES 0x00000010
  225. // Sync starting from scratch (i.e., at the first USN).
  226. #define DS_REPSYNC_FULL 0x00000020
  227. // This is a notification of an update that was marked urgent.
  228. #define DS_REPSYNC_URGENT 0x00000040
  229. // Don't discard this synchronization request, even if a similar
  230. // sync is pending.
  231. #define DS_REPSYNC_NO_DISCARD 0x00000080
  232. // Sync even if link is currently disabled.
  233. #define DS_REPSYNC_FORCE 0x00000100
  234. // Causes the source DSA to check if a reps-to is present for the local DSA
  235. // (aka the destination). If not, one is added. This ensures that
  236. // source sends change notifications.
  237. #define DS_REPSYNC_ADD_REFERENCE 0x00000200
  238. // ********************
  239. // Replica Add flags
  240. // ********************
  241. // Perform this operation asynchronously.
  242. #define DS_REPADD_ASYNCHRONOUS_OPERATION 0x00000001
  243. // Create a writeable replica. Otherwise, read-only.
  244. #define DS_REPADD_WRITEABLE 0x00000002
  245. // Sync the NC from this source when the DSA is started.
  246. #define DS_REPADD_INITIAL 0x00000004
  247. // Sync the NC from this source periodically, as defined by the
  248. // schedule passed in the preptimesSync argument.
  249. #define DS_REPADD_PERIODIC 0x00000008
  250. // Sync from the source DSA via an Intersite Messaging Service (ISM) transport
  251. // (e.g., SMTP) rather than native DS RPC.
  252. #define DS_REPADD_INTERSITE_MESSAGING 0x00000010
  253. // Don't replicate the NC now -- just save enough state such that we
  254. // know to replicate it later.
  255. #define DS_REPADD_ASYNCHRONOUS_REPLICA 0x00000020
  256. // Disable notification-based synchronization for the NC from this source.
  257. // This is expected to be a temporary state; the similar flag
  258. // DS_REPADD_NEVER_NOTIFY should be used if the disable is to be more permanent.
  259. #define DS_REPADD_DISABLE_NOTIFICATION 0x00000040
  260. // Disable periodic synchronization for the NC from this source
  261. #define DS_REPADD_DISABLE_PERIODIC 0x00000080
  262. // Use compression when replicating. Saves message size (e.g., network
  263. // bandwidth) at the expense of extra CPU overhead at both the source and
  264. // destination servers.
  265. #define DS_REPADD_USE_COMPRESSION 0x00000100
  266. // Do not request change notifications from this source. When this flag is
  267. // set, the source will not notify the destination when changes occur.
  268. // Recommended for all intersite replication, which may occur over WAN links.
  269. // This is expected to be a more or less permanent state; the similar flag
  270. // DS_REPADD_DISABLE_NOTIFICATION should be used if notifications are to be
  271. // disabled only temporarily.
  272. #define DS_REPADD_NEVER_NOTIFY 0x00000200
  273. // ********************
  274. // Replica Delete flags
  275. // ********************
  276. // Perform this operation asynchronously.
  277. #define DS_REPDEL_ASYNCHRONOUS_OPERATION 0x00000001
  278. // The replica being deleted is writeable.
  279. #define DS_REPDEL_WRITEABLE 0x00000002
  280. // Replica is a mail-based replica
  281. #define DS_REPDEL_INTERSITE_MESSAGING 0x00000004
  282. // Ignore any error generated by contacting the source to tell it to scratch
  283. // this server from its Reps-To for this NC.
  284. #define DS_REPDEL_IGNORE_ERRORS 0x00000008
  285. // Do not contact the source telling it to scratch this server from its
  286. // Rep-To for this NC. Otherwise, if the link is RPC-based, the source will
  287. // be contacted.
  288. #define DS_REPDEL_LOCAL_ONLY 0x00000010
  289. // Delete all the objects in the NC
  290. // "No source" is incompatible with (and rejected for) writeable NCs. This is
  291. // valid only for read-only NCs, and then only if the NC has no source. This
  292. // can occur when the NC has been partially deleted (in which case the KCC
  293. // periodically calls the delete API with the "no source" flag set).
  294. #define DS_REPDEL_NO_SOURCE 0x00000020
  295. // Allow deletion of read-only replica even if it sources
  296. // other read-only replicas.
  297. #define DS_REPDEL_REF_OK 0x00000040
  298. // ********************
  299. // Replica Modify flags
  300. // ********************
  301. // Perform this operation asynchronously.
  302. #define DS_REPMOD_ASYNCHRONOUS_OPERATION 0x00000001
  303. // The replica is writeable.
  304. #define DS_REPMOD_WRITEABLE 0x00000002
  305. // ********************
  306. // Replica Modify fields
  307. // ********************
  308. #define DS_REPMOD_UPDATE_FLAGS 0x00000001
  309. #define DS_REPMOD_UPDATE_ADDRESS 0x00000002
  310. #define DS_REPMOD_UPDATE_SCHEDULE 0x00000004
  311. #define DS_REPMOD_UPDATE_RESULT 0x00000008
  312. #define DS_REPMOD_UPDATE_TRANSPORT 0x00000010
  313. // ********************
  314. // Update Refs fields
  315. // ********************
  316. // Perform this operation asynchronously.
  317. #define DS_REPUPD_ASYNCHRONOUS_OPERATION 0x00000001
  318. // The replica being deleted is writeable.
  319. #define DS_REPUPD_WRITEABLE 0x00000002
  320. // Add a reference
  321. #define DS_REPUPD_ADD_REFERENCE 0x00000004
  322. // Remove a reference
  323. #define DS_REPUPD_DELETE_REFERENCE 0x00000008
  324. // ***********************
  325. // Well Known Object Guids
  326. // ***********************
  327. #define GUID_USERS_CONTAINER_A "a9d1ca15768811d1aded00c04fd8d5cd"
  328. #define GUID_COMPUTRS_CONTAINER_A "aa312825768811d1aded00c04fd8d5cd"
  329. #define GUID_SYSTEMS_CONTAINER_A "ab1d30f3768811d1aded00c04fd8d5cd"
  330. #define GUID_DOMAIN_CONTROLLERS_CONTAINER_A "a361b2ffffd211d1aa4b00c04fd7d83a"
  331. #define GUID_INFRASTRUCTURE_CONTAINER_A "2fbac1870ade11d297c400c04fd8d5cd"
  332. #define GUID_DELETED_OBJECTS_CONTAINER_A "18e2ea80684f11d2b9aa00c04f79f805"
  333. #define GUID_LOSTANDFOUND_CONTAINER_A "ab8153b7768811d1aded00c04fd8d5cd"
  334. #define GUID_USERS_CONTAINER_W L"a9d1ca15768811d1aded00c04fd8d5cd"
  335. #define GUID_COMPUTRS_CONTAINER_W L"aa312825768811d1aded00c04fd8d5cd"
  336. #define GUID_SYSTEMS_CONTAINER_W L"ab1d30f3768811d1aded00c04fd8d5cd"
  337. #define GUID_DOMAIN_CONTROLLERS_CONTAINER_W L"a361b2ffffd211d1aa4b00c04fd7d83a"
  338. #define GUID_INFRASTRUCTURE_CONTAINER_W L"2fbac1870ade11d297c400c04fd8d5cd"
  339. #define GUID_DELETED_OBJECTS_CONTAINER_W L"18e2ea80684f11d2b9aa00c04f79f805"
  340. #define GUID_LOSTANDFOUND_CONTAINER_W L"ab8153b7768811d1aded00c04fd8d5cd"
  341. #define GUID_USERS_CONTAINER_BYTE "\xa9\xd1\xca\x15\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd"
  342. #define GUID_COMPUTRS_CONTAINER_BYTE "\xaa\x31\x28\x25\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd"
  343. #define GUID_SYSTEMS_CONTAINER_BYTE "\xab\x1d\x30\xf3\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd"
  344. #define GUID_DOMAIN_CONTROLLERS_CONTAINER_BYTE "\xa3\x61\xb2\xff\xff\xd2\x11\xd1\xaa\x4b\x00\xc0\x4f\xd7\xd8\x3a"
  345. #define GUID_INFRASTRUCTURE_CONTAINER_BYTE "\x2f\xba\xc1\x87\x0a\xde\x11\xd2\x97\xc4\x00\xc0\x4f\xd8\xd5\xcd"
  346. #define GUID_DELETED_OBJECTS_CONTAINER_BYTE "\x18\xe2\xea\x80\x68\x4f\x11\xd2\xb9\xaa\x00\xc0\x4f\x79\xf8\x05"
  347. #define GUID_LOSTANDFOUND_CONTAINER_BYTE "\xab\x81\x53\xb7\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd"
  348. //////////////////////////////////////////////////////////////////////////
  349. // //
  350. // Prototypes //
  351. // //
  352. //////////////////////////////////////////////////////////////////////////
  353. // DSBind takes two optional input parameters which identify whether the
  354. // caller found a domain controller themselves via DsGetDcName or whether
  355. // a domain controller should be found using default parameters.
  356. // Behavior of the possible combinations are outlined below.
  357. //
  358. // DomainControllerName(value), DnsDomainName(NULL)
  359. //
  360. // The value for DomainControllerName is assumed to have been
  361. // obtained via DsGetDcName (i.e. Field with the same name in a
  362. // DOMAIN_CONTROLLER_INFO struct on return from DsGetDcName call.)
  363. // The client is bound to the domain controller at this name.
  364. //
  365. // Mutual authentication will be performed using an SPN of
  366. // LDAP/DomainControllerName provided DomainControllerName
  367. // is not a NETBIOS name or IP address - i.e. it must be a
  368. // DNS host name.
  369. //
  370. // DomainControllerName(value), DnsDomainName(value)
  371. //
  372. // DsBind will connect to the server identified by DomainControllerName.
  373. //
  374. // Mutual authentication will be performed using an SPN of
  375. // LDAP/DomainControllerName/DnsDomainName provided neither value
  376. // is a NETBIOS names or IP address - i.e. they must be
  377. // valid DNS names.
  378. //
  379. // DomainControllerName(NULL), DnsDomainName(NULL)
  380. //
  381. // DsBind will attempt to find to a global catalog and fail if one
  382. // can not be found.
  383. //
  384. // Mutual authentication will be performed using an SPN of
  385. // GC/DnsHostName/ForestName where DnsHostName and ForestName
  386. // represent the DomainControllerName and DnsForestName fields
  387. // respectively of the DOMAIN_CONTROLLER_INFO returned by the
  388. // DsGetDcName call used to find a global catalog.
  389. //
  390. // DomainControllerName(NULL), DnsDomainName(value)
  391. //
  392. // DsBind will attempt to find a domain controller for the domain
  393. // identified by DnsDomainName and fail if one can not be found.
  394. //
  395. // Mutual authentication will be performed using an SPN of
  396. // LDAP/DnsHostName/DnsDomainName where DnsDomainName is that
  397. // provided by the caller and DnsHostName is that returned by
  398. // DsGetDcName for the domain specified - provided DnsDomainName
  399. // is a valid DNS domain name - i.e. not a NETBIOS domain name.
  400. NTDSAPI
  401. DWORD
  402. WINAPI
  403. DsBindW(
  404. LPCWSTR DomainControllerName, // in, optional
  405. LPCWSTR DnsDomainName, // in, optional
  406. HANDLE *phDS);
  407. NTDSAPI
  408. DWORD
  409. WINAPI
  410. DsBindA(
  411. LPCSTR DomainControllerName, // in, optional
  412. LPCSTR DnsDomainName, // in, optional
  413. HANDLE *phDS);
  414. #ifdef UNICODE
  415. #define DsBind DsBindW
  416. #else
  417. #define DsBind DsBindA
  418. #endif
  419. NTDSAPI
  420. DWORD
  421. WINAPI
  422. DsBindWithCredW(
  423. LPCWSTR DomainControllerName, // in, optional
  424. LPCWSTR DnsDomainName, // in, optional
  425. RPC_AUTH_IDENTITY_HANDLE AuthIdentity, // in, optional
  426. HANDLE *phDS);
  427. NTDSAPI
  428. DWORD
  429. WINAPI
  430. DsBindWithCredA(
  431. LPCSTR DomainControllerName, // in, optional
  432. LPCSTR DnsDomainName, // in, optional
  433. RPC_AUTH_IDENTITY_HANDLE AuthIdentity, // in, optional
  434. HANDLE *phDS);
  435. #ifdef UNICODE
  436. #define DsBindWithCred DsBindWithCredW
  437. #else
  438. #define DsBindWithCred DsBindWithCredA
  439. #endif
  440. //
  441. // DsUnBind
  442. //
  443. NTDSAPI
  444. DWORD
  445. WINAPI
  446. DsUnBindW(
  447. HANDLE *phDS); // in
  448. NTDSAPI
  449. DWORD
  450. WINAPI
  451. DsUnBindA(
  452. HANDLE *phDS); // in
  453. #ifdef UNICODE
  454. #define DsUnBind DsUnBindW
  455. #else
  456. #define DsUnBind DsUnBindA
  457. #endif
  458. //
  459. // DsMakePasswordCredentials
  460. //
  461. // This function constructs a credential structure which is suitable for input
  462. // to the DsBindWithCredentials function, or the ldap_open function (winldap.h)
  463. // The credential must be freed using DsFreeCredential.
  464. //
  465. // None of the input parameters may be present indicating a null, default
  466. // credential. Otherwise the username must be present. If the domain or
  467. // password are null, they default to empty strings. The domain name may be
  468. // null when the username is fully qualified, for example UPN format.
  469. //
  470. NTDSAPI
  471. DWORD
  472. WINAPI
  473. DsMakePasswordCredentialsW(
  474. LPWSTR User,
  475. LPWSTR Domain,
  476. LPWSTR Password,
  477. RPC_AUTH_IDENTITY_HANDLE *pAuthIdentity
  478. );
  479. NTDSAPI
  480. DWORD
  481. WINAPI
  482. DsMakePasswordCredentialsA(
  483. LPSTR User,
  484. LPSTR Domain,
  485. LPSTR Password,
  486. RPC_AUTH_IDENTITY_HANDLE *pAuthIdentity
  487. );
  488. #ifdef UNICODE
  489. #define DsMakePasswordCredentials DsMakePasswordCredentialsW
  490. #else
  491. #define DsMakePasswordCredentials DsMakePasswordCredentialsA
  492. #endif
  493. NTDSAPI
  494. VOID
  495. WINAPI
  496. DsFreePasswordCredentials(
  497. RPC_AUTH_IDENTITY_HANDLE AuthIdentity
  498. );
  499. #define DsFreePasswordCredentialsW DsFreePasswordCredentials
  500. #define DsFreePasswordCredentialsA DsFreePasswordCredentials
  501. //
  502. // DsCrackNames
  503. //
  504. NTDSAPI
  505. DWORD
  506. WINAPI
  507. DsCrackNamesW(
  508. HANDLE hDS, // in
  509. DS_NAME_FLAGS flags, // in
  510. DS_NAME_FORMAT formatOffered, // in
  511. DS_NAME_FORMAT formatDesired, // in
  512. DWORD cNames, // in
  513. const LPCWSTR *rpNames, // in
  514. PDS_NAME_RESULTW *ppResult); // out
  515. NTDSAPI
  516. DWORD
  517. WINAPI
  518. DsCrackNamesA(
  519. HANDLE hDS, // in
  520. DS_NAME_FLAGS flags, // in
  521. DS_NAME_FORMAT formatOffered, // in
  522. DS_NAME_FORMAT formatDesired, // in
  523. DWORD cNames, // in
  524. const LPCSTR *rpNames, // in
  525. PDS_NAME_RESULTA *ppResult); // out
  526. #ifdef UNICODE
  527. #define DsCrackNames DsCrackNamesW
  528. #else
  529. #define DsCrackNames DsCrackNamesA
  530. #endif
  531. //
  532. // DsFreeNameResult
  533. //
  534. NTDSAPI
  535. void
  536. WINAPI
  537. DsFreeNameResultW(
  538. DS_NAME_RESULTW *pResult); // in
  539. NTDSAPI
  540. void
  541. WINAPI
  542. DsFreeNameResultA(
  543. DS_NAME_RESULTA *pResult); // in
  544. #ifdef UNICODE
  545. #define DsFreeNameResult DsFreeNameResultW
  546. #else
  547. #define DsFreeNameResult DsFreeNameResultA
  548. #endif
  549. // ==========================================================
  550. // DSMakeSpn -- client call to create SPN for a service to which it wants to
  551. // authenticate.
  552. // This name is then passed to "pszTargetName" of InitializeSecurityContext().
  553. //
  554. // Notes:
  555. // If the service name is a DNS host name, or canonical DNS service name
  556. // e.g. "www.ms.com", i.e., caller resolved with gethostbyname, then instance
  557. // name should be NULL.
  558. // Realm is host name minus first component, unless it is in the exception list
  559. //
  560. // If the service name is NetBIOS machine name, then instance name should be
  561. // NULL
  562. // Form must be <domain>\<machine>
  563. // Realm will be <domain>
  564. //
  565. // If the service name is that of a replicated service, where each replica has
  566. // its own account (e.g., with SRV records) then the caller must supply the
  567. // instance name then realm name is same as ServiceName
  568. //
  569. // If the service name is a DN, then must also supply instance name
  570. // (DN could be name of service object (incl RPC or Winsock), name of machine
  571. // account, name of domain object)
  572. // then realm name is domain part of the DN
  573. //
  574. // If the service name is NetBIOS domain name, then must also supply instance
  575. // name; realm name is domain name
  576. //
  577. // If the service is named by an IP address -- then use referring service name
  578. // as service name
  579. //
  580. // ServiceClass - e.g. "http", "ftp", "ldap", GUID
  581. // ServiceName - DNS or DN; assumes we can compute domain from service name
  582. // InstanceName OPTIONAL- DNS name of host for instance of service
  583. // InstancePort - port number for instance (0 if default)
  584. // Referrer OPTIONAL- DNS name of host that gave this referral
  585. // pcSpnLength - in -- max length IN CHARACTERS of principal name;
  586. // out -- actual
  587. // Length includes terminator
  588. // pszSPN - server principal name
  589. //
  590. // If buffer is not large enough, ERROR_BUFFER_OVERFLOW is returned and the
  591. // needed length is returned in pcSpnLength.
  592. //
  593. //
  594. NTDSAPI
  595. DWORD
  596. WINAPI
  597. DsMakeSpnW(
  598. IN LPCWSTR ServiceClass,
  599. IN LPCWSTR ServiceName,
  600. IN LPCWSTR InstanceName,
  601. IN USHORT InstancePort,
  602. IN LPCWSTR Referrer,
  603. IN OUT DWORD *pcSpnLength,
  604. OUT LPWSTR pszSpn
  605. );
  606. NTDSAPI
  607. DWORD
  608. WINAPI
  609. DsMakeSpnA(
  610. IN LPCSTR ServiceClass,
  611. IN LPCSTR ServiceName,
  612. IN LPCSTR InstanceName,
  613. IN USHORT InstancePort,
  614. IN LPCSTR Referrer,
  615. IN OUT DWORD *pcSpnLength,
  616. OUT LPSTR pszSpn
  617. );
  618. #ifdef UNICODE
  619. #define DsMakeSpn DsMakeSpnW
  620. #else
  621. #define DsMakeSpn DsMakeSpnA
  622. #endif
  623. // ==========================================================
  624. // DsGetSPN -- server's call to gets SPNs for a service name by which it is
  625. // known to clients. N.B.: there may be more than one name by which clients
  626. // know it the SPNs are then passed to DsAddAccountSpn to register them in
  627. // the DS
  628. //
  629. // IN SpnNameType eType,
  630. // IN LPCTSTR ServiceClass,
  631. // kind of service -- "http", "ldap", "ftp", etc.
  632. // IN LPCTSTR ServiceName OPTIONAL,
  633. // name of service -- DN or DNS; not needed for host-based
  634. // IN USHORT InstancePort,
  635. // port number (0 => default) for instances
  636. // IN USHORT cInstanceNames,
  637. // count of extra instance names and ports (0=>use gethostbyname)
  638. // IN LPCTSTR InstanceNames[] OPTIONAL,
  639. // extra instance names (not used for host names)
  640. // IN USHORT InstancePorts[] OPTIONAL,
  641. // extra instance ports (0 => default)
  642. // IN OUT PULONG pcSpn, // count of SPNs
  643. // IN OUT LPTSTR * prpszSPN[]
  644. // a bunch of SPNs for this service; free with DsFreeSpnArray
  645. NTDSAPI
  646. DWORD
  647. WINAPI
  648. DsGetSpnA(
  649. IN DS_SPN_NAME_TYPE ServiceType,
  650. IN LPCSTR ServiceClass,
  651. IN LPCSTR ServiceName,
  652. IN USHORT InstancePort,
  653. IN USHORT cInstanceNames,
  654. IN LPCSTR *pInstanceNames,
  655. IN const USHORT *pInstancePorts,
  656. OUT DWORD *pcSpn,
  657. OUT LPSTR **prpszSpn
  658. );
  659. NTDSAPI
  660. DWORD
  661. WINAPI
  662. DsGetSpnW(
  663. IN DS_SPN_NAME_TYPE ServiceType,
  664. IN LPCWSTR ServiceClass,
  665. IN LPCWSTR ServiceName,
  666. IN USHORT InstancePort,
  667. IN USHORT cInstanceNames,
  668. IN LPCWSTR *pInstanceNames,
  669. IN const USHORT *pInstancePorts,
  670. OUT DWORD *pcSpn,
  671. OUT LPWSTR **prpszSpn
  672. );
  673. #ifdef UNICODE
  674. #define DsGetSpn DsGetSpnW
  675. #else
  676. #define DsGetSpn DsGetSpnA
  677. #endif
  678. // ==========================================================
  679. // DsFreeSpnArray() -- Free array returned by DsGetSpn{A,W}
  680. NTDSAPI
  681. void
  682. WINAPI
  683. DsFreeSpnArrayA(
  684. IN DWORD cSpn,
  685. IN OUT LPSTR *rpszSpn
  686. );
  687. NTDSAPI
  688. void
  689. WINAPI
  690. DsFreeSpnArrayW(
  691. IN DWORD cSpn,
  692. IN OUT LPWSTR *rpszSpn
  693. );
  694. #ifdef UNICODE
  695. #define DsFreeSpnArray DsFreeSpnArrayW
  696. #else
  697. #define DsFreeSpnArray DsFreeSpnArrayA
  698. #endif
  699. // ==========================================================
  700. // DsCrackSpn() -- parse an SPN into the ServiceClass,
  701. // ServiceName, and InstanceName (and InstancePort) pieces.
  702. // An SPN is passed in, along with a pointer to the maximum length
  703. // for each piece and a pointer to a buffer where each piece should go.
  704. // On exit, the maximum lengths are updated to the actual length for each piece
  705. // and the buffer contain the appropriate piece. The InstancePort is 0 if not
  706. // present.
  707. //
  708. // DWORD DsCrackSpn(
  709. // IN LPTSTR pszSPN, // the SPN to parse
  710. // IN OUT PUSHORT pcServiceClass, // input -- max length of ServiceClass;
  711. // output -- actual length
  712. // OUT LPCTSTR ServiceClass, // the ServiceClass part of the SPN
  713. // IN OUT PUSHORT pcServiceName, // input -- max length of ServiceName;
  714. // output -- actual length
  715. // OUT LPCTSTR ServiceName, // the ServiceName part of the SPN
  716. // IN OUT PUSHORT pcInstance, // input -- max length of ServiceClass;
  717. // output -- actual length
  718. // OUT LPCTSTR InstanceName, // the InstanceName part of the SPN
  719. // OUT PUSHORT InstancePort // instance port
  720. //
  721. // Note: lengths are in characters; all string lengths include terminators
  722. // All arguments except pszSpn are optional.
  723. //
  724. NTDSAPI
  725. DWORD
  726. WINAPI
  727. DsCrackSpnA(
  728. IN LPCSTR pszSpn,
  729. IN OUT LPDWORD pcServiceClass,
  730. OUT LPSTR ServiceClass,
  731. IN OUT LPDWORD pcServiceName,
  732. OUT LPSTR ServiceName,
  733. IN OUT LPDWORD pcInstanceName,
  734. OUT LPSTR InstanceName,
  735. OUT USHORT *pInstancePort
  736. );
  737. NTDSAPI
  738. DWORD
  739. WINAPI
  740. DsCrackSpnW(
  741. IN LPCWSTR pszSpn,
  742. IN OUT DWORD *pcServiceClass,
  743. OUT LPWSTR ServiceClass,
  744. IN OUT DWORD *pcServiceName,
  745. OUT LPWSTR ServiceName,
  746. IN OUT DWORD *pcInstanceName,
  747. OUT LPWSTR InstanceName,
  748. OUT USHORT *pInstancePort
  749. );
  750. #ifdef UNICODE
  751. #define DsCrackSpn DsCrackSpnW
  752. #else
  753. #define DsCrackSpn DsCrackSpnA
  754. #endif
  755. // ==========================================================
  756. // DsWriteAccountSpn -- set or add SPNs for an account object
  757. // Usually done by service itself, or perhaps by an admin.
  758. //
  759. // This call is RPC'd to the DC where the account object is stored, so it can
  760. // securely enforce policy on what SPNs are allowed on the account. Direct LDAP
  761. // writes to the SPN property are not allowed -- all writes must come through
  762. // this RPC call. (Reads via // LDAP are OK.)
  763. //
  764. // The account object can be a machine accout, or a service (user) account.
  765. //
  766. // If called by the service to register itself, it can most easily get
  767. // the names by calling DsGetSpn with each of the names that
  768. // clients can use to find the service.
  769. //
  770. // IN SpnWriteOp eOp, // set, add
  771. // IN LPCTSTR pszAccount, // DN of account to which to add SPN
  772. // IN int cSPN, // count of SPNs to add to account
  773. // IN LPCTSTR rpszSPN[] // SPNs to add to altSecID property
  774. NTDSAPI
  775. DWORD
  776. WINAPI
  777. DsWriteAccountSpnA(
  778. IN HANDLE hDS,
  779. IN DS_SPN_WRITE_OP Operation,
  780. IN LPCSTR pszAccount,
  781. IN DWORD cSpn,
  782. IN LPCSTR *rpszSpn
  783. );
  784. NTDSAPI
  785. DWORD
  786. WINAPI
  787. DsWriteAccountSpnW(
  788. IN HANDLE hDS,
  789. IN DS_SPN_WRITE_OP Operation,
  790. IN LPCWSTR pszAccount,
  791. IN DWORD cSpn,
  792. IN LPCWSTR *rpszSpn
  793. );
  794. #ifdef UNICODE
  795. #define DsWriteAccountSpn DsWriteAccountSpnW
  796. #else
  797. #define DsWriteAccountSpn DsWriteAccountSpnA
  798. #endif
  799. /*++
  800. Routine Description:
  801. Constructs a Service Principal Name suitable to identify the desired server.
  802. The service class and part of a dns hostname must be supplied.
  803. This routine is a simplified wrapper to DsMakeSpn.
  804. The ServiceName is made canonical by resolving through DNS.
  805. Guid-based dns names are not supported.
  806. The simplified SPN constructed looks like this:
  807. ServiceClass / ServiceName / ServiceName
  808. The instance name portion (2nd position) is always defaulted. The port and
  809. referrer fields are not used.
  810. Arguments:
  811. ServiceClass - Class of service, defined by the service, can be any
  812. string unique to the service
  813. ServiceName - dns hostname, fully qualified or not
  814. Stringized IP address is also resolved if necessary
  815. pcSpnLength - IN, maximum length of buffer, in chars
  816. OUT, space utilized, in chars, including terminator
  817. pszSpn - Buffer, atleast of length *pcSpnLength
  818. Return Value:
  819. WINAPI - Win32 error code
  820. --*/
  821. NTDSAPI
  822. DWORD
  823. WINAPI
  824. DsClientMakeSpnForTargetServerW(
  825. IN LPCWSTR ServiceClass,
  826. IN LPCWSTR ServiceName,
  827. IN OUT DWORD *pcSpnLength,
  828. OUT LPWSTR pszSpn
  829. );
  830. NTDSAPI
  831. DWORD
  832. WINAPI
  833. DsClientMakeSpnForTargetServerA(
  834. IN LPCSTR ServiceClass,
  835. IN LPCSTR ServiceName,
  836. IN OUT DWORD *pcSpnLength,
  837. OUT LPSTR pszSpn
  838. );
  839. #ifdef UNICODE
  840. #define DsClientMakeSpnForTargetServer DsClientMakeSpnForTargetServerW
  841. #else
  842. #define DsClientMakeSpnForTargetServer DsClientMakeSpnForTargetServerA
  843. #endif
  844. /*++
  845. Routine Description:
  846. Register Service Principal Names for a server application.
  847. This routine does the following:
  848. 1. Enumerates a list of server SPNs using DsGetSpn and the provided class
  849. 2. Determines the domain of the current user context
  850. 3. Determines the DN of the current user context if not supplied
  851. 4. Locates a domain controller
  852. 5. Binds to the domain controller
  853. 6. Uses DsWriteAccountSpn to write the SPNs on the named object DN
  854. 7. Unbinds
  855. Construct server SPNs for this service, and write them to the right object.
  856. If the userObjectDn is specified, the SPN is written to that object.
  857. Otherwise the Dn is defaulted, to the user object, then computer.
  858. Now, bind to the DS, and register the name on the object for the
  859. user this service is running as. So, if we're running as local
  860. system, we'll register it on the computer object itself. If we're
  861. running as a domain user, we'll add the SPN to the user's object.
  862. Arguments:
  863. Operation - What should be done with the values: add, replace or delete
  864. ServiceClass - Unique string identifying service
  865. UserObjectDN - Optional, dn of object to write SPN to
  866. Return Value:
  867. WINAPI - Win32 error code
  868. --*/
  869. NTDSAPI
  870. DWORD
  871. WINAPI
  872. DsServerRegisterSpnA(
  873. IN DS_SPN_WRITE_OP Operation,
  874. IN LPCSTR ServiceClass,
  875. IN LPCSTR UserObjectDN
  876. );
  877. NTDSAPI
  878. DWORD
  879. WINAPI
  880. DsServerRegisterSpnW(
  881. IN DS_SPN_WRITE_OP Operation,
  882. IN LPCWSTR ServiceClass,
  883. IN LPCWSTR UserObjectDN
  884. );
  885. #ifdef UNICODE
  886. #define DsServerRegisterSpn DsServerRegisterSpnW
  887. #else
  888. #define DsServerRegisterSpn DsServerRegisterSpnA
  889. #endif
  890. // DsReplicaSync. The server that this call is executing on is called the
  891. // destination. The destination's naming context will be brought up to date
  892. // with respect to a source system. The source system is identified by the
  893. // uuid. The uuid is that of the source system's "NTDS Settings" object.
  894. // The destination system must already be configured such that the source
  895. // system is one of the systems from which it recieves replication data
  896. // ("replication from"). This is usually done automatically by the KCC.
  897. //
  898. // PARAMETERS:
  899. // pNC (DSNAME *)
  900. // Name of the NC to synchronize.
  901. // puuidSourceDRA (SZ)
  902. // objectGuid of DSA with which to synchronize the replica.
  903. // ulOptions (ULONG)
  904. // Bitwise OR of zero or more flags
  905. // RETURNS: WIN32 STATUS
  906. NTDSAPI
  907. DWORD
  908. WINAPI
  909. DsReplicaSyncA(
  910. IN HANDLE hDS,
  911. IN LPCSTR NameContext,
  912. IN const UUID *pUuidDsaSrc,
  913. IN ULONG Options
  914. );
  915. NTDSAPI
  916. DWORD
  917. WINAPI
  918. DsReplicaSyncW(
  919. IN HANDLE hDS,
  920. IN LPCWSTR NameContext,
  921. IN const UUID *pUuidDsaSrc,
  922. IN ULONG Options
  923. );
  924. #ifdef UNICODE
  925. #define DsReplicaSync DsReplicaSyncW
  926. #else
  927. #define DsReplicaSync DsReplicaSyncA
  928. #endif
  929. // DsReplicaAdd
  930. //
  931. /*
  932. Description:
  933. This call is executed on the destination. It causes the destination to
  934. add a "replication from" reference to the indicated source system.
  935. The source server is identified by string name, not uuid as with Sync.
  936. The DsaSrcAddress parameter is the transport specific address of the source
  937. DSA, usually its guid-based dns name. The guid in the guid-based dns name is
  938. the object-guid of that server's ntds-dsa (settings) object.
  939. Arguments:
  940. pNC (IN) - NC for which to add the replica. The NC record must exist
  941. locally as either an object (instantiated or not) or a reference
  942. phantom (i.e., a phantom with a guid).
  943. pSourceDsaDN (IN) - DN of the source DSA's ntdsDsa object. Required if
  944. ulOptions includes DS_REPADD_ASYNCHRONOUS_REPLICA; ignored otherwise.
  945. pTransportDN (IN) - DN of the interSiteTransport object representing the
  946. transport by which to communicate with the source server. Required if
  947. ulOptions includes INTERSITE_MESSAGING; ignored otherwise.
  948. pszSourceDsaAddress (IN) - Transport-specific address of the source DSA.
  949. pSchedule (IN) - Schedule by which to replicate the NC from this
  950. source in the future.
  951. ulOptions (IN) - flags
  952. RETURNS: WIN32 STATUS
  953. */
  954. NTDSAPI
  955. DWORD
  956. WINAPI
  957. DsReplicaAddA(
  958. IN HANDLE hDS,
  959. IN LPCSTR NameContext,
  960. IN LPCSTR SourceDsaDn,
  961. IN LPCSTR TransportDn,
  962. IN LPCSTR SourceDsaAddress,
  963. IN const PSCHEDULE pSchedule,
  964. IN DWORD Options
  965. );
  966. NTDSAPI
  967. DWORD
  968. WINAPI
  969. DsReplicaAddW(
  970. IN HANDLE hDS,
  971. IN LPCWSTR NameContext,
  972. IN LPCWSTR SourceDsaDn,
  973. IN LPCWSTR TransportDn,
  974. IN LPCWSTR SourceDsaAddress,
  975. IN const PSCHEDULE pSchedule,
  976. IN DWORD Options
  977. );
  978. #ifdef UNICODE
  979. #define DsReplicaAdd DsReplicaAddW
  980. #else
  981. #define DsReplicaAdd DsReplicaAddA
  982. #endif
  983. // DsReplicaDel
  984. //
  985. // The server that this call is executing on is the destination. The call
  986. // causes the destination to remove a "replication from" reference to the
  987. // indicated source server.
  988. // The source server is identified by string name, not uuid as with Sync.
  989. // The DsaSrc parameter is the transport specific address of the source DSA,
  990. // usually its guid-based dns name. The guid in the guid-based dns name is
  991. // the object-guid of that server's ntds-dsa (settings) object.
  992. //
  993. // PARAMETERS:
  994. // pNC (DSNAME *)
  995. // Name of the NC for which to delete a source.
  996. // pszSourceDRA (SZ)
  997. // DSA for which to delete the source.
  998. // ulOptions (ULONG)
  999. // Bitwise OR of zero or more flags
  1000. // RETURNS: WIN32 STATUS
  1001. NTDSAPI
  1002. DWORD
  1003. WINAPI
  1004. DsReplicaDelA(
  1005. IN HANDLE hDS,
  1006. IN LPCSTR NameContext,
  1007. IN LPCSTR DsaSrc,
  1008. IN ULONG Options
  1009. );
  1010. NTDSAPI
  1011. DWORD
  1012. WINAPI
  1013. DsReplicaDelW(
  1014. IN HANDLE hDS,
  1015. IN LPCWSTR NameContext,
  1016. IN LPCWSTR DsaSrc,
  1017. IN ULONG Options
  1018. );
  1019. #ifdef UNICODE
  1020. #define DsReplicaDel DsReplicaDelW
  1021. #else
  1022. #define DsReplicaDel DsReplicaDelA
  1023. #endif
  1024. // DsReplicaModify
  1025. //
  1026. //
  1027. // Modify a source for a given naming context
  1028. //
  1029. // The value must already exist.
  1030. //
  1031. // Either the UUID or the address may be used to identify the current value.
  1032. // If a UUID is specified, the UUID will be used for comparison. Otherwise,
  1033. // the address will be used for comparison.
  1034. //
  1035. // PARAMETERS:
  1036. // pNC (DSNAME *)
  1037. // Name of the NC for which the Reps-From should be modified.
  1038. // puuidSourceDRA (UUID *)
  1039. // Invocation-ID of the referenced DRA. May be NULL if:
  1040. // . ulModifyFields does not include DS_REPMOD_UPDATE_ADDRESS and
  1041. // . pmtxSourceDRA is non-NULL.
  1042. // puuidTransportObj (UUID *)
  1043. // objectGuid of the transport by which replication is to be performed
  1044. // Ignored if ulModifyFields does not include
  1045. // DS_REPMOD_UPDATE_TRANSPORT.
  1046. // pszSourceDRA (SZ)
  1047. // DSA for which the reference should be added or deleted. Ignored if
  1048. // puuidSourceDRA is non-NULL and ulModifyFields does not include
  1049. // DS_REPMOD_UPDATE_ADDRESS.
  1050. // prtSchedule (REPLTIMES *)
  1051. // Periodic replication schedule for this replica. Ignored if
  1052. // ulModifyFields does not include DS_REPMOD_UPDATE_SCHEDULE.
  1053. // ulReplicaFlags (ULONG)
  1054. // Flags to set for this replica. Ignored if ulModifyFields does not
  1055. // include DS_REPMOD_UPDATE_FLAGS.
  1056. // ulModifyFields (ULONG)
  1057. // Fields to update. One or more of the following bit flags:
  1058. // UPDATE_ADDRESS
  1059. // Update the MTX_ADDR associated with the referenced server.
  1060. // UPDATE_SCHEDULE
  1061. // Update the periodic replication schedule associated with
  1062. // the replica.
  1063. // UPDATE_FLAGS
  1064. // Update the flags associated with the replica.
  1065. // UPDATE_TRANSPORT
  1066. // Update the transport associated with the replica.
  1067. // ulOptions (ULONG)
  1068. // Bitwise OR of zero or more of the following:
  1069. // DS_REPMOD_ASYNCHRONOUS_OPERATION
  1070. // Perform this operation asynchronously.
  1071. // RETURNS: WIN32 STATUS
  1072. NTDSAPI
  1073. DWORD
  1074. WINAPI
  1075. DsReplicaModifyA(
  1076. IN HANDLE hDS,
  1077. IN LPCSTR NameContext,
  1078. IN const UUID *pUuidSourceDsa,
  1079. IN LPCSTR TransportDn,
  1080. IN LPCSTR SourceDsaAddress,
  1081. IN const PSCHEDULE pSchedule,
  1082. IN DWORD ReplicaFlags,
  1083. IN DWORD ModifyFields,
  1084. IN DWORD Options
  1085. );
  1086. NTDSAPI
  1087. DWORD
  1088. WINAPI
  1089. DsReplicaModifyW(
  1090. IN HANDLE hDS,
  1091. IN LPCWSTR NameContext,
  1092. IN const UUID *pUuidSourceDsa,
  1093. IN LPCWSTR TransportDn,
  1094. IN LPCWSTR SourceDsaAddress,
  1095. IN const PSCHEDULE pSchedule,
  1096. IN DWORD ReplicaFlags,
  1097. IN DWORD ModifyFields,
  1098. IN DWORD Options
  1099. );
  1100. #ifdef UNICODE
  1101. #define DsReplicaModify DsReplicaModifyW
  1102. #else
  1103. #define DsReplicaModify DsReplicaModifyA
  1104. #endif
  1105. // DsReplicaUpdateRefs
  1106. //
  1107. // In this case, the RPC is being executed on the "source" of destination-sourc
  1108. // replication relationship. This function tells the source that it no longer
  1109. // supplies replication information to the indicated destination system.
  1110. // Add or remove a target server from the Reps-To property on the given NC.
  1111. // Add/remove a reference given the DSNAME of the corresponding NTDS-DSA
  1112. // object.
  1113. //
  1114. // PARAMETERS:
  1115. // pNC (DSNAME *)
  1116. // Name of the NC for which the Reps-To should be modified.
  1117. // DsaDest (SZ)
  1118. // Network address of DSA for which the reference should be added
  1119. // or deleted.
  1120. // pUuidDsaDest (UUID *)
  1121. // Invocation-ID of DSA for which the reference should be added
  1122. // or deleted.
  1123. // ulOptions (ULONG)
  1124. // Bitwise OR of zero or more of the following:
  1125. // DS_REPUPD_ASYNC_OP
  1126. // Perform this operation asynchronously.
  1127. // DS_REPUPD_ADD_REFERENCE
  1128. // Add the given server to the Reps-To property.
  1129. // DS_REPUPD_DEL_REFERENCE
  1130. // Remove the given server from the Reps-To property.
  1131. // Note that ADD_REF and DEL_REF may be paired to perform
  1132. // "add or update".
  1133. //
  1134. // RETURNS: WIN32 STATUS
  1135. NTDSAPI
  1136. DWORD
  1137. WINAPI
  1138. DsReplicaUpdateRefsA(
  1139. IN HANDLE hDS,
  1140. IN LPCSTR NameContext,
  1141. IN LPCSTR DsaDest,
  1142. IN const UUID *pUuidDsaDest,
  1143. IN ULONG Options
  1144. );
  1145. NTDSAPI
  1146. DWORD
  1147. WINAPI
  1148. DsReplicaUpdateRefsW(
  1149. IN HANDLE hDS,
  1150. IN LPCWSTR NameContext,
  1151. IN LPCWSTR DsaDest,
  1152. IN const UUID *pUuidDsaDest,
  1153. IN ULONG Options
  1154. );
  1155. #ifdef UNICODE
  1156. #define DsReplicaUpdateRefs DsReplicaUpdateRefsW
  1157. #else
  1158. #define DsReplicaUpdateRefs DsReplicaUpdateRefsA
  1159. #endif
  1160. // Friends of DsReplicaSyncAll
  1161. typedef enum {
  1162. DS_REPSYNCALL_WIN32_ERROR_CONTACTING_SERVER = 0,
  1163. DS_REPSYNCALL_WIN32_ERROR_REPLICATING = 1,
  1164. DS_REPSYNCALL_SERVER_UNREACHABLE = 2
  1165. } DS_REPSYNCALL_ERROR;
  1166. typedef enum {
  1167. DS_REPSYNCALL_EVENT_ERROR = 0,
  1168. DS_REPSYNCALL_EVENT_SYNC_STARTED = 1,
  1169. DS_REPSYNCALL_EVENT_SYNC_COMPLETED = 2,
  1170. DS_REPSYNCALL_EVENT_FINISHED = 3
  1171. } DS_REPSYNCALL_EVENT;
  1172. // Friends of DsReplicaSyncAll
  1173. typedef struct {
  1174. LPSTR pszSrcId;
  1175. LPSTR pszDstId;
  1176. LPSTR pszNC;
  1177. GUID * pguidSrc;
  1178. GUID * pguidDst;
  1179. } DS_REPSYNCALL_SYNCA, * PDS_REPSYNCALL_SYNCA;
  1180. typedef struct {
  1181. LPWSTR pszSrcId;
  1182. LPWSTR pszDstId;
  1183. LPWSTR pszNC;
  1184. GUID * pguidSrc;
  1185. GUID * pguidDst;
  1186. } DS_REPSYNCALL_SYNCW, * PDS_REPSYNCALL_SYNCW;
  1187. typedef struct {
  1188. LPSTR pszSvrId;
  1189. DS_REPSYNCALL_ERROR error;
  1190. DWORD dwWin32Err;
  1191. LPSTR pszSrcId;
  1192. } DS_REPSYNCALL_ERRINFOA, * PDS_REPSYNCALL_ERRINFOA;
  1193. typedef struct {
  1194. LPWSTR pszSvrId;
  1195. DS_REPSYNCALL_ERROR error;
  1196. DWORD dwWin32Err;
  1197. LPWSTR pszSrcId;
  1198. } DS_REPSYNCALL_ERRINFOW, * PDS_REPSYNCALL_ERRINFOW;
  1199. typedef struct {
  1200. DS_REPSYNCALL_EVENT event;
  1201. DS_REPSYNCALL_ERRINFOA * pErrInfo;
  1202. DS_REPSYNCALL_SYNCA * pSync;
  1203. } DS_REPSYNCALL_UPDATEA, * PDS_REPSYNCALL_UPDATEA;
  1204. typedef struct {
  1205. DS_REPSYNCALL_EVENT event;
  1206. DS_REPSYNCALL_ERRINFOW * pErrInfo;
  1207. DS_REPSYNCALL_SYNCW * pSync;
  1208. } DS_REPSYNCALL_UPDATEW, * PDS_REPSYNCALL_UPDATEW;
  1209. #ifdef UNICODE
  1210. #define DS_REPSYNCALL_SYNC DS_REPSYNCALL_SYNCW
  1211. #define DS_REPSYNCALL_ERRINFO DS_REPSYNCALL_ERRINFOW
  1212. #define DS_REPSYNCALL_UPDATE DS_REPSYNCALL_UPDATEW
  1213. #define PDS_REPSYNCALL_SYNC PDS_REPSYNCALL_SYNCW
  1214. #define PDS_REPSYNCALL_ERRINFO PDS_REPSYNCALL_ERRINFOW
  1215. #define PDS_REPSYNCALL_UPDATE PDS_REPSYNCALL_UPDATEW
  1216. #else
  1217. #define DS_REPSYNCALL_SYNC DS_REPSYNCALL_SYNCA
  1218. #define DS_REPSYNCALL_ERRINFO DS_REPSYNCALL_ERRINFOA
  1219. #define DS_REPSYNCALL_UPDATE DS_REPSYNCALL_UPDATEA
  1220. #define PDS_REPSYNCALL_SYNC PDS_REPSYNCALL_SYNCA
  1221. #define PDS_REPSYNCALL_ERRINFO PDS_REPSYNCALL_ERRINFOA
  1222. #define PDS_REPSYNCALL_UPDATE PDS_REPSYNCALL_UPDATEA
  1223. #endif
  1224. // **********************
  1225. // Replica SyncAll flags
  1226. // **********************
  1227. // This option has no effect.
  1228. #define DS_REPSYNCALL_NO_OPTIONS 0x00000000
  1229. // Ordinarily, if a server cannot be contacted, DsReplicaSyncAll tries to
  1230. // route around it and replicate from as many servers as possible. Enabling
  1231. // this option will cause DsReplicaSyncAll to generate a fatal error if any
  1232. // server cannot be contacted, or if any server is unreachable (due to a
  1233. // disconnected or broken topology.)
  1234. #define DS_REPSYNCALL_ABORT_IF_SERVER_UNAVAILABLE 0x00000001
  1235. // This option disables transitive replication; syncs will only be performed
  1236. // with adjacent servers and no DsBind calls will be made.
  1237. #define DS_REPSYNCALL_SYNC_ADJACENT_SERVERS_ONLY 0x00000002
  1238. // Ordinarily, when DsReplicaSyncAll encounters a non-fatal error, it returns
  1239. // the GUID DNS of the relevant server(s). Enabling this option causes
  1240. // DsReplicaSyncAll to return the servers' DNs instead.
  1241. #define DS_REPSYNCALL_ID_SERVERS_BY_DN 0x00000004
  1242. // This option disables all syncing. The topology will still be analyzed and
  1243. // unavailable / unreachable servers will still be identified.
  1244. #define DS_REPSYNCALL_DO_NOT_SYNC 0x00000008
  1245. // Ordinarily, DsReplicaSyncAll attempts to bind to all servers before
  1246. // generating the topology. If a server cannot be contacted, DsReplicaSyncAll
  1247. // excludes that server from the topology and tries to route around it. If
  1248. // this option is enabled, checking will be bypassed and DsReplicaSyncAll will
  1249. // assume all servers are responding. This will speed operation of
  1250. // DsReplicaSyncAll, but if some servers are not responding, some transitive
  1251. // replications may be blocked.
  1252. #define DS_REPSYNCALL_SKIP_INITIAL_CHECK 0x00000010
  1253. // Push mode. Push changes from the home server out to all partners using
  1254. // transitive replication. This reverses the direction of replication, and
  1255. // the order of execution of the replication sets from the usual "pulling"
  1256. // mode of execution.
  1257. #define DS_REPSYNCALL_PUSH_CHANGES_OUTWARD 0x00000020
  1258. // Cross site boundaries. By default, the only servers that are considered are
  1259. // those in the same site as the home system. With this option, all servers in
  1260. // the enterprise, across all sites, are eligible. They must be connected by
  1261. // a synchronous (RPC) transport, however.
  1262. #define DS_REPSYNCALL_CROSS_SITE_BOUNDARIES 0x00000040
  1263. // DsReplicaSyncAll. Syncs the destination server with all other servers
  1264. // in the site.
  1265. //
  1266. // PARAMETERS:
  1267. // hDS (IN) - A DS connection bound to the destination server.
  1268. // pszNameContext (IN) - The naming context to synchronize
  1269. // ulFlags (IN) - Bitwise OR of zero or more flags
  1270. // pFnCallBack (IN, OPTIONAL) - Callback function for message-passing.
  1271. // pCallbackData (IN, OPTIONAL) - A pointer that will be passed to the
  1272. // first argument of the callback function.
  1273. // pErrors (OUT, OPTIONAL) - Pointer to a (PDS_REPSYNCALL_ERRINFO *)
  1274. // object that will hold an array of error structures.
  1275. NTDSAPI
  1276. DWORD
  1277. WINAPI
  1278. DsReplicaSyncAllA (
  1279. HANDLE hDS,
  1280. LPCSTR pszNameContext,
  1281. ULONG ulFlags,
  1282. BOOL (__stdcall * pFnCallBack) (LPVOID, PDS_REPSYNCALL_UPDATEA),
  1283. LPVOID pCallbackData,
  1284. PDS_REPSYNCALL_ERRINFOA ** pErrors
  1285. );
  1286. NTDSAPI
  1287. DWORD
  1288. WINAPI
  1289. DsReplicaSyncAllW (
  1290. HANDLE hDS,
  1291. LPCWSTR pszNameContext,
  1292. ULONG ulFlags,
  1293. BOOL (__stdcall * pFnCallBack) (LPVOID, PDS_REPSYNCALL_UPDATEW),
  1294. LPVOID pCallbackData,
  1295. PDS_REPSYNCALL_ERRINFOW ** pErrors
  1296. );
  1297. #ifdef UNICODE
  1298. #define DsReplicaSyncAll DsReplicaSyncAllW
  1299. #else
  1300. #define DsReplicaSyncAll DsReplicaSyncAllA
  1301. #endif
  1302. NTDSAPI
  1303. DWORD
  1304. WINAPI
  1305. DsRemoveDsServerW(
  1306. HANDLE hDs, // in
  1307. LPWSTR ServerDN, // in
  1308. LPWSTR DomainDN, // in, optional
  1309. BOOL *fLastDcInDomain, // out, optional
  1310. BOOL fCommit // in
  1311. );
  1312. NTDSAPI
  1313. DWORD
  1314. WINAPI
  1315. DsRemoveDsServerA(
  1316. HANDLE hDs, // in
  1317. LPSTR ServerDN, // in
  1318. LPSTR DomainDN, // in, optional
  1319. BOOL *fLastDcInDomain, // out, optional
  1320. BOOL fCommit // in
  1321. );
  1322. #ifdef UNICODE
  1323. #define DsRemoveDsServer DsRemoveDsServerW
  1324. #else
  1325. #define DsRemoveDsServer DsRemoveDsServerA
  1326. #endif
  1327. NTDSAPI
  1328. DWORD
  1329. WINAPI
  1330. DsRemoveDsDomainW(
  1331. HANDLE hDs, // in
  1332. LPWSTR DomainDN // in
  1333. );
  1334. NTDSAPI
  1335. DWORD
  1336. WINAPI
  1337. DsRemoveDsDomainA(
  1338. HANDLE hDs, // in
  1339. LPSTR DomainDN // in
  1340. );
  1341. #ifdef UNICODE
  1342. #define DsRemoveDsDomain DsRemoveDsDomainW
  1343. #else
  1344. #define DsRemoveDsDomain DsRemoveDsDomainA
  1345. #endif
  1346. NTDSAPI
  1347. DWORD
  1348. WINAPI
  1349. DsListSitesA(
  1350. HANDLE hDs, // in
  1351. PDS_NAME_RESULTA *ppSites); // out
  1352. NTDSAPI
  1353. DWORD
  1354. WINAPI
  1355. DsListSitesW(
  1356. HANDLE hDs, // in
  1357. PDS_NAME_RESULTW *ppSites); // out
  1358. #ifdef UNICODE
  1359. #define DsListSites DsListSitesW
  1360. #else
  1361. #define DsListSites DsListSitesA
  1362. #endif
  1363. NTDSAPI
  1364. DWORD
  1365. WINAPI
  1366. DsListServersInSiteA(
  1367. HANDLE hDs, // in
  1368. LPCSTR site, // in
  1369. PDS_NAME_RESULTA *ppServers); // out
  1370. NTDSAPI
  1371. DWORD
  1372. WINAPI
  1373. DsListServersInSiteW(
  1374. HANDLE hDs, // in
  1375. LPCWSTR site, // in
  1376. PDS_NAME_RESULTW *ppServers); // out
  1377. #ifdef UNICODE
  1378. #define DsListServersInSite DsListServersInSiteW
  1379. #else
  1380. #define DsListServersInSite DsListServersInSiteA
  1381. #endif
  1382. NTDSAPI
  1383. DWORD
  1384. WINAPI
  1385. DsListDomainsInSiteA(
  1386. HANDLE hDs, // in
  1387. LPCSTR site, // in
  1388. PDS_NAME_RESULTA *ppDomains); // out
  1389. NTDSAPI
  1390. DWORD
  1391. WINAPI
  1392. DsListDomainsInSiteW(
  1393. HANDLE hDs, // in
  1394. LPCWSTR site, // in
  1395. PDS_NAME_RESULTW *ppDomains); // out
  1396. #ifdef UNICODE
  1397. #define DsListDomainsInSite DsListDomainsInSiteW
  1398. #else
  1399. #define DsListDomainsInSite DsListDomainsInSiteA
  1400. #endif
  1401. NTDSAPI
  1402. DWORD
  1403. WINAPI
  1404. DsListServersForDomainInSiteA(
  1405. HANDLE hDs, // in
  1406. LPCSTR domain, // in
  1407. LPCSTR site, // in
  1408. PDS_NAME_RESULTA *ppServers); // out
  1409. NTDSAPI
  1410. DWORD
  1411. WINAPI
  1412. DsListServersForDomainInSiteW(
  1413. HANDLE hDs, // in
  1414. LPCWSTR domain, // in
  1415. LPCWSTR site, // in
  1416. PDS_NAME_RESULTW *ppServers); // out
  1417. #ifdef UNICODE
  1418. #define DsListServersForDomainInSite DsListServersForDomainInSiteW
  1419. #else
  1420. #define DsListServersForDomainInSite DsListServersForDomainInSiteA
  1421. #endif
  1422. // Define indices for DsListInfoForServer return data. Check status
  1423. // for each field as a given value may not be present.
  1424. #define DS_LIST_DSA_OBJECT_FOR_SERVER 0
  1425. #define DS_LIST_DNS_HOST_NAME_FOR_SERVER 1
  1426. #define DS_LIST_ACCOUNT_OBJECT_FOR_SERVER 2
  1427. NTDSAPI
  1428. DWORD
  1429. WINAPI
  1430. DsListInfoForServerA(
  1431. HANDLE hDs, // in
  1432. LPCSTR server, // in
  1433. PDS_NAME_RESULTA *ppInfo); // out
  1434. NTDSAPI
  1435. DWORD
  1436. WINAPI
  1437. DsListInfoForServerW(
  1438. HANDLE hDs, // in
  1439. LPCWSTR server, // in
  1440. PDS_NAME_RESULTW *ppInfo); // out
  1441. #ifdef UNICODE
  1442. #define DsListInfoForServer DsListInfoForServerW
  1443. #else
  1444. #define DsListInfoForServer DsListInfoForServerA
  1445. #endif
  1446. // Define indices for DsListRoles return data. Check status for
  1447. // each field as a given value may not be present.
  1448. #define DS_ROLE_SCHEMA_OWNER 0
  1449. #define DS_ROLE_DOMAIN_OWNER 1
  1450. #define DS_ROLE_PDC_OWNER 2
  1451. #define DS_ROLE_RID_OWNER 3
  1452. #define DS_ROLE_INFRASTRUCTURE_OWNER 4
  1453. NTDSAPI
  1454. DWORD
  1455. WINAPI
  1456. DsListRolesA(
  1457. HANDLE hDs, // in
  1458. PDS_NAME_RESULTA *ppRoles); // out
  1459. NTDSAPI
  1460. DWORD
  1461. WINAPI
  1462. DsListRolesW(
  1463. HANDLE hDs, // in
  1464. PDS_NAME_RESULTW *ppRoles); // out
  1465. #ifdef UNICODE
  1466. #define DsListRoles DsListRolesW
  1467. #else
  1468. #define DsListRoles DsListRolesA
  1469. #endif
  1470. // Definitions required for DsMapSchemaGuid routines.
  1471. #define DS_SCHEMA_GUID_NOT_FOUND 0
  1472. #define DS_SCHEMA_GUID_ATTR 1
  1473. #define DS_SCHEMA_GUID_ATTR_SET 2
  1474. #define DS_SCHEMA_GUID_CLASS 3
  1475. #define DS_SCHEMA_GUID_CONTROL_RIGHT 4
  1476. typedef struct
  1477. {
  1478. GUID guid; // mapped GUID
  1479. DWORD guidType; // DS_SCHEMA_GUID_* value
  1480. #ifdef MIDL_PASS
  1481. [string,unique] CHAR *pName; // might be NULL
  1482. #else
  1483. LPSTR pName; // might be NULL
  1484. #endif
  1485. } DS_SCHEMA_GUID_MAPA, *PDS_SCHEMA_GUID_MAPA;
  1486. typedef struct
  1487. {
  1488. GUID guid; // mapped GUID
  1489. DWORD guidType; // DS_SCHEMA_GUID_* value
  1490. #ifdef MIDL_PASS
  1491. [string,unique] WCHAR *pName; // might be NULL
  1492. #else
  1493. LPWSTR pName; // might be NULL
  1494. #endif
  1495. } DS_SCHEMA_GUID_MAPW, *PDS_SCHEMA_GUID_MAPW;
  1496. NTDSAPI
  1497. DWORD
  1498. WINAPI
  1499. DsMapSchemaGuidsA(
  1500. HANDLE hDs, // in
  1501. DWORD cGuids, // in
  1502. GUID *rGuids, // in
  1503. DS_SCHEMA_GUID_MAPA **ppGuidMap); // out
  1504. NTDSAPI
  1505. VOID
  1506. WINAPI
  1507. DsFreeSchemaGuidMapA(
  1508. PDS_SCHEMA_GUID_MAPA pGuidMap); // in
  1509. NTDSAPI
  1510. DWORD
  1511. WINAPI
  1512. DsMapSchemaGuidsW(
  1513. HANDLE hDs, // in
  1514. DWORD cGuids, // in
  1515. GUID *rGuids, // in
  1516. DS_SCHEMA_GUID_MAPW **ppGuidMap); // out
  1517. NTDSAPI
  1518. VOID
  1519. WINAPI
  1520. DsFreeSchemaGuidMapW(
  1521. PDS_SCHEMA_GUID_MAPW pGuidMap); // in
  1522. #ifdef UNICODE
  1523. #define DS_SCHEMA_GUID_MAP DS_SCHEMA_GUID_MAPW
  1524. #define PDS_SCHEMA_GUID_MAP PDS_SCHEMA_GUID_MAPW
  1525. #define DsMapSchemaGuids DsMapSchemaGuidsW
  1526. #define DsFreeSchemaGuidMap DsFreeSchemaGuidMapW
  1527. #else
  1528. #define DS_SCHEMA_GUID_MAP DS_SCHEMA_GUID_MAPA
  1529. #define PDS_SCHEMA_GUID_MAP PDS_SCHEMA_GUID_MAPA
  1530. #define DsMapSchemaGuids DsMapSchemaGuidsA
  1531. #define DsFreeSchemaGuidMap DsFreeSchemaGuidMapA
  1532. #endif
  1533. typedef struct
  1534. {
  1535. #ifdef MIDL_PASS
  1536. [string,unique] CHAR *NetbiosName; // might be NULL
  1537. [string,unique] CHAR *DnsHostName; // might be NULL
  1538. [string,unique] CHAR *SiteName; // might be NULL
  1539. [string,unique] CHAR *ComputerObjectName; // might be NULL
  1540. [string,unique] CHAR *ServerObjectName; // might be NULL
  1541. #else
  1542. LPSTR NetbiosName; // might be NULL
  1543. LPSTR DnsHostName; // might be NULL
  1544. LPSTR SiteName; // might be NULL
  1545. LPSTR ComputerObjectName; // might be NULL
  1546. LPSTR ServerObjectName; // might be NULL
  1547. #endif
  1548. BOOL fIsPdc;
  1549. BOOL fDsEnabled;
  1550. } DS_DOMAIN_CONTROLLER_INFO_1A, *PDS_DOMAIN_CONTROLLER_INFO_1A;
  1551. typedef struct
  1552. {
  1553. #ifdef MIDL_PASS
  1554. [string,unique] WCHAR *NetbiosName; // might be NULL
  1555. [string,unique] WCHAR *DnsHostName; // might be NULL
  1556. [string,unique] WCHAR *SiteName; // might be NULL
  1557. [string,unique] WCHAR *ComputerObjectName; // might be NULL
  1558. [string,unique] WCHAR *ServerObjectName; // might be NULL
  1559. #else
  1560. LPWSTR NetbiosName; // might be NULL
  1561. LPWSTR DnsHostName; // might be NULL
  1562. LPWSTR SiteName; // might be NULL
  1563. LPWSTR ComputerObjectName; // might be NULL
  1564. LPWSTR ServerObjectName; // might be NULL
  1565. #endif
  1566. BOOL fIsPdc;
  1567. BOOL fDsEnabled;
  1568. } DS_DOMAIN_CONTROLLER_INFO_1W, *PDS_DOMAIN_CONTROLLER_INFO_1W;
  1569. typedef struct
  1570. {
  1571. #ifdef MIDL_PASS
  1572. [string,unique] CHAR *NetbiosName; // might be NULL
  1573. [string,unique] CHAR *DnsHostName; // might be NULL
  1574. [string,unique] CHAR *SiteName; // might be NULL
  1575. [string,unique] CHAR *SiteObjectName; // might be NULL
  1576. [string,unique] CHAR *ComputerObjectName; // might be NULL
  1577. [string,unique] CHAR *ServerObjectName; // might be NULL
  1578. [string,unique] CHAR *NtdsDsaObjectName; // might be NULL
  1579. #else
  1580. LPSTR NetbiosName; // might be NULL
  1581. LPSTR DnsHostName; // might be NULL
  1582. LPSTR SiteName; // might be NULL
  1583. LPSTR SiteObjectName; // might be NULL
  1584. LPSTR ComputerObjectName; // might be NULL
  1585. LPSTR ServerObjectName; // might be NULL
  1586. LPSTR NtdsDsaObjectName; // might be NULL
  1587. #endif
  1588. BOOL fIsPdc;
  1589. BOOL fDsEnabled;
  1590. BOOL fIsGc;
  1591. // Valid iff SiteObjectName non-NULL.
  1592. GUID SiteObjectGuid;
  1593. // Valid iff ComputerObjectName non-NULL.
  1594. GUID ComputerObjectGuid;
  1595. // Valid iff ServerObjectName non-NULL;
  1596. GUID ServerObjectGuid;
  1597. // Valid iff fDsEnabled is TRUE.
  1598. GUID NtdsDsaObjectGuid;
  1599. } DS_DOMAIN_CONTROLLER_INFO_2A, *PDS_DOMAIN_CONTROLLER_INFO_2A;
  1600. typedef struct
  1601. {
  1602. #ifdef MIDL_PASS
  1603. [string,unique] WCHAR *NetbiosName; // might be NULL
  1604. [string,unique] WCHAR *DnsHostName; // might be NULL
  1605. [string,unique] WCHAR *SiteName; // might be NULL
  1606. [string,unique] WCHAR *SiteObjectName; // might be NULL
  1607. [string,unique] WCHAR *ComputerObjectName; // might be NULL
  1608. [string,unique] WCHAR *ServerObjectName; // might be NULL
  1609. [string,unique] WCHAR *NtdsDsaObjectName; // might be NULL
  1610. #else
  1611. LPWSTR NetbiosName; // might be NULL
  1612. LPWSTR DnsHostName; // might be NULL
  1613. LPWSTR SiteName; // might be NULL
  1614. LPWSTR SiteObjectName; // might be NULL
  1615. LPWSTR ComputerObjectName; // might be NULL
  1616. LPWSTR ServerObjectName; // might be NULL
  1617. LPWSTR NtdsDsaObjectName; // might be NULL
  1618. #endif
  1619. BOOL fIsPdc;
  1620. BOOL fDsEnabled;
  1621. BOOL fIsGc;
  1622. // Valid iff SiteObjectName non-NULL.
  1623. GUID SiteObjectGuid;
  1624. // Valid iff ComputerObjectName non-NULL.
  1625. GUID ComputerObjectGuid;
  1626. // Valid iff ServerObjectName non-NULL;
  1627. GUID ServerObjectGuid;
  1628. // Valid iff fDsEnabled is TRUE.
  1629. GUID NtdsDsaObjectGuid;
  1630. } DS_DOMAIN_CONTROLLER_INFO_2W, *PDS_DOMAIN_CONTROLLER_INFO_2W;
  1631. // The following APIs strictly find domain controller account objects
  1632. // in the DS and return information associated with them. As such, they
  1633. // may return entries which correspond to domain controllers long since
  1634. // decommissioned, etc. and there is no guarantee that there exists a
  1635. // physical domain controller at all. Use DsGetDcName (dsgetdc.h) to find
  1636. // live domain controllers for a domain.
  1637. NTDSAPI
  1638. DWORD
  1639. WINAPI
  1640. DsGetDomainControllerInfoA(
  1641. HANDLE hDs, // in
  1642. LPCSTR DomainName, // in
  1643. DWORD InfoLevel, // in
  1644. DWORD *pcOut, // out
  1645. VOID **ppInfo); // out
  1646. NTDSAPI
  1647. DWORD
  1648. WINAPI
  1649. DsGetDomainControllerInfoW(
  1650. HANDLE hDs, // in
  1651. LPCWSTR DomainName, // in
  1652. DWORD InfoLevel, // in
  1653. DWORD *pcOut, // out
  1654. VOID **ppInfo); // out
  1655. NTDSAPI
  1656. VOID
  1657. WINAPI
  1658. DsFreeDomainControllerInfoA(
  1659. DWORD InfoLevel, // in
  1660. DWORD cInfo, // in
  1661. VOID *pInfo); // in
  1662. NTDSAPI
  1663. VOID
  1664. WINAPI
  1665. DsFreeDomainControllerInfoW(
  1666. DWORD InfoLevel, // in
  1667. DWORD cInfo, // in
  1668. VOID *pInfo); // in
  1669. #ifdef UNICODE
  1670. #define DS_DOMAIN_CONTROLLER_INFO_1 DS_DOMAIN_CONTROLLER_INFO_1W
  1671. #define DS_DOMAIN_CONTROLLER_INFO_2 DS_DOMAIN_CONTROLLER_INFO_2W
  1672. #define PDS_DOMAIN_CONTROLLER_INFO_1 PDS_DOMAIN_CONTROLLER_INFO_1W
  1673. #define PDS_DOMAIN_CONTROLLER_INFO_2 PDS_DOMAIN_CONTROLLER_INFO_2W
  1674. #define DsGetDomainControllerInfo DsGetDomainControllerInfoW
  1675. #define DsFreeDomainControllerInfo DsFreeDomainControllerInfoW
  1676. #else
  1677. #define DS_DOMAIN_CONTROLLER_INFO_1 DS_DOMAIN_CONTROLLER_INFO_1A
  1678. #define DS_DOMAIN_CONTROLLER_INFO_2 DS_DOMAIN_CONTROLLER_INFO_2A
  1679. #define PDS_DOMAIN_CONTROLLER_INFO_1 PDS_DOMAIN_CONTROLLER_INFO_1A
  1680. #define PDS_DOMAIN_CONTROLLER_INFO_2 PDS_DOMAIN_CONTROLLER_INFO_2A
  1681. #define DsGetDomainControllerInfo DsGetDomainControllerInfoA
  1682. #define DsFreeDomainControllerInfo DsFreeDomainControllerInfoA
  1683. #endif
  1684. // Which task should be run?
  1685. typedef enum {
  1686. DS_KCC_TASKID_UPDATE_TOPOLOGY = 0
  1687. } DS_KCC_TASKID;
  1688. // Don't wait for completion of the task; queue it and return.
  1689. #define DS_KCC_FLAG_ASYNC_OP (1)
  1690. NTDSAPI
  1691. DWORD
  1692. WINAPI
  1693. DsReplicaConsistencyCheck(
  1694. HANDLE hDS, // in
  1695. DS_KCC_TASKID TaskID, // in
  1696. DWORD dwFlags); // in
  1697. typedef enum _DS_REPL_INFO_TYPE {
  1698. DS_REPL_INFO_NEIGHBORS = 0, // returns DS_REPL_NEIGHBORS *
  1699. DS_REPL_INFO_CURSORS_FOR_NC = 1, // returns DS_REPL_CURSORS *
  1700. DS_REPL_INFO_METADATA_FOR_OBJ = 2, // returns DS_REPL_OBJECT_META_DATA *
  1701. // <- insert new DS_REPL_INFO_* types here.
  1702. DS_REPL_INFO_TYPE_MAX
  1703. } DS_REPL_INFO_TYPE;
  1704. // Bit values for the dwReplicaFlags field of the DS_REPL_NEIGHBOR structure.
  1705. #define DS_REPL_NBR_WRITEABLE (0x10)
  1706. #define DS_REPL_NBR_SYNC_ON_STARTUP (0x20)
  1707. #define DS_REPL_NBR_DO_SCHEDULED_SYNCS (0x40)
  1708. #define DS_REPL_NBR_USE_ASYNC_INTERSITE_TRANSPORT (0x80)
  1709. #define DS_REPL_NBR_FULL_SYNC_IN_PROGRESS (0x10000)
  1710. #define DS_REPL_NBR_FULL_SYNC_NEXT_PACKET (0x20000)
  1711. #define DS_REPL_NBR_NEVER_SYNCED (0x200000)
  1712. #define DS_REPL_NBR_IGNORE_CHANGE_NOTIFICATIONS (0x4000000)
  1713. #define DS_REPL_NBR_DISABLE_SCHEDULED_SYNC (0x8000000)
  1714. #define DS_REPL_NBR_COMPRESS_CHANGES (0x10000000)
  1715. #define DS_REPL_NBR_NO_CHANGE_NOTIFICATIONS (0x20000000)
  1716. typedef struct _DS_REPL_NEIGHBORW {
  1717. LPWSTR pszNamingContext;
  1718. LPWSTR pszSourceDsaDN;
  1719. LPWSTR pszSourceDsaAddress;
  1720. LPWSTR pszAsyncIntersiteTransportDN;
  1721. DWORD dwReplicaFlags;
  1722. DWORD dwReserved; // alignment
  1723. UUID uuidNamingContextObjGuid;
  1724. UUID uuidSourceDsaObjGuid;
  1725. UUID uuidSourceDsaInvocationID;
  1726. UUID uuidAsyncIntersiteTransportObjGuid;
  1727. USN usnLastObjChangeSynced;
  1728. USN usnAttributeFilter;
  1729. FILETIME ftimeLastSyncSuccess;
  1730. FILETIME ftimeLastSyncAttempt;
  1731. DWORD dwLastSyncResult;
  1732. DWORD cNumConsecutiveSyncFailures;
  1733. } DS_REPL_NEIGHBORW;
  1734. typedef struct _DS_REPL_NEIGHBORSW {
  1735. DWORD cNumNeighbors;
  1736. DWORD dwReserved; // alignment
  1737. #ifdef MIDL_PASS
  1738. [size_is(cNumNeighbors)] DS_REPL_NEIGHBORW rgNeighbor[];
  1739. #else
  1740. DS_REPL_NEIGHBORW rgNeighbor[1];
  1741. #endif
  1742. } DS_REPL_NEIGHBORSW;
  1743. typedef struct _DS_REPL_CURSOR {
  1744. UUID uuidSourceDsaInvocationID;
  1745. USN usnAttributeFilter;
  1746. } DS_REPL_CURSOR;
  1747. typedef struct _DS_REPL_CURSORS {
  1748. DWORD cNumCursors;
  1749. DWORD dwReserved; // alignment
  1750. #ifdef MIDL_PASS
  1751. [size_is(cNumCursors)] DS_REPL_CURSOR rgCursor[];
  1752. #else
  1753. DS_REPL_CURSOR rgCursor[1];
  1754. #endif
  1755. } DS_REPL_CURSORS;
  1756. typedef struct _DS_REPL_ATTR_META_DATA {
  1757. LPWSTR pszAttributeName;
  1758. DWORD dwVersion;
  1759. FILETIME ftimeLastOriginatingChange;
  1760. UUID uuidLastOriginatingDsaInvocationID;
  1761. USN usnOriginatingChange; // in the originating DSA's USN space
  1762. USN usnLocalChange; // in the local DSA's USN space
  1763. } DS_REPL_ATTR_META_DATA;
  1764. typedef struct _DS_REPL_OBJ_META_DATA {
  1765. DWORD cNumEntries;
  1766. DWORD dwReserved; // alignment
  1767. #ifdef MIDL_PASS
  1768. [size_is(cNumEntries)] DS_REPL_ATTR_META_DATA rgMetaData[];
  1769. #else
  1770. DS_REPL_ATTR_META_DATA rgMetaData[1];
  1771. #endif
  1772. } DS_REPL_OBJ_META_DATA;
  1773. NTDSAPI
  1774. DWORD
  1775. WINAPI
  1776. DsReplicaGetInfoW(
  1777. HANDLE hDS, // in
  1778. DS_REPL_INFO_TYPE InfoType, // in
  1779. LPCWSTR pszObject, // in
  1780. UUID * puuidForSourceDsaObjGuid, // in
  1781. VOID ** ppInfo); // out
  1782. NTDSAPI
  1783. void
  1784. WINAPI
  1785. DsReplicaFreeInfo(
  1786. DS_REPL_INFO_TYPE InfoType, // in
  1787. VOID * pInfo); // in
  1788. #ifdef UNICODE
  1789. #define DsReplicaGetInfo DsReplicaGetInfoW
  1790. #define DS_REPL_NEIGHBOR DS_REPL_NEIGHBORW
  1791. #define DS_REPL_NEIGHBORS DS_REPL_NEIGHBORSW
  1792. #else
  1793. // No ANSI equivalents currently supported.
  1794. #endif
  1795. NTDSAPI
  1796. DWORD
  1797. WINAPI
  1798. DsAddSidHistoryW(
  1799. HANDLE hDS, // in
  1800. DWORD Flags, // in - sbz for now
  1801. LPCWSTR SrcDomain, // in - DNS or NetBIOS
  1802. LPCWSTR SrcPrincipal, // in - SAM account name
  1803. LPCWSTR SrcDomainController, // in, optional
  1804. RPC_AUTH_IDENTITY_HANDLE SrcDomainCreds, // in - creds for src domain
  1805. LPCWSTR DstDomain, // in - DNS or NetBIOS
  1806. LPCWSTR DstPrincipal); // in - SAM account name
  1807. NTDSAPI
  1808. DWORD
  1809. WINAPI
  1810. DsAddSidHistoryA(
  1811. HANDLE hDS, // in
  1812. DWORD Flags, // in - sbz for now
  1813. LPCSTR SrcDomain, // in - DNS or NetBIOS
  1814. LPCSTR SrcPrincipal, // in - SAM account name
  1815. LPCSTR SrcDomainController, // in, optional
  1816. RPC_AUTH_IDENTITY_HANDLE SrcDomainCreds, // in - creds for src domain
  1817. LPCSTR DstDomain, // in - DNS or NetBIOS
  1818. LPCSTR DstPrincipal); // in - SAM account name
  1819. #ifdef UNICODE
  1820. #define DsAddSidHistory DsAddSidHistoryW
  1821. #else
  1822. #define DsAddSidHistory DsAddSidHistoryA
  1823. #endif
  1824. #ifdef __cplusplus
  1825. }
  1826. #endif
  1827. #endif // _NTDSAPI_H_