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.

3515 lines
114 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) 1996-2000 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. #if !defined(_NTDSAPI_POSTXP_ASLIB_)
  21. #define NTDSAPI_POSTXP DECLSPEC_IMPORT
  22. #else
  23. #define NTDSAPI_POSTXP
  24. #endif
  25. #else
  26. #define NTDSAPI
  27. #define NTDSAPI_POSTXP
  28. #endif
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. //////////////////////////////////////////////////////////////////////////
  33. // //
  34. // Data definitions //
  35. // //
  36. //////////////////////////////////////////////////////////////////////////
  37. #ifdef MIDL_PASS
  38. typedef GUID UUID;
  39. typedef void * RPC_AUTH_IDENTITY_HANDLE;
  40. typedef void VOID;
  41. #endif
  42. // Following constants define the Active Directory Behavior
  43. // Version numbers.
  44. #define DS_BEHAVIOR_WIN2000 0
  45. #define DS_BEHAVIOR_WIN2003_WITH_MIXED_DOMAINS 1
  46. #define DS_BEHAVIOR_WIN2003 2
  47. #define DS_DEFAULT_LOCALE \
  48. (MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), \
  49. SORT_DEFAULT))
  50. #define DS_DEFAULT_LOCALE_COMPARE_FLAGS (NORM_IGNORECASE | \
  51. NORM_IGNOREKANATYPE | \
  52. NORM_IGNORENONSPACE | \
  53. NORM_IGNOREWIDTH | \
  54. SORT_STRINGSORT )
  55. // When booted to DS mode, this event is signalled when the DS has completed
  56. // its initial sync attempts. The period of time between system startup and
  57. // this event's state being set is indeterminate from the local service's
  58. // standpoint. In the meantime the contents of the DS should be considered
  59. // incomplete / out-dated, and the machine will not be advertised as a domain
  60. // controller to off-machine clients. Other local services that rely on
  61. // information published in the DS should avoid accessing (or at least
  62. // relying on) the contents of the DS until this event is set.
  63. #define DS_SYNCED_EVENT_NAME "NTDSInitialSyncsCompleted"
  64. #define DS_SYNCED_EVENT_NAME_W L"NTDSInitialSyncsCompleted"
  65. // Permissions bits used in security descriptors in the directory.
  66. #ifndef _DS_CONTROL_BITS_DEFINED_
  67. #define _DS_CONTROL_BITS_DEFINED_
  68. #define ACTRL_DS_OPEN 0x00000000
  69. #define ACTRL_DS_CREATE_CHILD 0x00000001
  70. #define ACTRL_DS_DELETE_CHILD 0x00000002
  71. #define ACTRL_DS_LIST 0x00000004
  72. #define ACTRL_DS_SELF 0x00000008
  73. #define ACTRL_DS_READ_PROP 0x00000010
  74. #define ACTRL_DS_WRITE_PROP 0x00000020
  75. #define ACTRL_DS_DELETE_TREE 0x00000040
  76. #define ACTRL_DS_LIST_OBJECT 0x00000080
  77. #define ACTRL_DS_CONTROL_ACCESS 0x00000100
  78. // generic read
  79. #define DS_GENERIC_READ ((STANDARD_RIGHTS_READ) | \
  80. (ACTRL_DS_LIST) | \
  81. (ACTRL_DS_READ_PROP) | \
  82. (ACTRL_DS_LIST_OBJECT))
  83. // generic execute
  84. #define DS_GENERIC_EXECUTE ((STANDARD_RIGHTS_EXECUTE) | \
  85. (ACTRL_DS_LIST))
  86. // generic right
  87. #define DS_GENERIC_WRITE ((STANDARD_RIGHTS_WRITE) | \
  88. (ACTRL_DS_SELF) | \
  89. (ACTRL_DS_WRITE_PROP))
  90. // generic all
  91. #define DS_GENERIC_ALL ((STANDARD_RIGHTS_REQUIRED) | \
  92. (ACTRL_DS_CREATE_CHILD) | \
  93. (ACTRL_DS_DELETE_CHILD) | \
  94. (ACTRL_DS_DELETE_TREE) | \
  95. (ACTRL_DS_READ_PROP) | \
  96. (ACTRL_DS_WRITE_PROP) | \
  97. (ACTRL_DS_LIST) | \
  98. (ACTRL_DS_LIST_OBJECT) | \
  99. (ACTRL_DS_CONTROL_ACCESS) | \
  100. (ACTRL_DS_SELF))
  101. #endif
  102. typedef enum
  103. {
  104. // unknown name type
  105. DS_UNKNOWN_NAME = 0,
  106. // eg: CN=User Name,OU=Users,DC=Example,DC=Microsoft,DC=Com
  107. DS_FQDN_1779_NAME = 1,
  108. // eg: Example\UserN
  109. // Domain-only version includes trailing '\\'.
  110. DS_NT4_ACCOUNT_NAME = 2,
  111. // Probably "User Name" but could be something else. I.e. The
  112. // display name is not necessarily the defining RDN.
  113. DS_DISPLAY_NAME = 3,
  114. // obsolete - see #define later
  115. // DS_DOMAIN_SIMPLE_NAME = 4,
  116. // obsolete - see #define later
  117. // DS_ENTERPRISE_SIMPLE_NAME = 5,
  118. // String-ized GUID as returned by IIDFromString().
  119. // eg: {4fa050f0-f561-11cf-bdd9-00aa003a77b6}
  120. DS_UNIQUE_ID_NAME = 6,
  121. // eg: example.microsoft.com/software/user name
  122. // Domain-only version includes trailing '/'.
  123. DS_CANONICAL_NAME = 7,
  124. // eg: [email protected]
  125. DS_USER_PRINCIPAL_NAME = 8,
  126. // Same as DS_CANONICAL_NAME except that rightmost '/' is
  127. // replaced with '\n' - even in domain-only case.
  128. // eg: example.microsoft.com/software\nuser name
  129. DS_CANONICAL_NAME_EX = 9,
  130. // eg: www/[email protected] - generalized service principal
  131. // names.
  132. DS_SERVICE_PRINCIPAL_NAME = 10,
  133. // This is the string representation of a SID. Invalid for formatDesired.
  134. // See sddl.h for SID binary <--> text conversion routines.
  135. // eg: S-1-5-21-397955417-626881126-188441444-501
  136. DS_SID_OR_SID_HISTORY_NAME = 11,
  137. // Pseudo-name format so GetUserNameEx can return the DNS domain name to
  138. // a caller. This level is not supported by the DS APIs.
  139. DS_DNS_DOMAIN_NAME = 12
  140. } DS_NAME_FORMAT;
  141. // Map old name formats to closest new format so that old code builds
  142. // against new headers w/o errors and still gets (almost) correct result.
  143. #define DS_DOMAIN_SIMPLE_NAME DS_USER_PRINCIPAL_NAME
  144. #define DS_ENTERPRISE_SIMPLE_NAME DS_USER_PRINCIPAL_NAME
  145. typedef enum
  146. {
  147. DS_NAME_NO_FLAGS = 0x0,
  148. // Perform a syntactical mapping at the client (if possible) without
  149. // going out on the wire. Returns DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING
  150. // if a purely syntactical mapping is not possible.
  151. DS_NAME_FLAG_SYNTACTICAL_ONLY = 0x1,
  152. // Force a trip to the DC for evaluation, even if this could be
  153. // locally cracked syntactically.
  154. DS_NAME_FLAG_EVAL_AT_DC = 0x2,
  155. // The call fails if the DC is not a GC
  156. DS_NAME_FLAG_GCVERIFY = 0x4,
  157. // Enable cross forest trust referral
  158. DS_NAME_FLAG_TRUST_REFERRAL = 0x8
  159. } DS_NAME_FLAGS;
  160. typedef enum
  161. {
  162. DS_NAME_NO_ERROR = 0,
  163. // Generic processing error.
  164. DS_NAME_ERROR_RESOLVING = 1,
  165. // Couldn't find the name at all - or perhaps caller doesn't have
  166. // rights to see it.
  167. DS_NAME_ERROR_NOT_FOUND = 2,
  168. // Input name mapped to more than one output name.
  169. DS_NAME_ERROR_NOT_UNIQUE = 3,
  170. // Input name found, but not the associated output format.
  171. // Can happen if object doesn't have all the required attributes.
  172. DS_NAME_ERROR_NO_MAPPING = 4,
  173. // Unable to resolve entire name, but was able to determine which
  174. // domain object resides in. Thus DS_NAME_RESULT_ITEM?.pDomain
  175. // is valid on return.
  176. DS_NAME_ERROR_DOMAIN_ONLY = 5,
  177. // Unable to perform a purely syntactical mapping at the client
  178. // without going out on the wire.
  179. DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING = 6,
  180. // The name is from an external trusted forest.
  181. DS_NAME_ERROR_TRUST_REFERRAL = 7
  182. } DS_NAME_ERROR;
  183. #define DS_NAME_LEGAL_FLAGS (DS_NAME_FLAG_SYNTACTICAL_ONLY)
  184. typedef enum {
  185. // "paulle-nec.ntwksta.ms.com"
  186. DS_SPN_DNS_HOST = 0,
  187. // "cn=paulle-nec,ou=computers,dc=ntwksta,dc=ms,dc=com"
  188. DS_SPN_DN_HOST = 1,
  189. // "paulle-nec"
  190. DS_SPN_NB_HOST = 2,
  191. // "ntdev.ms.com"
  192. DS_SPN_DOMAIN = 3,
  193. // "ntdev"
  194. DS_SPN_NB_DOMAIN = 4,
  195. // "cn=anRpcService,cn=RPC Services,cn=system,dc=ms,dc=com"
  196. // "cn=aWsService,cn=Winsock Services,cn=system,dc=ms,dc=com"
  197. // "cn=aService,dc=itg,dc=ms,dc=com"
  198. // "www.ms.com", "ftp.ms.com", "ldap.ms.com"
  199. // "products.ms.com"
  200. DS_SPN_SERVICE = 5
  201. } DS_SPN_NAME_TYPE;
  202. typedef enum { // example:
  203. DS_SPN_ADD_SPN_OP = 0, // add SPNs
  204. DS_SPN_REPLACE_SPN_OP = 1, // set all SPNs
  205. DS_SPN_DELETE_SPN_OP = 2 // Delete SPNs
  206. } DS_SPN_WRITE_OP;
  207. typedef struct
  208. {
  209. DWORD status; // DS_NAME_ERROR
  210. #ifdef MIDL_PASS
  211. [string,unique] CHAR *pDomain; // DNS domain
  212. [string,unique] CHAR *pName; // name in requested format
  213. #else
  214. LPSTR pDomain; // DNS domain
  215. LPSTR pName; // name in requested format
  216. #endif
  217. } DS_NAME_RESULT_ITEMA, *PDS_NAME_RESULT_ITEMA;
  218. typedef struct
  219. {
  220. DWORD cItems; // item count
  221. #ifdef MIDL_PASS
  222. [size_is(cItems)] PDS_NAME_RESULT_ITEMA rItems;
  223. #else
  224. PDS_NAME_RESULT_ITEMA rItems; // item array
  225. #endif
  226. } DS_NAME_RESULTA, *PDS_NAME_RESULTA;
  227. typedef struct
  228. {
  229. DWORD status; // DS_NAME_ERROR
  230. #ifdef MIDL_PASS
  231. [string,unique] WCHAR *pDomain; // DNS domain
  232. [string,unique] WCHAR *pName; // name in requested format
  233. #else
  234. LPWSTR pDomain; // DNS domain
  235. LPWSTR pName; // name in requested format
  236. #endif
  237. } DS_NAME_RESULT_ITEMW, *PDS_NAME_RESULT_ITEMW;
  238. typedef struct
  239. {
  240. DWORD cItems; // item count
  241. #ifdef MIDL_PASS
  242. [size_is(cItems)] PDS_NAME_RESULT_ITEMW rItems;
  243. #else
  244. PDS_NAME_RESULT_ITEMW rItems; // item array
  245. #endif
  246. } DS_NAME_RESULTW, *PDS_NAME_RESULTW;
  247. #ifdef UNICODE
  248. #define DS_NAME_RESULT DS_NAME_RESULTW
  249. #define PDS_NAME_RESULT PDS_NAME_RESULTW
  250. #define DS_NAME_RESULT_ITEM DS_NAME_RESULT_ITEMW
  251. #define PDS_NAME_RESULT_ITEM PDS_NAME_RESULT_ITEMW
  252. #else
  253. #define DS_NAME_RESULT DS_NAME_RESULTA
  254. #define PDS_NAME_RESULT PDS_NAME_RESULTA
  255. #define DS_NAME_RESULT_ITEM DS_NAME_RESULT_ITEMA
  256. #define PDS_NAME_RESULT_ITEM PDS_NAME_RESULT_ITEMA
  257. #endif
  258. // Public replication option flags
  259. // ********************
  260. // DsBindWithSpnEx flags
  261. // ********************
  262. // Allow the Bind to use delegate service level, so that you can
  263. // do ntdsapi operations that require delegation, such as
  264. // DsAddSidHistory, and DsReplicaSyncAll(). Most operations do
  265. // not require DELEGATE so this flag should only be specified
  266. // if you need it, because if you bind to a rogue server with
  267. // the DELEGATE flag, you'll allow the rogue server to use your
  268. // credentials to connect back to a non-rogue server and perform
  269. // operations other than you intended.
  270. #define NTDSAPI_BIND_ALLOW_DELEGATION (0x00000001)
  271. // ********************
  272. // Replica Sync flags
  273. // These flag values are used both as input to DsReplicaSync and
  274. // as output from DsReplicaGetInfo, PENDING_OPS, DS_REPL_OPW.ulOptions
  275. // ********************
  276. // Perform this operation asynchronously.
  277. // Required when using DS_REPSYNC_ALL_SOURCES
  278. #define DS_REPSYNC_ASYNCHRONOUS_OPERATION 0x00000001
  279. // Writeable replica. Otherwise, read-only.
  280. #define DS_REPSYNC_WRITEABLE 0x00000002
  281. // This is a periodic sync request as scheduled by the admin.
  282. #define DS_REPSYNC_PERIODIC 0x00000004
  283. // Use inter-site messaging
  284. #define DS_REPSYNC_INTERSITE_MESSAGING 0x00000008
  285. // Sync from all sources.
  286. #define DS_REPSYNC_ALL_SOURCES 0x00000010
  287. // Sync starting from scratch (i.e., at the first USN).
  288. #define DS_REPSYNC_FULL 0x00000020
  289. // This is a notification of an update that was marked urgent.
  290. #define DS_REPSYNC_URGENT 0x00000040
  291. // Don't discard this synchronization request, even if a similar
  292. // sync is pending.
  293. #define DS_REPSYNC_NO_DISCARD 0x00000080
  294. // Sync even if link is currently disabled.
  295. #define DS_REPSYNC_FORCE 0x00000100
  296. // Causes the source DSA to check if a reps-to is present for the local DSA
  297. // (aka the destination). If not, one is added. This ensures that
  298. // source sends change notifications.
  299. #define DS_REPSYNC_ADD_REFERENCE 0x00000200
  300. // A sync from this source has never completed (e.g., a new source).
  301. #define DS_REPSYNC_NEVER_COMPLETED 0x00000400
  302. // When this sync is complete, requests a sync in the opposite direction.
  303. #define DS_REPSYNC_TWO_WAY 0x00000800
  304. // Do not request change notifications from this source.
  305. #define DS_REPSYNC_NEVER_NOTIFY 0x00001000
  306. // Sync the NC from this source when the DSA is started.
  307. #define DS_REPSYNC_INITIAL 0x00002000
  308. // Use compression when replicating. Saves message size (e.g., network
  309. // bandwidth) at the expense of extra CPU overhead at both the source and
  310. // destination servers.
  311. #define DS_REPSYNC_USE_COMPRESSION 0x00004000
  312. // Sync was abandoned for lack of updates
  313. #define DS_REPSYNC_ABANDONED 0x00008000
  314. // Initial sync in progress
  315. #define DS_REPSYNC_INITIAL_IN_PROGRESS 0x00010000
  316. // Partial Attribute Set sync in progress
  317. #define DS_REPSYNC_PARTIAL_ATTRIBUTE_SET 0x00020000
  318. // Sync is being retried
  319. #define DS_REPSYNC_REQUEUE 0x00040000
  320. // Sync is a notification request from a source
  321. #define DS_REPSYNC_NOTIFICATION 0x00080000
  322. // Sync is a special form which requests to establish contact
  323. // now and do the rest of the sync later
  324. #define DS_REPSYNC_ASYNCHRONOUS_REPLICA 0x00100000
  325. // Request critical objects only
  326. #define DS_REPSYNC_CRITICAL 0x00200000
  327. // A full synchronization is in progress
  328. #define DS_REPSYNC_FULL_IN_PROGRESS 0x00400000
  329. // Synchronization request was previously preempted
  330. #define DS_REPSYNC_PREEMPTED 0x00800000
  331. // ********************
  332. // Replica Add flags
  333. // ********************
  334. // Perform this operation asynchronously.
  335. #define DS_REPADD_ASYNCHRONOUS_OPERATION 0x00000001
  336. // Create a writeable replica. Otherwise, read-only.
  337. #define DS_REPADD_WRITEABLE 0x00000002
  338. // Sync the NC from this source when the DSA is started.
  339. #define DS_REPADD_INITIAL 0x00000004
  340. // Sync the NC from this source periodically, as defined by the
  341. // schedule passed in the preptimesSync argument.
  342. #define DS_REPADD_PERIODIC 0x00000008
  343. // Sync from the source DSA via an Intersite Messaging Service (ISM) transport
  344. // (e.g., SMTP) rather than native DS RPC.
  345. #define DS_REPADD_INTERSITE_MESSAGING 0x00000010
  346. // Don't replicate the NC now -- just save enough state such that we
  347. // know to replicate it later.
  348. #define DS_REPADD_ASYNCHRONOUS_REPLICA 0x00000020
  349. // Disable notification-based synchronization for the NC from this source.
  350. // This is expected to be a temporary state; the similar flag
  351. // DS_REPADD_NEVER_NOTIFY should be used if the disable is to be more permanent.
  352. #define DS_REPADD_DISABLE_NOTIFICATION 0x00000040
  353. // Disable periodic synchronization for the NC from this source
  354. #define DS_REPADD_DISABLE_PERIODIC 0x00000080
  355. // Use compression when replicating. Saves message size (e.g., network
  356. // bandwidth) at the expense of extra CPU overhead at both the source and
  357. // destination servers.
  358. #define DS_REPADD_USE_COMPRESSION 0x00000100
  359. // Do not request change notifications from this source. When this flag is
  360. // set, the source will not notify the destination when changes occur.
  361. // Recommended for all intersite replication, which may occur over WAN links.
  362. // This is expected to be a more or less permanent state; the similar flag
  363. // DS_REPADD_DISABLE_NOTIFICATION should be used if notifications are to be
  364. // disabled only temporarily.
  365. #define DS_REPADD_NEVER_NOTIFY 0x00000200
  366. // When this sync is complete, requests a sync in the opposite direction.
  367. #define DS_REPADD_TWO_WAY 0x00000400
  368. // Request critical objects only
  369. // Critical only is only allowed while installing
  370. // A critical only sync does not bring all objects in the partition. It
  371. // replicates just the ones necessary for minimal directory operation.
  372. // A normal, non-critical sync must be performed before the partition
  373. // can be considered fully synchronized.
  374. #define DS_REPADD_CRITICAL 0x00000800
  375. // ********************
  376. // Replica Delete flags
  377. // ********************
  378. // Perform this operation asynchronously.
  379. #define DS_REPDEL_ASYNCHRONOUS_OPERATION 0x00000001
  380. // The replica being deleted is writeable.
  381. #define DS_REPDEL_WRITEABLE 0x00000002
  382. // Replica is a mail-based replica
  383. #define DS_REPDEL_INTERSITE_MESSAGING 0x00000004
  384. // Ignore any error generated by contacting the source to tell it to scratch
  385. // this server from its Reps-To for this NC.
  386. #define DS_REPDEL_IGNORE_ERRORS 0x00000008
  387. // Do not contact the source telling it to scratch this server from its
  388. // Rep-To for this NC. Otherwise, if the link is RPC-based, the source will
  389. // be contacted.
  390. #define DS_REPDEL_LOCAL_ONLY 0x00000010
  391. // Delete all the objects in the NC
  392. // "No source" is incompatible with (and rejected for) writeable NCs. This is
  393. // valid only for read-only NCs, and then only if the NC has no source. This
  394. // can occur when the NC has been partially deleted (in which case the KCC
  395. // periodically calls the delete API with the "no source" flag set).
  396. #define DS_REPDEL_NO_SOURCE 0x00000020
  397. // Allow deletion of read-only replica even if it sources
  398. // other read-only replicas.
  399. #define DS_REPDEL_REF_OK 0x00000040
  400. // ********************
  401. // Replica Modify flags
  402. // ********************
  403. // Perform this operation asynchronously.
  404. #define DS_REPMOD_ASYNCHRONOUS_OPERATION 0x00000001
  405. // The replica is writeable.
  406. #define DS_REPMOD_WRITEABLE 0x00000002
  407. // ********************
  408. // Replica Modify fields
  409. // ********************
  410. #define DS_REPMOD_UPDATE_FLAGS 0x00000001
  411. #define DS_REPMOD_UPDATE_ADDRESS 0x00000002
  412. #define DS_REPMOD_UPDATE_SCHEDULE 0x00000004
  413. #define DS_REPMOD_UPDATE_RESULT 0x00000008
  414. #define DS_REPMOD_UPDATE_TRANSPORT 0x00000010
  415. // ********************
  416. // Update Refs fields
  417. // ********************
  418. // Perform this operation asynchronously.
  419. #define DS_REPUPD_ASYNCHRONOUS_OPERATION 0x00000001
  420. // The replica being deleted is writeable.
  421. #define DS_REPUPD_WRITEABLE 0x00000002
  422. // Add a reference
  423. #define DS_REPUPD_ADD_REFERENCE 0x00000004
  424. // Remove a reference
  425. #define DS_REPUPD_DELETE_REFERENCE 0x00000008
  426. // ********************
  427. // NC Related Flags
  428. // ********************
  429. //
  430. // Instance Type bits, specifies flags for NC head creation.
  431. //
  432. #define DS_INSTANCETYPE_IS_NC_HEAD 0x00000001 // This if what to specify on an object to indicate it's an NC Head.
  433. #define DS_INSTANCETYPE_NC_IS_WRITEABLE 0x00000004 // This is to indicate that the NC Head is writeable.
  434. #define DS_INSTANCETYPE_NC_COMING 0x00000010 // This is to indicate that this NC is still replicating in objects to this DC, and may not be a complete NC.
  435. #define DS_INSTANCETYPE_NC_GOING 0x00000020 // This is to indicate that this NC is in the process of being removed from this DC, and may not be a complete NC.
  436. // ********************
  437. // xxx_OPT_xxx Flags
  438. // ********************
  439. // These macros define bit flags which can be set in the "options" attribute
  440. // of objects of the specified object class.
  441. // Bit flags valid for options attribute on NTDS-DSA objects.
  442. //
  443. #define NTDSDSA_OPT_IS_GC ( 1 << 0 ) /* DSA is a global catalog */
  444. #define NTDSDSA_OPT_DISABLE_INBOUND_REPL ( 1 << 1 ) /* disable inbound replication */
  445. #define NTDSDSA_OPT_DISABLE_OUTBOUND_REPL ( 1 << 2 ) /* disable outbound replication */
  446. #define NTDSDSA_OPT_DISABLE_NTDSCONN_XLATE ( 1 << 3 ) /* disable logical conn xlation */
  447. // Bit flags for options attribute on NTDS-Connection objects.
  448. //
  449. // The reasons that two bits are required to control notification are as follows.
  450. // We must support existing connections with the old behavior and the UI does not
  451. // create manual connections with the new bit set.
  452. // The default for existing and manually created connections with bits 2 and 3
  453. // clear must be the standard prior behavior: notification for intra-site and
  454. // no notification for inter-site.
  455. // We need a way to distinguish a old connection which desires the default
  456. // notification rules, and a new connection for which we desire to explicitly
  457. // control the notification state as passed down from a site link. Thus we
  458. // have a new bit to say we are overriding the default, and a new bit to indicate
  459. // what the overridden default shall be.
  460. //
  461. #define NTDSCONN_OPT_IS_GENERATED ( 1 << 0 ) /* object generated by DS, not admin */
  462. #define NTDSCONN_OPT_TWOWAY_SYNC ( 1 << 1 ) /* force sync in opposite direction at end of sync */
  463. #define NTDSCONN_OPT_OVERRIDE_NOTIFY_DEFAULT (1 << 2 ) // Do not use defaults to determine notification
  464. #define NTDSCONN_OPT_USE_NOTIFY (1 << 3) // Does source notify destination
  465. // For intra-site connections, this bit has no meaning.
  466. // For inter-site connections, this bit means:
  467. // 0 - Compression of replication data enabled
  468. // 1 - Compression of replication data disabled
  469. #define NTDSCONN_OPT_DISABLE_INTERSITE_COMPRESSION (1 << 4)
  470. // For connections whose IS_GENERATED bit is 0, this bit has no effect.
  471. // For KCC-generated connections, this bit indicates that the schedule attribute
  472. // is owned by the user and should not be touched by the KCC.
  473. #define NTDSCONN_OPT_USER_OWNED_SCHEDULE (1 << 5)
  474. // Connection reasons
  475. //
  476. // Values for "reason for connection". A connection can be needed for
  477. // more than one reason.
  478. //
  479. #define NTDSCONN_KCC_NO_REASON ( 0 ) // 000
  480. #define NTDSCONN_KCC_GC_TOPOLOGY ( 1 << 0 ) // 001
  481. #define NTDSCONN_KCC_RING_TOPOLOGY ( 1 << 1 ) // 002
  482. #define NTDSCONN_KCC_MINIMIZE_HOPS_TOPOLOGY ( 1 << 2 ) // 004
  483. #define NTDSCONN_KCC_STALE_SERVERS_TOPOLOGY ( 1 << 3 ) // 008
  484. #define NTDSCONN_KCC_OSCILLATING_CONNECTION_TOPOLOGY ( 1 << 4 ) // 010
  485. #define NTDSCONN_KCC_INTERSITE_GC_TOPOLOGY (1 << 5) // 020
  486. #define NTDSCONN_KCC_INTERSITE_TOPOLOGY (1 << 6) // 040
  487. #define NTDSCONN_KCC_SERVER_FAILOVER_TOPOLOGY (1 << 7) // 080
  488. #define NTDSCONN_KCC_SITE_FAILOVER_TOPOLOGY (1 << 8) // 100
  489. #define NTDSCONN_KCC_REDUNDANT_SERVER_TOPOLOGY (1 << 9) // 200
  490. //
  491. // The high 4 bits of the options attribute are used by NTFRS to assign priority
  492. // for inbound connections. Bit 31 is used to force FRS to ignore schedule during
  493. // the initial sync. Bits 30 - 28 are used to specify a priority between 0-7.
  494. //
  495. #define FRSCONN_PRIORITY_MASK 0x70000000
  496. #define FRSCONN_MAX_PRIORITY 0x8
  497. #define NTDSCONN_OPT_IGNORE_SCHEDULE_MASK 0x80000000
  498. #define NTDSCONN_IGNORE_SCHEDULE(_options_)\
  499. (((_options_) & NTDSCONN_OPT_IGNORE_SCHEDULE_MASK) >> 31)
  500. #define FRSCONN_GET_PRIORITY(_options_) \
  501. (((((_options_) & FRSCONN_PRIORITY_MASK) >> 28) != 0 ) ? \
  502. (((_options_) & FRSCONN_PRIORITY_MASK) >> 28) : \
  503. FRSCONN_MAX_PRIORITY \
  504. )
  505. // Bit flags for options attribute on NTDS-Site-Settings objects.
  506. //
  507. #define NTDSSETTINGS_OPT_IS_AUTO_TOPOLOGY_DISABLED ( 1 << 0 ) /* automatic topology gen disabled */
  508. #define NTDSSETTINGS_OPT_IS_TOPL_CLEANUP_DISABLED ( 1 << 1 ) /* automatic topology cleanup disabled */
  509. #define NTDSSETTINGS_OPT_IS_TOPL_MIN_HOPS_DISABLED ( 1 << 2 ) /* automatic minimum hops topology disabled */
  510. #define NTDSSETTINGS_OPT_IS_TOPL_DETECT_STALE_DISABLED ( 1 << 3 ) /* automatic stale server detection disabled */
  511. #define NTDSSETTINGS_OPT_IS_INTER_SITE_AUTO_TOPOLOGY_DISABLED ( 1 << 4 ) /* automatic inter-site topology gen disabled */
  512. #define NTDSSETTINGS_OPT_IS_GROUP_CACHING_ENABLED ( 1 << 5 ) /* group memberships for users enabled */
  513. #define NTDSSETTINGS_OPT_FORCE_KCC_WHISTLER_BEHAVIOR ( 1 << 6 ) /* force KCC to operate in Whistler behavior mode */
  514. #define NTDSSETTINGS_OPT_FORCE_KCC_W2K_ELECTION ( 1 << 7 ) /* force KCC to use the Windows 2000 ISTG election algorithm */
  515. #define NTDSSETTINGS_OPT_IS_RAND_BH_SELECTION_DISABLED ( 1 << 8 ) /* prevent the KCC from randomly picking a bridgehead when creating a connection */
  516. #define NTDSSETTINGS_OPT_IS_SCHEDULE_HASHING_ENABLED ( 1 << 9 ) /* allow the KCC to use hashing when creating a replication schedule */
  517. #define NTDSSETTINGS_OPT_IS_REDUNDANT_SERVER_TOPOLOGY_ENABLED ( 1 << 10 ) /* create static failover connections */
  518. // How many redundant connections will be generated
  519. #define NTDSSETTINGS_DEFAULT_SERVER_REDUNDANCY 2
  520. // Bit flags for options attribute on Inter-Site-Transport objects
  521. //
  522. // Note, the sense of the flag should be such that the default state or
  523. // behavior corresponds to the flag NOT being present. Put another way, the
  524. // flag should state the OPPOSITE of the default
  525. //
  526. // default: schedules are significant
  527. #define NTDSTRANSPORT_OPT_IGNORE_SCHEDULES ( 1 << 0 ) // Schedules disabled
  528. // default: links transitive (bridges not required)
  529. #define NTDSTRANSPORT_OPT_BRIDGES_REQUIRED (1 << 1 ) // siteLink bridges are required
  530. // Bit flags for options attribute on site-Connection objects
  531. //
  532. // These are not realized in the DS, but are built up in the KCC
  533. #define NTDSSITECONN_OPT_USE_NOTIFY ( 1 << 0 ) // Use notification on this link
  534. #define NTDSSITECONN_OPT_TWOWAY_SYNC ( 1 << 1 ) /* force sync in opposite direction at end of sync */
  535. // This bit means:
  536. // 0 - Compression of replication data across this site connection enabled
  537. // 1 - Compression of replication data across this site connection disabled
  538. #define NTDSSITECONN_OPT_DISABLE_COMPRESSION ( 1 << 2 )
  539. // Bit flags for options attribute on site-Link objects
  540. // Note that these options are AND-ed along a site-link path
  541. //
  542. #define NTDSSITELINK_OPT_USE_NOTIFY ( 1 << 0 ) // Use notification on this link
  543. #define NTDSSITELINK_OPT_TWOWAY_SYNC ( 1 << 1 ) /* force sync in opposite direction at end of sync */
  544. // This bit means:
  545. // 0 - Compression of replication data across this site link enabled
  546. // 1 - Compression of replication data across this site link disabled
  547. #define NTDSSITELINK_OPT_DISABLE_COMPRESSION ( 1 << 2 )
  548. // ***********************
  549. // Well Known Object Guids
  550. // ***********************
  551. #define GUID_USERS_CONTAINER_A "a9d1ca15768811d1aded00c04fd8d5cd"
  552. #define GUID_COMPUTRS_CONTAINER_A "aa312825768811d1aded00c04fd8d5cd"
  553. #define GUID_SYSTEMS_CONTAINER_A "ab1d30f3768811d1aded00c04fd8d5cd"
  554. #define GUID_DOMAIN_CONTROLLERS_CONTAINER_A "a361b2ffffd211d1aa4b00c04fd7d83a"
  555. #define GUID_INFRASTRUCTURE_CONTAINER_A "2fbac1870ade11d297c400c04fd8d5cd"
  556. #define GUID_DELETED_OBJECTS_CONTAINER_A "18e2ea80684f11d2b9aa00c04f79f805"
  557. #define GUID_LOSTANDFOUND_CONTAINER_A "ab8153b7768811d1aded00c04fd8d5cd"
  558. #define GUID_FOREIGNSECURITYPRINCIPALS_CONTAINER_A "22b70c67d56e4efb91e9300fca3dc1aa"
  559. #define GUID_PROGRAM_DATA_CONTAINER_A "09460c08ae1e4a4ea0f64aee7daa1e5a"
  560. #define GUID_MICROSOFT_PROGRAM_DATA_CONTAINER_A "f4be92a4c777485e878e9421d53087db"
  561. #define GUID_NTDS_QUOTAS_CONTAINER_A "6227f0af1fc2410d8e3bb10615bb5b0f"
  562. #define GUID_USERS_CONTAINER_W L"a9d1ca15768811d1aded00c04fd8d5cd"
  563. #define GUID_COMPUTRS_CONTAINER_W L"aa312825768811d1aded00c04fd8d5cd"
  564. #define GUID_SYSTEMS_CONTAINER_W L"ab1d30f3768811d1aded00c04fd8d5cd"
  565. #define GUID_DOMAIN_CONTROLLERS_CONTAINER_W L"a361b2ffffd211d1aa4b00c04fd7d83a"
  566. #define GUID_INFRASTRUCTURE_CONTAINER_W L"2fbac1870ade11d297c400c04fd8d5cd"
  567. #define GUID_DELETED_OBJECTS_CONTAINER_W L"18e2ea80684f11d2b9aa00c04f79f805"
  568. #define GUID_LOSTANDFOUND_CONTAINER_W L"ab8153b7768811d1aded00c04fd8d5cd"
  569. #define GUID_FOREIGNSECURITYPRINCIPALS_CONTAINER_W L"22b70c67d56e4efb91e9300fca3dc1aa"
  570. #define GUID_PROGRAM_DATA_CONTAINER_W L"09460c08ae1e4a4ea0f64aee7daa1e5a"
  571. #define GUID_MICROSOFT_PROGRAM_DATA_CONTAINER_W L"f4be92a4c777485e878e9421d53087db"
  572. #define GUID_NTDS_QUOTAS_CONTAINER_W L"6227f0af1fc2410d8e3bb10615bb5b0f"
  573. #define GUID_USERS_CONTAINER_BYTE "\xa9\xd1\xca\x15\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd"
  574. #define GUID_COMPUTRS_CONTAINER_BYTE "\xaa\x31\x28\x25\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd"
  575. #define GUID_SYSTEMS_CONTAINER_BYTE "\xab\x1d\x30\xf3\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd"
  576. #define GUID_DOMAIN_CONTROLLERS_CONTAINER_BYTE "\xa3\x61\xb2\xff\xff\xd2\x11\xd1\xaa\x4b\x00\xc0\x4f\xd7\xd8\x3a"
  577. #define GUID_INFRASTRUCTURE_CONTAINER_BYTE "\x2f\xba\xc1\x87\x0a\xde\x11\xd2\x97\xc4\x00\xc0\x4f\xd8\xd5\xcd"
  578. #define GUID_DELETED_OBJECTS_CONTAINER_BYTE "\x18\xe2\xea\x80\x68\x4f\x11\xd2\xb9\xaa\x00\xc0\x4f\x79\xf8\x05"
  579. #define GUID_LOSTANDFOUND_CONTAINER_BYTE "\xab\x81\x53\xb7\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd"
  580. #define GUID_FOREIGNSECURITYPRINCIPALS_CONTAINER_BYTE "\x22\xb7\x0c\x67\xd5\x6e\x4e\xfb\x91\xe9\x30\x0f\xca\x3d\xc1\xaa"
  581. #define GUID_PROGRAM_DATA_CONTAINER_BYTE "\x09\x46\x0c\x08\xae\x1e\x4a\x4e\xa0\xf6\x4a\xee\x7d\xaa\x1e\x5a"
  582. #define GUID_MICROSOFT_PROGRAM_DATA_CONTAINER_BYTE "\xf4\xbe\x92\xa4\xc7\x77\x48\x5e\x87\x8e\x94\x21\xd5\x30\x87\xdb"
  583. #define GUID_NTDS_QUOTAS_CONTAINER_BYTE "\x62\x27\xf0\xaf\x1f\xc2\x41\x0d\x8e\x3b\xb1\x06\x15\xbb\x5b\x0f"
  584. typedef enum _DS_MANGLE_FOR {
  585. DS_MANGLE_UNKNOWN = 0,
  586. DS_MANGLE_OBJECT_RDN_FOR_DELETION,
  587. DS_MANGLE_OBJECT_RDN_FOR_NAME_CONFLICT,
  588. } DS_MANGLE_FOR;
  589. //////////////////////////////////////////////////////////////////////////
  590. // //
  591. // Prototypes //
  592. // //
  593. //////////////////////////////////////////////////////////////////////////
  594. // DSBind takes two optional input parameters which identify whether the
  595. // caller found a domain controller themselves via DsGetDcName or whether
  596. // a domain controller should be found using default parameters.
  597. // Behavior of the possible combinations are outlined below.
  598. //
  599. // DomainControllerName(value), DnsDomainName(NULL)
  600. //
  601. // The value for DomainControllerName is assumed to have been
  602. // obtained via DsGetDcName (i.e. Field with the same name in a
  603. // DOMAIN_CONTROLLER_INFO struct on return from DsGetDcName call.)
  604. // The client is bound to the domain controller at this name.
  605. //
  606. // Mutual authentication will be performed using an SPN of
  607. // LDAP/DomainControllerName provided DomainControllerName
  608. // is not a NETBIOS name or IP address - i.e. it must be a
  609. // DNS host name.
  610. //
  611. // DomainControllerName(value), DnsDomainName(value)
  612. //
  613. // DsBind will connect to the server identified by DomainControllerName.
  614. //
  615. // Mutual authentication will be performed using an SPN of
  616. // LDAP/DomainControllerName/DnsDomainName provided neither value
  617. // is a NETBIOS names or IP address - i.e. they must be
  618. // valid DNS names.
  619. //
  620. // DomainControllerName(NULL), DnsDomainName(NULL)
  621. //
  622. // DsBind will attempt to find to a global catalog and fail if one
  623. // can not be found.
  624. //
  625. // Mutual authentication will be performed using an SPN of
  626. // GC/DnsHostName/ForestName where DnsHostName and ForestName
  627. // represent the DomainControllerName and DnsForestName fields
  628. // respectively of the DOMAIN_CONTROLLER_INFO returned by the
  629. // DsGetDcName call used to find a global catalog.
  630. //
  631. // DomainControllerName(NULL), DnsDomainName(value)
  632. //
  633. // DsBind will attempt to find a domain controller for the domain
  634. // identified by DnsDomainName and fail if one can not be found.
  635. //
  636. // Mutual authentication will be performed using an SPN of
  637. // LDAP/DnsHostName/DnsDomainName where DnsDomainName is that
  638. // provided by the caller and DnsHostName is that returned by
  639. // DsGetDcName for the domain specified - provided DnsDomainName
  640. // is a valid DNS domain name - i.e. not a NETBIOS domain name.
  641. NTDSAPI
  642. DWORD
  643. WINAPI
  644. DsBindW(
  645. LPCWSTR DomainControllerName, // in, optional
  646. LPCWSTR DnsDomainName, // in, optional
  647. HANDLE *phDS);
  648. NTDSAPI
  649. DWORD
  650. WINAPI
  651. DsBindA(
  652. LPCSTR DomainControllerName, // in, optional
  653. LPCSTR DnsDomainName, // in, optional
  654. HANDLE *phDS);
  655. #ifdef UNICODE
  656. #define DsBind DsBindW
  657. #else
  658. #define DsBind DsBindA
  659. #endif
  660. NTDSAPI
  661. DWORD
  662. WINAPI
  663. DsBindWithCredW(
  664. LPCWSTR DomainControllerName, // in, optional
  665. LPCWSTR DnsDomainName, // in, optional
  666. RPC_AUTH_IDENTITY_HANDLE AuthIdentity, // in, optional
  667. HANDLE *phDS);
  668. NTDSAPI
  669. DWORD
  670. WINAPI
  671. DsBindWithCredA(
  672. LPCSTR DomainControllerName, // in, optional
  673. LPCSTR DnsDomainName, // in, optional
  674. RPC_AUTH_IDENTITY_HANDLE AuthIdentity, // in, optional
  675. HANDLE *phDS);
  676. #ifdef UNICODE
  677. #define DsBindWithCred DsBindWithCredW
  678. #else
  679. #define DsBindWithCred DsBindWithCredA
  680. #endif
  681. //
  682. // DsBindWithSpn{A|W} allows the caller to specify the service principal
  683. // name (SPN) which will be used for mutual authentication against
  684. // the destination server. Do not provide an SPN if you are expecting
  685. // DsBind to find a server for you as SPNs are machine specific and its
  686. // unlikely the SPN you provide matches the server DsBind finds for you.
  687. // Providing a NULL ServicePrincipalName argument results in behavior
  688. // identical to DsBindWithCred{A|W}.
  689. //
  690. NTDSAPI
  691. DWORD
  692. WINAPI
  693. DsBindWithSpnW(
  694. LPCWSTR DomainControllerName, // in, optional
  695. LPCWSTR DnsDomainName, // in, optional
  696. RPC_AUTH_IDENTITY_HANDLE AuthIdentity, // in, optional
  697. LPCWSTR ServicePrincipalName, // in, optional
  698. HANDLE *phDS);
  699. NTDSAPI
  700. DWORD
  701. WINAPI
  702. DsBindWithSpnA(
  703. LPCSTR DomainControllerName, // in, optional
  704. LPCSTR DnsDomainName, // in, optional
  705. RPC_AUTH_IDENTITY_HANDLE AuthIdentity, // in, optional
  706. LPCSTR ServicePrincipalName, // in, optional
  707. HANDLE *phDS);
  708. #ifdef UNICODE
  709. #define DsBindWithSpn DsBindWithSpnW
  710. #else
  711. #define DsBindWithSpn DsBindWithSpnA
  712. #endif
  713. //
  714. // DsBindWithSpnEx{A|W} allows you all the options of the previous
  715. // DsBindWithSpn(), plus the added benefit of specifying some optional
  716. // Binding flags. Currently if you pass NTDSAPI_BIND_ALLOW_DELEGATION,
  717. // you will get the exact old behaviour. If you can avoid it, you
  718. // should not specify this flag, see flag above for details.
  719. //
  720. NTDSAPI_POSTXP
  721. DWORD
  722. WINAPI
  723. DsBindWithSpnExW(
  724. LPCWSTR DomainControllerName, // in, optional
  725. LPCWSTR DnsDomainName, // in, optional
  726. RPC_AUTH_IDENTITY_HANDLE AuthIdentity, // in, optional
  727. LPCWSTR ServicePrincipalName, // in, optional
  728. DWORD BindFlags, // in, optional
  729. HANDLE *phDS);
  730. NTDSAPI_POSTXP
  731. DWORD
  732. WINAPI
  733. DsBindWithSpnExA(
  734. LPCSTR DomainControllerName, // in, optional
  735. LPCSTR DnsDomainName, // in, optional
  736. RPC_AUTH_IDENTITY_HANDLE AuthIdentity, // in, optional
  737. LPCSTR ServicePrincipalName, // in, optional
  738. DWORD BindFlags, // in, optional
  739. HANDLE *phDS);
  740. #ifdef UNICODE
  741. #define DsBindWithSpnEx DsBindWithSpnExW
  742. #else
  743. #define DsBindWithSpnEx DsBindWithSpnExA
  744. #endif
  745. //
  746. // DsBindToISTG{A|W} allows the caller to bind to the server which
  747. // holds the Inter-Site Topology Generator role in the specified site.
  748. // The site name should be the RDN of a site. If no site is specified,
  749. // the function will try to bind to the ISTG in a nearby site.
  750. //
  751. NTDSAPI_POSTXP
  752. DWORD
  753. WINAPI
  754. DsBindToISTGW(
  755. LPCWSTR SiteName, // in, optional
  756. HANDLE *phDS);
  757. NTDSAPI_POSTXP
  758. DWORD
  759. WINAPI
  760. DsBindToISTGA(
  761. LPCSTR SiteName, // in, optional
  762. HANDLE *phDS);
  763. #ifdef UNICODE
  764. #define DsBindToISTG DsBindToISTGW
  765. #else
  766. #define DsBindToISTG DsBindToISTGA
  767. #endif
  768. //
  769. // DsBindingSetTimeout allows the caller to specify a timeout value
  770. // which will be honored by all RPC calls using the specified binding
  771. // handle. RPC calls which take longer the timeout value are canceled.
  772. //
  773. NTDSAPI_POSTXP
  774. DWORD
  775. WINAPI
  776. DsBindingSetTimeout(
  777. HANDLE hDS, // in
  778. ULONG cTimeoutSecs // in
  779. );
  780. //
  781. // DsUnBind
  782. //
  783. NTDSAPI
  784. DWORD
  785. WINAPI
  786. DsUnBindW(
  787. HANDLE *phDS); // in
  788. NTDSAPI
  789. DWORD
  790. WINAPI
  791. DsUnBindA(
  792. HANDLE *phDS); // in
  793. #ifdef UNICODE
  794. #define DsUnBind DsUnBindW
  795. #else
  796. #define DsUnBind DsUnBindA
  797. #endif
  798. //
  799. // DsMakePasswordCredentials
  800. //
  801. // This function constructs a credential structure which is suitable for input
  802. // to the DsBindWithCredentials function, or the ldap_open function (winldap.h)
  803. // The credential must be freed using DsFreeCredential.
  804. //
  805. // None of the input parameters may be present indicating a null, default
  806. // credential. Otherwise the username must be present. If the domain or
  807. // password are null, they default to empty strings. The domain name may be
  808. // null when the username is fully qualified, for example UPN format.
  809. //
  810. NTDSAPI
  811. DWORD
  812. WINAPI
  813. DsMakePasswordCredentialsW(
  814. LPCWSTR User,
  815. LPCWSTR Domain,
  816. LPCWSTR Password,
  817. RPC_AUTH_IDENTITY_HANDLE *pAuthIdentity
  818. );
  819. NTDSAPI
  820. DWORD
  821. WINAPI
  822. DsMakePasswordCredentialsA(
  823. LPCSTR User,
  824. LPCSTR Domain,
  825. LPCSTR Password,
  826. RPC_AUTH_IDENTITY_HANDLE *pAuthIdentity
  827. );
  828. #ifdef UNICODE
  829. #define DsMakePasswordCredentials DsMakePasswordCredentialsW
  830. #else
  831. #define DsMakePasswordCredentials DsMakePasswordCredentialsA
  832. #endif
  833. NTDSAPI
  834. VOID
  835. WINAPI
  836. DsFreePasswordCredentials(
  837. RPC_AUTH_IDENTITY_HANDLE AuthIdentity
  838. );
  839. #define DsFreePasswordCredentialsW DsFreePasswordCredentials
  840. #define DsFreePasswordCredentialsA DsFreePasswordCredentials
  841. //
  842. // DsCrackNames
  843. //
  844. NTDSAPI
  845. DWORD
  846. WINAPI
  847. DsCrackNamesW(
  848. HANDLE hDS, // in
  849. DS_NAME_FLAGS flags, // in
  850. DS_NAME_FORMAT formatOffered, // in
  851. DS_NAME_FORMAT formatDesired, // in
  852. DWORD cNames, // in
  853. const LPCWSTR *rpNames, // in
  854. PDS_NAME_RESULTW *ppResult); // out
  855. NTDSAPI
  856. DWORD
  857. WINAPI
  858. DsCrackNamesA(
  859. HANDLE hDS, // in
  860. DS_NAME_FLAGS flags, // in
  861. DS_NAME_FORMAT formatOffered, // in
  862. DS_NAME_FORMAT formatDesired, // in
  863. DWORD cNames, // in
  864. const LPCSTR *rpNames, // in
  865. PDS_NAME_RESULTA *ppResult); // out
  866. #ifdef UNICODE
  867. #define DsCrackNames DsCrackNamesW
  868. #else
  869. #define DsCrackNames DsCrackNamesA
  870. #endif
  871. //
  872. // DsFreeNameResult
  873. //
  874. NTDSAPI
  875. void
  876. WINAPI
  877. DsFreeNameResultW(
  878. DS_NAME_RESULTW *pResult); // in
  879. NTDSAPI
  880. void
  881. WINAPI
  882. DsFreeNameResultA(
  883. DS_NAME_RESULTA *pResult); // in
  884. #ifdef UNICODE
  885. #define DsFreeNameResult DsFreeNameResultW
  886. #else
  887. #define DsFreeNameResult DsFreeNameResultA
  888. #endif
  889. // ==========================================================
  890. // DSMakeSpn -- client call to create SPN for a service to which it wants to
  891. // authenticate.
  892. // This name is then passed to "pszTargetName" of InitializeSecurityContext().
  893. //
  894. // Notes:
  895. // If the service name is a DNS host name, or canonical DNS service name
  896. // e.g. "www.ms.com", i.e., caller resolved with gethostbyname, then instance
  897. // name should be NULL.
  898. // Realm is host name minus first component, unless it is in the exception list
  899. //
  900. // If the service name is NetBIOS machine name, then instance name should be
  901. // NULL
  902. // Form must be <domain>\<machine>
  903. // Realm will be <domain>
  904. //
  905. // If the service name is that of a replicated service, where each replica has
  906. // its own account (e.g., with SRV records) then the caller must supply the
  907. // instance name then realm name is same as ServiceName
  908. //
  909. // If the service name is a DN, then must also supply instance name
  910. // (DN could be name of service object (incl RPC or Winsock), name of machine
  911. // account, name of domain object)
  912. // then realm name is domain part of the DN
  913. //
  914. // If the service name is NetBIOS domain name, then must also supply instance
  915. // name; realm name is domain name
  916. //
  917. // If the service is named by an IP address -- then use referring service name
  918. // as service name
  919. //
  920. // ServiceClass - e.g. "http", "ftp", "ldap", GUID
  921. // ServiceName - DNS or DN; assumes we can compute domain from service name
  922. // InstanceName OPTIONAL- DNS name of host for instance of service
  923. // InstancePort - port number for instance (0 if default)
  924. // Referrer OPTIONAL- DNS name of host that gave this referral
  925. // pcSpnLength - in -- max length IN CHARACTERS of principal name;
  926. // out -- actual
  927. // Length includes terminator
  928. // pszSPN - server principal name
  929. //
  930. // If buffer is not large enough, ERROR_BUFFER_OVERFLOW is returned and the
  931. // needed length is returned in pcSpnLength.
  932. //
  933. //
  934. NTDSAPI
  935. DWORD
  936. WINAPI
  937. DsMakeSpnW(
  938. IN LPCWSTR ServiceClass,
  939. IN LPCWSTR ServiceName,
  940. IN LPCWSTR InstanceName,
  941. IN USHORT InstancePort,
  942. IN LPCWSTR Referrer,
  943. IN OUT DWORD *pcSpnLength,
  944. OUT LPWSTR pszSpn
  945. );
  946. NTDSAPI
  947. DWORD
  948. WINAPI
  949. DsMakeSpnA(
  950. IN LPCSTR ServiceClass,
  951. IN LPCSTR ServiceName,
  952. IN LPCSTR InstanceName,
  953. IN USHORT InstancePort,
  954. IN LPCSTR Referrer,
  955. IN OUT DWORD *pcSpnLength,
  956. OUT LPSTR pszSpn
  957. );
  958. #ifdef UNICODE
  959. #define DsMakeSpn DsMakeSpnW
  960. #else
  961. #define DsMakeSpn DsMakeSpnA
  962. #endif
  963. // ==========================================================
  964. // DsGetSPN -- server's call to gets SPNs for a service name by which it is
  965. // known to clients. N.B.: there may be more than one name by which clients
  966. // know it the SPNs are then passed to DsAddAccountSpn to register them in
  967. // the DS
  968. //
  969. // IN SpnNameType eType,
  970. // IN LPCTSTR ServiceClass,
  971. // kind of service -- "http", "ldap", "ftp", etc.
  972. // IN LPCTSTR ServiceName OPTIONAL,
  973. // name of service -- DN or DNS; not needed for host-based
  974. // IN USHORT InstancePort,
  975. // port number (0 => default) for instances
  976. // IN USHORT cInstanceNames,
  977. // count of extra instance names and ports (0=>use gethostbyname)
  978. // IN LPCTSTR InstanceNames[] OPTIONAL,
  979. // extra instance names (not used for host names)
  980. // IN USHORT InstancePorts[] OPTIONAL,
  981. // extra instance ports (0 => default)
  982. // IN OUT PULONG pcSpn, // count of SPNs
  983. // IN OUT LPTSTR * prpszSPN[]
  984. // a bunch of SPNs for this service; free with DsFreeSpnArray
  985. NTDSAPI
  986. DWORD
  987. WINAPI
  988. DsGetSpnA(
  989. IN DS_SPN_NAME_TYPE ServiceType,
  990. IN LPCSTR ServiceClass,
  991. IN LPCSTR ServiceName,
  992. IN USHORT InstancePort,
  993. IN USHORT cInstanceNames,
  994. IN LPCSTR *pInstanceNames,
  995. IN const USHORT *pInstancePorts,
  996. OUT DWORD *pcSpn,
  997. OUT LPSTR **prpszSpn
  998. );
  999. NTDSAPI
  1000. DWORD
  1001. WINAPI
  1002. DsGetSpnW(
  1003. IN DS_SPN_NAME_TYPE ServiceType,
  1004. IN LPCWSTR ServiceClass,
  1005. IN LPCWSTR ServiceName,
  1006. IN USHORT InstancePort,
  1007. IN USHORT cInstanceNames,
  1008. IN LPCWSTR *pInstanceNames,
  1009. IN const USHORT *pInstancePorts,
  1010. OUT DWORD *pcSpn,
  1011. OUT LPWSTR **prpszSpn
  1012. );
  1013. #ifdef UNICODE
  1014. #define DsGetSpn DsGetSpnW
  1015. #else
  1016. #define DsGetSpn DsGetSpnA
  1017. #endif
  1018. // ==========================================================
  1019. // DsFreeSpnArray() -- Free array returned by DsGetSpn{A,W}
  1020. NTDSAPI
  1021. void
  1022. WINAPI
  1023. DsFreeSpnArrayA(
  1024. IN DWORD cSpn,
  1025. IN OUT LPSTR *rpszSpn
  1026. );
  1027. NTDSAPI
  1028. void
  1029. WINAPI
  1030. DsFreeSpnArrayW(
  1031. IN DWORD cSpn,
  1032. IN OUT LPWSTR *rpszSpn
  1033. );
  1034. #ifdef UNICODE
  1035. #define DsFreeSpnArray DsFreeSpnArrayW
  1036. #else
  1037. #define DsFreeSpnArray DsFreeSpnArrayA
  1038. #endif
  1039. // ==========================================================
  1040. // DsCrackSpn() -- parse an SPN into the ServiceClass,
  1041. // ServiceName, and InstanceName (and InstancePort) pieces.
  1042. // An SPN is passed in, along with a pointer to the maximum length
  1043. // for each piece and a pointer to a buffer where each piece should go.
  1044. // On exit, the maximum lengths are updated to the actual length for each piece
  1045. // and the buffer contain the appropriate piece. The InstancePort is 0 if not
  1046. // present.
  1047. //
  1048. // DWORD DsCrackSpn(
  1049. // IN LPTSTR pszSPN, // the SPN to parse
  1050. // IN OUT PUSHORT pcServiceClass, // input -- max length of ServiceClass;
  1051. // output -- actual length
  1052. // OUT LPCTSTR ServiceClass, // the ServiceClass part of the SPN
  1053. // IN OUT PUSHORT pcServiceName, // input -- max length of ServiceName;
  1054. // output -- actual length
  1055. // OUT LPCTSTR ServiceName, // the ServiceName part of the SPN
  1056. // IN OUT PUSHORT pcInstance, // input -- max length of ServiceClass;
  1057. // output -- actual length
  1058. // OUT LPCTSTR InstanceName, // the InstanceName part of the SPN
  1059. // OUT PUSHORT InstancePort // instance port
  1060. //
  1061. // Note: lengths are in characters; all string lengths include terminators
  1062. // All arguments except pszSpn are optional.
  1063. //
  1064. NTDSAPI
  1065. DWORD
  1066. WINAPI
  1067. DsCrackSpnA(
  1068. IN LPCSTR pszSpn,
  1069. IN OUT LPDWORD pcServiceClass,
  1070. OUT LPSTR ServiceClass,
  1071. IN OUT LPDWORD pcServiceName,
  1072. OUT LPSTR ServiceName,
  1073. IN OUT LPDWORD pcInstanceName,
  1074. OUT LPSTR InstanceName,
  1075. OUT USHORT *pInstancePort
  1076. );
  1077. NTDSAPI
  1078. DWORD
  1079. WINAPI
  1080. DsCrackSpnW(
  1081. IN LPCWSTR pszSpn,
  1082. IN OUT DWORD *pcServiceClass,
  1083. OUT LPWSTR ServiceClass,
  1084. IN OUT DWORD *pcServiceName,
  1085. OUT LPWSTR ServiceName,
  1086. IN OUT DWORD *pcInstanceName,
  1087. OUT LPWSTR InstanceName,
  1088. OUT USHORT *pInstancePort
  1089. );
  1090. #ifdef UNICODE
  1091. #define DsCrackSpn DsCrackSpnW
  1092. #else
  1093. #define DsCrackSpn DsCrackSpnA
  1094. #endif
  1095. // ==========================================================
  1096. // DsWriteAccountSpn -- set or add SPNs for an account object
  1097. // Usually done by service itself, or perhaps by an admin.
  1098. //
  1099. // This call is RPC'd to the DC where the account object is stored, so it can
  1100. // securely enforce policy on what SPNs are allowed on the account. Direct LDAP
  1101. // writes to the SPN property are not allowed -- all writes must come through
  1102. // this RPC call. (Reads via // LDAP are OK.)
  1103. //
  1104. // The account object can be a machine accout, or a service (user) account.
  1105. //
  1106. // If called by the service to register itself, it can most easily get
  1107. // the names by calling DsGetSpn with each of the names that
  1108. // clients can use to find the service.
  1109. //
  1110. // IN SpnWriteOp eOp, // set, add
  1111. // IN LPCTSTR pszAccount, // DN of account to which to add SPN
  1112. // IN int cSPN, // count of SPNs to add to account
  1113. // IN LPCTSTR rpszSPN[] // SPNs to add to altSecID property
  1114. NTDSAPI
  1115. DWORD
  1116. WINAPI
  1117. DsWriteAccountSpnA(
  1118. IN HANDLE hDS,
  1119. IN DS_SPN_WRITE_OP Operation,
  1120. IN LPCSTR pszAccount,
  1121. IN DWORD cSpn,
  1122. IN LPCSTR *rpszSpn
  1123. );
  1124. NTDSAPI
  1125. DWORD
  1126. WINAPI
  1127. DsWriteAccountSpnW(
  1128. IN HANDLE hDS,
  1129. IN DS_SPN_WRITE_OP Operation,
  1130. IN LPCWSTR pszAccount,
  1131. IN DWORD cSpn,
  1132. IN LPCWSTR *rpszSpn
  1133. );
  1134. #ifdef UNICODE
  1135. #define DsWriteAccountSpn DsWriteAccountSpnW
  1136. #else
  1137. #define DsWriteAccountSpn DsWriteAccountSpnA
  1138. #endif
  1139. /*++
  1140. Routine Description:
  1141. Constructs a Service Principal Name suitable to identify the desired server.
  1142. The service class and part of a dns hostname must be supplied.
  1143. This routine is a simplified wrapper to DsMakeSpn.
  1144. The ServiceName is made canonical by resolving through DNS.
  1145. Guid-based dns names are not supported.
  1146. NOTE:
  1147. This routine is no longer recommended for use. In order to be secure, an SPN
  1148. should be constructed purely on the client without reliance on other services,
  1149. such as DNS, which may be spoofed.
  1150. The simplified SPN constructed looks like this:
  1151. ServiceClass / ServiceName / ServiceName
  1152. The instance name portion (2nd position) is always defaulted. The port and
  1153. referrer fields are not used.
  1154. Arguments:
  1155. ServiceClass - Class of service, defined by the service, can be any
  1156. string unique to the service
  1157. ServiceName - dns hostname, fully qualified or not
  1158. Stringized IP address is also resolved if necessary
  1159. pcSpnLength - IN, maximum length of buffer, in chars
  1160. OUT, space utilized, in chars, including terminator
  1161. pszSpn - Buffer, atleast of length *pcSpnLength
  1162. Return Value:
  1163. WINAPI - Win32 error code
  1164. --*/
  1165. NTDSAPI
  1166. DWORD
  1167. WINAPI
  1168. DsClientMakeSpnForTargetServerW(
  1169. IN LPCWSTR ServiceClass,
  1170. IN LPCWSTR ServiceName,
  1171. IN OUT DWORD *pcSpnLength,
  1172. OUT LPWSTR pszSpn
  1173. );
  1174. NTDSAPI
  1175. DWORD
  1176. WINAPI
  1177. DsClientMakeSpnForTargetServerA(
  1178. IN LPCSTR ServiceClass,
  1179. IN LPCSTR ServiceName,
  1180. IN OUT DWORD *pcSpnLength,
  1181. OUT LPSTR pszSpn
  1182. );
  1183. #ifdef UNICODE
  1184. #define DsClientMakeSpnForTargetServer DsClientMakeSpnForTargetServerW
  1185. #else
  1186. #define DsClientMakeSpnForTargetServer DsClientMakeSpnForTargetServerA
  1187. #endif
  1188. /*++
  1189. Routine Description:
  1190. Register Service Principal Names for a server application.
  1191. This routine does the following:
  1192. 1. Enumerates a list of server SPNs using DsGetSpn and the provided class
  1193. 2. Determines the domain of the current user context
  1194. 3. Determines the DN of the current user context if not supplied
  1195. 4. Locates a domain controller
  1196. 5. Binds to the domain controller
  1197. 6. Uses DsWriteAccountSpn to write the SPNs on the named object DN
  1198. 7. Unbinds
  1199. Construct server SPNs for this service, and write them to the right object.
  1200. If the userObjectDn is specified, the SPN is written to that object.
  1201. Otherwise the Dn is defaulted, to the user object, then computer.
  1202. Now, bind to the DS, and register the name on the object for the
  1203. user this service is running as. So, if we're running as local
  1204. system, we'll register it on the computer object itself. If we're
  1205. running as a domain user, we'll add the SPN to the user's object.
  1206. Arguments:
  1207. Operation - What should be done with the values: add, replace or delete
  1208. ServiceClass - Unique string identifying service
  1209. UserObjectDN - Optional, dn of object to write SPN to
  1210. Return Value:
  1211. WINAPI - Win32 error code
  1212. --*/
  1213. NTDSAPI
  1214. DWORD
  1215. WINAPI
  1216. DsServerRegisterSpnA(
  1217. IN DS_SPN_WRITE_OP Operation,
  1218. IN LPCSTR ServiceClass,
  1219. IN LPCSTR UserObjectDN
  1220. );
  1221. NTDSAPI
  1222. DWORD
  1223. WINAPI
  1224. DsServerRegisterSpnW(
  1225. IN DS_SPN_WRITE_OP Operation,
  1226. IN LPCWSTR ServiceClass,
  1227. IN LPCWSTR UserObjectDN
  1228. );
  1229. #ifdef UNICODE
  1230. #define DsServerRegisterSpn DsServerRegisterSpnW
  1231. #else
  1232. #define DsServerRegisterSpn DsServerRegisterSpnA
  1233. #endif
  1234. // DsReplicaSync. The server that this call is executing on is called the
  1235. // destination. The destination's naming context will be brought up to date
  1236. // with respect to a source system. The source system is identified by the
  1237. // uuid. The uuid is that of the source system's "NTDS Settings" object.
  1238. // The destination system must already be configured such that the source
  1239. // system is one of the systems from which it recieves replication data
  1240. // ("replication from"). This is usually done automatically by the KCC.
  1241. //
  1242. // PARAMETERS:
  1243. // pNC (DSNAME *)
  1244. // Name of the NC to synchronize.
  1245. // puuidSourceDRA (SZ)
  1246. // objectGuid of DSA with which to synchronize the replica.
  1247. // ulOptions (ULONG)
  1248. // Bitwise OR of zero or more flags
  1249. // RETURNS: WIN32 STATUS
  1250. NTDSAPI
  1251. DWORD
  1252. WINAPI
  1253. DsReplicaSyncA(
  1254. IN HANDLE hDS,
  1255. IN LPCSTR NameContext,
  1256. IN const UUID *pUuidDsaSrc,
  1257. IN ULONG Options
  1258. );
  1259. NTDSAPI
  1260. DWORD
  1261. WINAPI
  1262. DsReplicaSyncW(
  1263. IN HANDLE hDS,
  1264. IN LPCWSTR NameContext,
  1265. IN const UUID *pUuidDsaSrc,
  1266. IN ULONG Options
  1267. );
  1268. #ifdef UNICODE
  1269. #define DsReplicaSync DsReplicaSyncW
  1270. #else
  1271. #define DsReplicaSync DsReplicaSyncA
  1272. #endif
  1273. // DsReplicaAdd
  1274. //
  1275. /*
  1276. Description:
  1277. This call is executed on the destination. It causes the destination to
  1278. add a "replication from" reference to the indicated source system.
  1279. The source server is identified by string name, not uuid as with Sync.
  1280. The DsaSrcAddress parameter is the transport specific address of the source
  1281. DSA, usually its guid-based dns name. The guid in the guid-based dns name is
  1282. the object-guid of that server's ntds-dsa (settings) object.
  1283. Arguments:
  1284. pNC (IN) - NC for which to add the replica.
  1285. pSourceDsaDN (IN) - DN of the source DSA's ntdsDsa object. Required if
  1286. ulOptions includes DS_REPADD_ASYNCHRONOUS_REPLICA; ignored otherwise.
  1287. pTransportDN (IN) - DN of the interSiteTransport object representing the
  1288. transport by which to communicate with the source server. Required if
  1289. ulOptions includes INTERSITE_MESSAGING; ignored otherwise.
  1290. pszSourceDsaAddress (IN) - Transport-specific address of the source DSA.
  1291. pSchedule (IN) - Schedule by which to replicate the NC from this
  1292. source in the future.
  1293. ulOptions (IN) - flags
  1294. RETURNS: WIN32 STATUS
  1295. */
  1296. NTDSAPI
  1297. DWORD
  1298. WINAPI
  1299. DsReplicaAddA(
  1300. IN HANDLE hDS,
  1301. IN LPCSTR NameContext,
  1302. IN LPCSTR SourceDsaDn,
  1303. IN LPCSTR TransportDn,
  1304. IN LPCSTR SourceDsaAddress,
  1305. IN const PSCHEDULE pSchedule,
  1306. IN DWORD Options
  1307. );
  1308. NTDSAPI
  1309. DWORD
  1310. WINAPI
  1311. DsReplicaAddW(
  1312. IN HANDLE hDS,
  1313. IN LPCWSTR NameContext,
  1314. IN LPCWSTR SourceDsaDn,
  1315. IN LPCWSTR TransportDn,
  1316. IN LPCWSTR SourceDsaAddress,
  1317. IN const PSCHEDULE pSchedule,
  1318. IN DWORD Options
  1319. );
  1320. #ifdef UNICODE
  1321. #define DsReplicaAdd DsReplicaAddW
  1322. #else
  1323. #define DsReplicaAdd DsReplicaAddA
  1324. #endif
  1325. // DsReplicaDel
  1326. //
  1327. // The server that this call is executing on is the destination. The call
  1328. // causes the destination to remove a "replication from" reference to the
  1329. // indicated source server.
  1330. // The source server is identified by string name, not uuid as with Sync.
  1331. // The DsaSrc parameter is the transport specific address of the source DSA,
  1332. // usually its guid-based dns name. The guid in the guid-based dns name is
  1333. // the object-guid of that server's ntds-dsa (settings) object.
  1334. // If you remove an NC from a given destination and specify the "no source"
  1335. // flag, then the entire replica will be removed from the DC.
  1336. //
  1337. // PARAMETERS:
  1338. // pNC (DSNAME *)
  1339. // Name of the NC for which to delete a source.
  1340. // pszSourceDRA (SZ)
  1341. // DSA for which to delete the source.
  1342. // ulOptions (ULONG)
  1343. // Bitwise OR of zero or more flags
  1344. //
  1345. //
  1346. // RETURNS: WIN32 STATUS
  1347. NTDSAPI
  1348. DWORD
  1349. WINAPI
  1350. DsReplicaDelA(
  1351. IN HANDLE hDS,
  1352. IN LPCSTR NameContext,
  1353. IN LPCSTR DsaSrc,
  1354. IN ULONG Options
  1355. );
  1356. NTDSAPI
  1357. DWORD
  1358. WINAPI
  1359. DsReplicaDelW(
  1360. IN HANDLE hDS,
  1361. IN LPCWSTR NameContext,
  1362. IN LPCWSTR DsaSrc,
  1363. IN ULONG Options
  1364. );
  1365. #ifdef UNICODE
  1366. #define DsReplicaDel DsReplicaDelW
  1367. #else
  1368. #define DsReplicaDel DsReplicaDelA
  1369. #endif
  1370. // DsReplicaModify
  1371. //
  1372. //
  1373. // Modify a source for a given naming context
  1374. //
  1375. // The value must already exist.
  1376. //
  1377. // Either the UUID or the address may be used to identify the current value.
  1378. // If a UUID is specified, the UUID will be used for comparison. Otherwise,
  1379. // the address will be used for comparison.
  1380. //
  1381. // PARAMETERS:
  1382. // pNC (DSNAME *)
  1383. // Name of the NC for which the Reps-From should be modified.
  1384. // puuidSourceDRA (UUID *)
  1385. // Guid of the DSA object for the source server. May be NULL if:
  1386. // . ulModifyFields does not include DS_REPMOD_UPDATE_ADDRESS and
  1387. // . pmtxSourceDRA is non-NULL.
  1388. // puuidTransportObj (UUID *)
  1389. // objectGuid of the transport by which replication is to be performed
  1390. // Ignored if ulModifyFields does not include
  1391. // DS_REPMOD_UPDATE_TRANSPORT.
  1392. // pszSourceDRA (SZ)
  1393. // DSA for which the reference should be added or deleted. Ignored if
  1394. // puuidSourceDRA is non-NULL and ulModifyFields does not include
  1395. // DS_REPMOD_UPDATE_ADDRESS.
  1396. // prtSchedule (REPLTIMES *)
  1397. // Periodic replication schedule for this replica. Ignored if
  1398. // ulModifyFields does not include DS_REPMOD_UPDATE_SCHEDULE.
  1399. // ulReplicaFlags (ULONG)
  1400. // Flags to set for this replica. Ignored if ulModifyFields does not
  1401. // include DS_REPMOD_UPDATE_FLAGS.
  1402. // ulModifyFields (ULONG)
  1403. // Fields to update. One or more of the following bit flags:
  1404. // UPDATE_ADDRESS
  1405. // Update the MTX_ADDR associated with the referenced server.
  1406. // UPDATE_SCHEDULE
  1407. // Update the periodic replication schedule associated with
  1408. // the replica.
  1409. // UPDATE_FLAGS
  1410. // Update the flags associated with the replica.
  1411. // UPDATE_TRANSPORT
  1412. // Update the transport associated with the replica.
  1413. // ulOptions (ULONG)
  1414. // Bitwise OR of zero or more of the following:
  1415. // DS_REPMOD_ASYNCHRONOUS_OPERATION
  1416. // Perform this operation asynchronously.
  1417. // RETURNS: WIN32 STATUS
  1418. NTDSAPI
  1419. DWORD
  1420. WINAPI
  1421. DsReplicaModifyA(
  1422. IN HANDLE hDS,
  1423. IN LPCSTR NameContext,
  1424. IN const UUID *pUuidSourceDsa,
  1425. IN LPCSTR TransportDn,
  1426. IN LPCSTR SourceDsaAddress,
  1427. IN const PSCHEDULE pSchedule,
  1428. IN DWORD ReplicaFlags,
  1429. IN DWORD ModifyFields,
  1430. IN DWORD Options
  1431. );
  1432. NTDSAPI
  1433. DWORD
  1434. WINAPI
  1435. DsReplicaModifyW(
  1436. IN HANDLE hDS,
  1437. IN LPCWSTR NameContext,
  1438. IN const UUID *pUuidSourceDsa,
  1439. IN LPCWSTR TransportDn,
  1440. IN LPCWSTR SourceDsaAddress,
  1441. IN const PSCHEDULE pSchedule,
  1442. IN DWORD ReplicaFlags,
  1443. IN DWORD ModifyFields,
  1444. IN DWORD Options
  1445. );
  1446. #ifdef UNICODE
  1447. #define DsReplicaModify DsReplicaModifyW
  1448. #else
  1449. #define DsReplicaModify DsReplicaModifyA
  1450. #endif
  1451. // DsReplicaUpdateRefs
  1452. //
  1453. // In this case, the RPC is being executed on the "source" of destination-sourc
  1454. // replication relationship. This function tells the source that it no longer
  1455. // supplies replication information to the indicated destination system.
  1456. // Add or remove a target server from the Reps-To property on the given NC.
  1457. // Add/remove a reference given the DSNAME of the corresponding NTDS-DSA
  1458. // object.
  1459. //
  1460. // PARAMETERS:
  1461. // pNC (DSNAME *)
  1462. // Name of the NC for which the Reps-To should be modified.
  1463. // DsaDest (SZ)
  1464. // Network address of DSA for which the reference should be added
  1465. // or deleted.
  1466. // pUuidDsaDest (UUID *)
  1467. // objectGuid of the DSA object for which the reference should be
  1468. // added or deleted.
  1469. // ulOptions (ULONG)
  1470. // Bitwise OR of zero or more of the following:
  1471. // DS_REPUPD_ASYNC_OP
  1472. // Perform this operation asynchronously.
  1473. // DS_REPUPD_ADD_REFERENCE
  1474. // Add the given server to the Reps-To property.
  1475. // DS_REPUPD_DEL_REFERENCE
  1476. // Remove the given server from the Reps-To property.
  1477. // Note that ADD_REF and DEL_REF may be paired to perform
  1478. // "add or update".
  1479. //
  1480. // RETURNS: WIN32 STATUS
  1481. NTDSAPI
  1482. DWORD
  1483. WINAPI
  1484. DsReplicaUpdateRefsA(
  1485. IN HANDLE hDS,
  1486. IN LPCSTR NameContext,
  1487. IN LPCSTR DsaDest,
  1488. IN const UUID *pUuidDsaDest,
  1489. IN ULONG Options
  1490. );
  1491. NTDSAPI
  1492. DWORD
  1493. WINAPI
  1494. DsReplicaUpdateRefsW(
  1495. IN HANDLE hDS,
  1496. IN LPCWSTR NameContext,
  1497. IN LPCWSTR DsaDest,
  1498. IN const UUID *pUuidDsaDest,
  1499. IN ULONG Options
  1500. );
  1501. #ifdef UNICODE
  1502. #define DsReplicaUpdateRefs DsReplicaUpdateRefsW
  1503. #else
  1504. #define DsReplicaUpdateRefs DsReplicaUpdateRefsA
  1505. #endif
  1506. // Friends of DsReplicaSyncAll
  1507. typedef enum {
  1508. DS_REPSYNCALL_WIN32_ERROR_CONTACTING_SERVER = 0,
  1509. DS_REPSYNCALL_WIN32_ERROR_REPLICATING = 1,
  1510. DS_REPSYNCALL_SERVER_UNREACHABLE = 2
  1511. } DS_REPSYNCALL_ERROR;
  1512. typedef enum {
  1513. DS_REPSYNCALL_EVENT_ERROR = 0,
  1514. DS_REPSYNCALL_EVENT_SYNC_STARTED = 1,
  1515. DS_REPSYNCALL_EVENT_SYNC_COMPLETED = 2,
  1516. DS_REPSYNCALL_EVENT_FINISHED = 3
  1517. } DS_REPSYNCALL_EVENT;
  1518. // Friends of DsReplicaSyncAll
  1519. typedef struct {
  1520. LPSTR pszSrcId;
  1521. LPSTR pszDstId;
  1522. LPSTR pszNC;
  1523. GUID * pguidSrc;
  1524. GUID * pguidDst;
  1525. } DS_REPSYNCALL_SYNCA, * PDS_REPSYNCALL_SYNCA;
  1526. typedef struct {
  1527. LPWSTR pszSrcId;
  1528. LPWSTR pszDstId;
  1529. LPWSTR pszNC;
  1530. GUID * pguidSrc;
  1531. GUID * pguidDst;
  1532. } DS_REPSYNCALL_SYNCW, * PDS_REPSYNCALL_SYNCW;
  1533. typedef struct {
  1534. LPSTR pszSvrId;
  1535. DS_REPSYNCALL_ERROR error;
  1536. DWORD dwWin32Err;
  1537. LPSTR pszSrcId;
  1538. } DS_REPSYNCALL_ERRINFOA, * PDS_REPSYNCALL_ERRINFOA;
  1539. typedef struct {
  1540. LPWSTR pszSvrId;
  1541. DS_REPSYNCALL_ERROR error;
  1542. DWORD dwWin32Err;
  1543. LPWSTR pszSrcId;
  1544. } DS_REPSYNCALL_ERRINFOW, * PDS_REPSYNCALL_ERRINFOW;
  1545. typedef struct {
  1546. DS_REPSYNCALL_EVENT event;
  1547. DS_REPSYNCALL_ERRINFOA * pErrInfo;
  1548. DS_REPSYNCALL_SYNCA * pSync;
  1549. } DS_REPSYNCALL_UPDATEA, * PDS_REPSYNCALL_UPDATEA;
  1550. typedef struct {
  1551. DS_REPSYNCALL_EVENT event;
  1552. DS_REPSYNCALL_ERRINFOW * pErrInfo;
  1553. DS_REPSYNCALL_SYNCW * pSync;
  1554. } DS_REPSYNCALL_UPDATEW, * PDS_REPSYNCALL_UPDATEW;
  1555. #ifdef UNICODE
  1556. #define DS_REPSYNCALL_SYNC DS_REPSYNCALL_SYNCW
  1557. #define DS_REPSYNCALL_ERRINFO DS_REPSYNCALL_ERRINFOW
  1558. #define DS_REPSYNCALL_UPDATE DS_REPSYNCALL_UPDATEW
  1559. #define PDS_REPSYNCALL_SYNC PDS_REPSYNCALL_SYNCW
  1560. #define PDS_REPSYNCALL_ERRINFO PDS_REPSYNCALL_ERRINFOW
  1561. #define PDS_REPSYNCALL_UPDATE PDS_REPSYNCALL_UPDATEW
  1562. #else
  1563. #define DS_REPSYNCALL_SYNC DS_REPSYNCALL_SYNCA
  1564. #define DS_REPSYNCALL_ERRINFO DS_REPSYNCALL_ERRINFOA
  1565. #define DS_REPSYNCALL_UPDATE DS_REPSYNCALL_UPDATEA
  1566. #define PDS_REPSYNCALL_SYNC PDS_REPSYNCALL_SYNCA
  1567. #define PDS_REPSYNCALL_ERRINFO PDS_REPSYNCALL_ERRINFOA
  1568. #define PDS_REPSYNCALL_UPDATE PDS_REPSYNCALL_UPDATEA
  1569. #endif
  1570. // **********************
  1571. // Replica SyncAll flags
  1572. // **********************
  1573. // This option has no effect.
  1574. #define DS_REPSYNCALL_NO_OPTIONS 0x00000000
  1575. // Ordinarily, if a server cannot be contacted, DsReplicaSyncAll tries to
  1576. // route around it and replicate from as many servers as possible. Enabling
  1577. // this option will cause DsReplicaSyncAll to generate a fatal error if any
  1578. // server cannot be contacted, or if any server is unreachable (due to a
  1579. // disconnected or broken topology.)
  1580. #define DS_REPSYNCALL_ABORT_IF_SERVER_UNAVAILABLE 0x00000001
  1581. // This option disables transitive replication; syncs will only be performed
  1582. // with adjacent servers and no DsBind calls will be made.
  1583. #define DS_REPSYNCALL_SYNC_ADJACENT_SERVERS_ONLY 0x00000002
  1584. // Ordinarily, when DsReplicaSyncAll encounters a non-fatal error, it returns
  1585. // the GUID DNS of the relevant server(s). Enabling this option causes
  1586. // DsReplicaSyncAll to return the servers' DNs instead.
  1587. #define DS_REPSYNCALL_ID_SERVERS_BY_DN 0x00000004
  1588. // This option disables all syncing. The topology will still be analyzed and
  1589. // unavailable / unreachable servers will still be identified.
  1590. #define DS_REPSYNCALL_DO_NOT_SYNC 0x00000008
  1591. // Ordinarily, DsReplicaSyncAll attempts to bind to all servers before
  1592. // generating the topology. If a server cannot be contacted, DsReplicaSyncAll
  1593. // excludes that server from the topology and tries to route around it. If
  1594. // this option is enabled, checking will be bypassed and DsReplicaSyncAll will
  1595. // assume all servers are responding. This will speed operation of
  1596. // DsReplicaSyncAll, but if some servers are not responding, some transitive
  1597. // replications may be blocked.
  1598. #define DS_REPSYNCALL_SKIP_INITIAL_CHECK 0x00000010
  1599. // Push mode. Push changes from the home server out to all partners using
  1600. // transitive replication. This reverses the direction of replication, and
  1601. // the order of execution of the replication sets from the usual "pulling"
  1602. // mode of execution.
  1603. #define DS_REPSYNCALL_PUSH_CHANGES_OUTWARD 0x00000020
  1604. // Cross site boundaries. By default, the only servers that are considered are
  1605. // those in the same site as the home system. With this option, all servers in
  1606. // the enterprise, across all sites, are eligible. They must be connected by
  1607. // a synchronous (RPC) transport, however.
  1608. #define DS_REPSYNCALL_CROSS_SITE_BOUNDARIES 0x00000040
  1609. // DsReplicaSyncAll. Syncs the destination server with all other servers
  1610. // in the site.
  1611. //
  1612. // PARAMETERS:
  1613. // hDS (IN) - A DS connection bound to the destination server.
  1614. // pszNameContext (IN) - The naming context to synchronize
  1615. // ulFlags (IN) - Bitwise OR of zero or more flags
  1616. // pFnCallBack (IN, OPTIONAL) - Callback function for message-passing.
  1617. // pCallbackData (IN, OPTIONAL) - A pointer that will be passed to the
  1618. // first argument of the callback function.
  1619. // pErrors (OUT, OPTIONAL) - Pointer to a (PDS_REPSYNCALL_ERRINFO *)
  1620. // object that will hold an array of error structures.
  1621. NTDSAPI
  1622. DWORD
  1623. WINAPI
  1624. DsReplicaSyncAllA (
  1625. HANDLE hDS,
  1626. LPCSTR pszNameContext,
  1627. ULONG ulFlags,
  1628. BOOL (__stdcall * pFnCallBack) (LPVOID, PDS_REPSYNCALL_UPDATEA),
  1629. LPVOID pCallbackData,
  1630. PDS_REPSYNCALL_ERRINFOA ** pErrors
  1631. );
  1632. NTDSAPI
  1633. DWORD
  1634. WINAPI
  1635. DsReplicaSyncAllW (
  1636. HANDLE hDS,
  1637. LPCWSTR pszNameContext,
  1638. ULONG ulFlags,
  1639. BOOL (__stdcall * pFnCallBack) (LPVOID, PDS_REPSYNCALL_UPDATEW),
  1640. LPVOID pCallbackData,
  1641. PDS_REPSYNCALL_ERRINFOW ** pErrors
  1642. );
  1643. #ifdef UNICODE
  1644. #define DsReplicaSyncAll DsReplicaSyncAllW
  1645. #else
  1646. #define DsReplicaSyncAll DsReplicaSyncAllA
  1647. #endif
  1648. NTDSAPI
  1649. DWORD
  1650. WINAPI
  1651. DsRemoveDsServerW(
  1652. HANDLE hDs, // in
  1653. LPWSTR ServerDN, // in
  1654. LPWSTR DomainDN, // in, optional
  1655. BOOL *fLastDcInDomain, // out, optional
  1656. BOOL fCommit // in
  1657. );
  1658. NTDSAPI
  1659. DWORD
  1660. WINAPI
  1661. DsRemoveDsServerA(
  1662. HANDLE hDs, // in
  1663. LPSTR ServerDN, // in
  1664. LPSTR DomainDN, // in, optional
  1665. BOOL *fLastDcInDomain, // out, optional
  1666. BOOL fCommit // in
  1667. );
  1668. #ifdef UNICODE
  1669. #define DsRemoveDsServer DsRemoveDsServerW
  1670. #else
  1671. #define DsRemoveDsServer DsRemoveDsServerA
  1672. #endif
  1673. NTDSAPI
  1674. DWORD
  1675. WINAPI
  1676. DsRemoveDsDomainW(
  1677. HANDLE hDs, // in
  1678. LPWSTR DomainDN // in
  1679. );
  1680. NTDSAPI
  1681. DWORD
  1682. WINAPI
  1683. DsRemoveDsDomainA(
  1684. HANDLE hDs, // in
  1685. LPSTR DomainDN // in
  1686. );
  1687. #ifdef UNICODE
  1688. #define DsRemoveDsDomain DsRemoveDsDomainW
  1689. #else
  1690. #define DsRemoveDsDomain DsRemoveDsDomainA
  1691. #endif
  1692. NTDSAPI
  1693. DWORD
  1694. WINAPI
  1695. DsListSitesA(
  1696. HANDLE hDs, // in
  1697. PDS_NAME_RESULTA *ppSites); // out
  1698. NTDSAPI
  1699. DWORD
  1700. WINAPI
  1701. DsListSitesW(
  1702. HANDLE hDs, // in
  1703. PDS_NAME_RESULTW *ppSites); // out
  1704. #ifdef UNICODE
  1705. #define DsListSites DsListSitesW
  1706. #else
  1707. #define DsListSites DsListSitesA
  1708. #endif
  1709. NTDSAPI
  1710. DWORD
  1711. WINAPI
  1712. DsListServersInSiteA(
  1713. HANDLE hDs, // in
  1714. LPCSTR site, // in
  1715. PDS_NAME_RESULTA *ppServers); // out
  1716. NTDSAPI
  1717. DWORD
  1718. WINAPI
  1719. DsListServersInSiteW(
  1720. HANDLE hDs, // in
  1721. LPCWSTR site, // in
  1722. PDS_NAME_RESULTW *ppServers); // out
  1723. #ifdef UNICODE
  1724. #define DsListServersInSite DsListServersInSiteW
  1725. #else
  1726. #define DsListServersInSite DsListServersInSiteA
  1727. #endif
  1728. NTDSAPI
  1729. DWORD
  1730. WINAPI
  1731. DsListDomainsInSiteA(
  1732. HANDLE hDs, // in
  1733. LPCSTR site, // in
  1734. PDS_NAME_RESULTA *ppDomains); // out
  1735. NTDSAPI
  1736. DWORD
  1737. WINAPI
  1738. DsListDomainsInSiteW(
  1739. HANDLE hDs, // in
  1740. LPCWSTR site, // in
  1741. PDS_NAME_RESULTW *ppDomains); // out
  1742. #ifdef UNICODE
  1743. #define DsListDomainsInSite DsListDomainsInSiteW
  1744. #else
  1745. #define DsListDomainsInSite DsListDomainsInSiteA
  1746. #endif
  1747. NTDSAPI
  1748. DWORD
  1749. WINAPI
  1750. DsListServersForDomainInSiteA(
  1751. HANDLE hDs, // in
  1752. LPCSTR domain, // in
  1753. LPCSTR site, // in
  1754. PDS_NAME_RESULTA *ppServers); // out
  1755. NTDSAPI
  1756. DWORD
  1757. WINAPI
  1758. DsListServersForDomainInSiteW(
  1759. HANDLE hDs, // in
  1760. LPCWSTR domain, // in
  1761. LPCWSTR site, // in
  1762. PDS_NAME_RESULTW *ppServers); // out
  1763. #ifdef UNICODE
  1764. #define DsListServersForDomainInSite DsListServersForDomainInSiteW
  1765. #else
  1766. #define DsListServersForDomainInSite DsListServersForDomainInSiteA
  1767. #endif
  1768. // Define indices for DsListInfoForServer return data. Check status
  1769. // for each field as a given value may not be present.
  1770. #define DS_LIST_DSA_OBJECT_FOR_SERVER 0
  1771. #define DS_LIST_DNS_HOST_NAME_FOR_SERVER 1
  1772. #define DS_LIST_ACCOUNT_OBJECT_FOR_SERVER 2
  1773. NTDSAPI
  1774. DWORD
  1775. WINAPI
  1776. DsListInfoForServerA(
  1777. HANDLE hDs, // in
  1778. LPCSTR server, // in
  1779. PDS_NAME_RESULTA *ppInfo); // out
  1780. NTDSAPI
  1781. DWORD
  1782. WINAPI
  1783. DsListInfoForServerW(
  1784. HANDLE hDs, // in
  1785. LPCWSTR server, // in
  1786. PDS_NAME_RESULTW *ppInfo); // out
  1787. #ifdef UNICODE
  1788. #define DsListInfoForServer DsListInfoForServerW
  1789. #else
  1790. #define DsListInfoForServer DsListInfoForServerA
  1791. #endif
  1792. // Define indices for DsListRoles return data. Check status for
  1793. // each field as a given value may not be present.
  1794. #define DS_ROLE_SCHEMA_OWNER 0
  1795. #define DS_ROLE_DOMAIN_OWNER 1
  1796. #define DS_ROLE_PDC_OWNER 2
  1797. #define DS_ROLE_RID_OWNER 3
  1798. #define DS_ROLE_INFRASTRUCTURE_OWNER 4
  1799. NTDSAPI
  1800. DWORD
  1801. WINAPI
  1802. DsListRolesA(
  1803. HANDLE hDs, // in
  1804. PDS_NAME_RESULTA *ppRoles); // out
  1805. NTDSAPI
  1806. DWORD
  1807. WINAPI
  1808. DsListRolesW(
  1809. HANDLE hDs, // in
  1810. PDS_NAME_RESULTW *ppRoles); // out
  1811. #ifdef UNICODE
  1812. #define DsListRoles DsListRolesW
  1813. #else
  1814. #define DsListRoles DsListRolesA
  1815. #endif
  1816. //
  1817. // DsQuerySitesByCost{A|W} allows the caller to determine the
  1818. // communication cost between the From Site and each of the sites
  1819. // in the list of To Sites. The costs are returned in the rgSiteInfo
  1820. // structure which must be freed with DsQuerySitesFree.
  1821. //
  1822. // The Site Names should all be passed as RDNs. For example, if the
  1823. // site's DN is "CN=Foo,CN=Sites,CN=Configuration,...", the RDN is
  1824. // simply "Foo".
  1825. //
  1826. typedef struct {
  1827. DWORD errorCode;
  1828. DWORD cost;
  1829. } DS_SITE_COST_INFO, *PDS_SITE_COST_INFO;
  1830. NTDSAPI_POSTXP
  1831. DWORD
  1832. WINAPI
  1833. DsQuerySitesByCostW(
  1834. HANDLE hDS, // in
  1835. LPWSTR pwszFromSite, // in
  1836. LPWSTR *rgwszToSites, // in
  1837. DWORD cToSites, // in
  1838. DWORD dwFlags, // in
  1839. PDS_SITE_COST_INFO *prgSiteInfo // out
  1840. );
  1841. NTDSAPI_POSTXP
  1842. DWORD
  1843. WINAPI
  1844. DsQuerySitesByCostA(
  1845. HANDLE hDS, // in
  1846. LPSTR pwszFromSite, // in
  1847. LPSTR *rgwszToSites, // in
  1848. DWORD cToSites, // in
  1849. DWORD dwFlags, // in
  1850. PDS_SITE_COST_INFO *prgSiteInfo // out
  1851. );
  1852. #ifdef UNICODE
  1853. #define DsQuerySitesByCost DsQuerySitesByCostW
  1854. #else
  1855. #define DsQuerySitesByCost DsQuerySitesByCostA
  1856. #endif
  1857. //
  1858. // DsQuerySitesByCost will free the site info array returned
  1859. // from DsQuerySitesByCost{A|W}.
  1860. //
  1861. VOID
  1862. DsQuerySitesFree(
  1863. PDS_SITE_COST_INFO rgSiteInfo
  1864. );
  1865. // Definitions required for DsMapSchemaGuid routines.
  1866. #define DS_SCHEMA_GUID_NOT_FOUND 0
  1867. #define DS_SCHEMA_GUID_ATTR 1
  1868. #define DS_SCHEMA_GUID_ATTR_SET 2
  1869. #define DS_SCHEMA_GUID_CLASS 3
  1870. #define DS_SCHEMA_GUID_CONTROL_RIGHT 4
  1871. typedef struct
  1872. {
  1873. GUID guid; // mapped GUID
  1874. DWORD guidType; // DS_SCHEMA_GUID_* value
  1875. #ifdef MIDL_PASS
  1876. [string,unique] CHAR *pName; // might be NULL
  1877. #else
  1878. LPSTR pName; // might be NULL
  1879. #endif
  1880. } DS_SCHEMA_GUID_MAPA, *PDS_SCHEMA_GUID_MAPA;
  1881. typedef struct
  1882. {
  1883. GUID guid; // mapped GUID
  1884. DWORD guidType; // DS_SCHEMA_GUID_* value
  1885. #ifdef MIDL_PASS
  1886. [string,unique] WCHAR *pName; // might be NULL
  1887. #else
  1888. LPWSTR pName; // might be NULL
  1889. #endif
  1890. } DS_SCHEMA_GUID_MAPW, *PDS_SCHEMA_GUID_MAPW;
  1891. NTDSAPI
  1892. DWORD
  1893. WINAPI
  1894. DsMapSchemaGuidsA(
  1895. HANDLE hDs, // in
  1896. DWORD cGuids, // in
  1897. GUID *rGuids, // in
  1898. DS_SCHEMA_GUID_MAPA **ppGuidMap); // out
  1899. NTDSAPI
  1900. VOID
  1901. WINAPI
  1902. DsFreeSchemaGuidMapA(
  1903. PDS_SCHEMA_GUID_MAPA pGuidMap); // in
  1904. NTDSAPI
  1905. DWORD
  1906. WINAPI
  1907. DsMapSchemaGuidsW(
  1908. HANDLE hDs, // in
  1909. DWORD cGuids, // in
  1910. GUID *rGuids, // in
  1911. DS_SCHEMA_GUID_MAPW **ppGuidMap); // out
  1912. NTDSAPI
  1913. VOID
  1914. WINAPI
  1915. DsFreeSchemaGuidMapW(
  1916. PDS_SCHEMA_GUID_MAPW pGuidMap); // in
  1917. #ifdef UNICODE
  1918. #define DS_SCHEMA_GUID_MAP DS_SCHEMA_GUID_MAPW
  1919. #define PDS_SCHEMA_GUID_MAP PDS_SCHEMA_GUID_MAPW
  1920. #define DsMapSchemaGuids DsMapSchemaGuidsW
  1921. #define DsFreeSchemaGuidMap DsFreeSchemaGuidMapW
  1922. #else
  1923. #define DS_SCHEMA_GUID_MAP DS_SCHEMA_GUID_MAPA
  1924. #define PDS_SCHEMA_GUID_MAP PDS_SCHEMA_GUID_MAPA
  1925. #define DsMapSchemaGuids DsMapSchemaGuidsA
  1926. #define DsFreeSchemaGuidMap DsFreeSchemaGuidMapA
  1927. #endif
  1928. typedef struct
  1929. {
  1930. #ifdef MIDL_PASS
  1931. [string,unique] CHAR *NetbiosName; // might be NULL
  1932. [string,unique] CHAR *DnsHostName; // might be NULL
  1933. [string,unique] CHAR *SiteName; // might be NULL
  1934. [string,unique] CHAR *ComputerObjectName; // might be NULL
  1935. [string,unique] CHAR *ServerObjectName; // might be NULL
  1936. #else
  1937. LPSTR NetbiosName; // might be NULL
  1938. LPSTR DnsHostName; // might be NULL
  1939. LPSTR SiteName; // might be NULL
  1940. LPSTR ComputerObjectName; // might be NULL
  1941. LPSTR ServerObjectName; // might be NULL
  1942. #endif
  1943. BOOL fIsPdc;
  1944. BOOL fDsEnabled;
  1945. } DS_DOMAIN_CONTROLLER_INFO_1A, *PDS_DOMAIN_CONTROLLER_INFO_1A;
  1946. typedef struct
  1947. {
  1948. #ifdef MIDL_PASS
  1949. [string,unique] WCHAR *NetbiosName; // might be NULL
  1950. [string,unique] WCHAR *DnsHostName; // might be NULL
  1951. [string,unique] WCHAR *SiteName; // might be NULL
  1952. [string,unique] WCHAR *ComputerObjectName; // might be NULL
  1953. [string,unique] WCHAR *ServerObjectName; // might be NULL
  1954. #else
  1955. LPWSTR NetbiosName; // might be NULL
  1956. LPWSTR DnsHostName; // might be NULL
  1957. LPWSTR SiteName; // might be NULL
  1958. LPWSTR ComputerObjectName; // might be NULL
  1959. LPWSTR ServerObjectName; // might be NULL
  1960. #endif
  1961. BOOL fIsPdc;
  1962. BOOL fDsEnabled;
  1963. } DS_DOMAIN_CONTROLLER_INFO_1W, *PDS_DOMAIN_CONTROLLER_INFO_1W;
  1964. typedef struct
  1965. {
  1966. #ifdef MIDL_PASS
  1967. [string,unique] CHAR *NetbiosName; // might be NULL
  1968. [string,unique] CHAR *DnsHostName; // might be NULL
  1969. [string,unique] CHAR *SiteName; // might be NULL
  1970. [string,unique] CHAR *SiteObjectName; // might be NULL
  1971. [string,unique] CHAR *ComputerObjectName; // might be NULL
  1972. [string,unique] CHAR *ServerObjectName; // might be NULL
  1973. [string,unique] CHAR *NtdsDsaObjectName; // might be NULL
  1974. #else
  1975. LPSTR NetbiosName; // might be NULL
  1976. LPSTR DnsHostName; // might be NULL
  1977. LPSTR SiteName; // might be NULL
  1978. LPSTR SiteObjectName; // might be NULL
  1979. LPSTR ComputerObjectName; // might be NULL
  1980. LPSTR ServerObjectName; // might be NULL
  1981. LPSTR NtdsDsaObjectName; // might be NULL
  1982. #endif
  1983. BOOL fIsPdc;
  1984. BOOL fDsEnabled;
  1985. BOOL fIsGc;
  1986. // Valid iff SiteObjectName non-NULL.
  1987. GUID SiteObjectGuid;
  1988. // Valid iff ComputerObjectName non-NULL.
  1989. GUID ComputerObjectGuid;
  1990. // Valid iff ServerObjectName non-NULL;
  1991. GUID ServerObjectGuid;
  1992. // Valid iff fDsEnabled is TRUE.
  1993. GUID NtdsDsaObjectGuid;
  1994. } DS_DOMAIN_CONTROLLER_INFO_2A, *PDS_DOMAIN_CONTROLLER_INFO_2A;
  1995. typedef struct
  1996. {
  1997. #ifdef MIDL_PASS
  1998. [string,unique] WCHAR *NetbiosName; // might be NULL
  1999. [string,unique] WCHAR *DnsHostName; // might be NULL
  2000. [string,unique] WCHAR *SiteName; // might be NULL
  2001. [string,unique] WCHAR *SiteObjectName; // might be NULL
  2002. [string,unique] WCHAR *ComputerObjectName; // might be NULL
  2003. [string,unique] WCHAR *ServerObjectName; // might be NULL
  2004. [string,unique] WCHAR *NtdsDsaObjectName; // might be NULL
  2005. #else
  2006. LPWSTR NetbiosName; // might be NULL
  2007. LPWSTR DnsHostName; // might be NULL
  2008. LPWSTR SiteName; // might be NULL
  2009. LPWSTR SiteObjectName; // might be NULL
  2010. LPWSTR ComputerObjectName; // might be NULL
  2011. LPWSTR ServerObjectName; // might be NULL
  2012. LPWSTR NtdsDsaObjectName; // might be NULL
  2013. #endif
  2014. BOOL fIsPdc;
  2015. BOOL fDsEnabled;
  2016. BOOL fIsGc;
  2017. // Valid iff SiteObjectName non-NULL.
  2018. GUID SiteObjectGuid;
  2019. // Valid iff ComputerObjectName non-NULL.
  2020. GUID ComputerObjectGuid;
  2021. // Valid iff ServerObjectName non-NULL;
  2022. GUID ServerObjectGuid;
  2023. // Valid iff fDsEnabled is TRUE.
  2024. GUID NtdsDsaObjectGuid;
  2025. } DS_DOMAIN_CONTROLLER_INFO_2W, *PDS_DOMAIN_CONTROLLER_INFO_2W;
  2026. // The following APIs strictly find domain controller account objects
  2027. // in the DS and return information associated with them. As such, they
  2028. // may return entries which correspond to domain controllers long since
  2029. // decommissioned, etc. and there is no guarantee that there exists a
  2030. // physical domain controller at all. Use DsGetDcName (dsgetdc.h) to find
  2031. // live domain controllers for a domain.
  2032. NTDSAPI
  2033. DWORD
  2034. WINAPI
  2035. DsGetDomainControllerInfoA(
  2036. HANDLE hDs, // in
  2037. LPCSTR DomainName, // in
  2038. DWORD InfoLevel, // in
  2039. DWORD *pcOut, // out
  2040. VOID **ppInfo); // out
  2041. NTDSAPI
  2042. DWORD
  2043. WINAPI
  2044. DsGetDomainControllerInfoW(
  2045. HANDLE hDs, // in
  2046. LPCWSTR DomainName, // in
  2047. DWORD InfoLevel, // in
  2048. DWORD *pcOut, // out
  2049. VOID **ppInfo); // out
  2050. NTDSAPI
  2051. VOID
  2052. WINAPI
  2053. DsFreeDomainControllerInfoA(
  2054. DWORD InfoLevel, // in
  2055. DWORD cInfo, // in
  2056. VOID *pInfo); // in
  2057. NTDSAPI
  2058. VOID
  2059. WINAPI
  2060. DsFreeDomainControllerInfoW(
  2061. DWORD InfoLevel, // in
  2062. DWORD cInfo, // in
  2063. VOID *pInfo); // in
  2064. #ifdef UNICODE
  2065. #define DS_DOMAIN_CONTROLLER_INFO_1 DS_DOMAIN_CONTROLLER_INFO_1W
  2066. #define DS_DOMAIN_CONTROLLER_INFO_2 DS_DOMAIN_CONTROLLER_INFO_2W
  2067. #define PDS_DOMAIN_CONTROLLER_INFO_1 PDS_DOMAIN_CONTROLLER_INFO_1W
  2068. #define PDS_DOMAIN_CONTROLLER_INFO_2 PDS_DOMAIN_CONTROLLER_INFO_2W
  2069. #define DsGetDomainControllerInfo DsGetDomainControllerInfoW
  2070. #define DsFreeDomainControllerInfo DsFreeDomainControllerInfoW
  2071. #else
  2072. #define DS_DOMAIN_CONTROLLER_INFO_1 DS_DOMAIN_CONTROLLER_INFO_1A
  2073. #define DS_DOMAIN_CONTROLLER_INFO_2 DS_DOMAIN_CONTROLLER_INFO_2A
  2074. #define PDS_DOMAIN_CONTROLLER_INFO_1 PDS_DOMAIN_CONTROLLER_INFO_1A
  2075. #define PDS_DOMAIN_CONTROLLER_INFO_2 PDS_DOMAIN_CONTROLLER_INFO_2A
  2076. #define DsGetDomainControllerInfo DsGetDomainControllerInfoA
  2077. #define DsFreeDomainControllerInfo DsFreeDomainControllerInfoA
  2078. #endif
  2079. // Which task should be run?
  2080. typedef enum {
  2081. DS_KCC_TASKID_UPDATE_TOPOLOGY = 0
  2082. } DS_KCC_TASKID;
  2083. // Don't wait for completion of the task; queue it and return.
  2084. #define DS_KCC_FLAG_ASYNC_OP (1 << 0)
  2085. // Don't enqueue the task if another queued task will run soon.
  2086. #define DS_KCC_FLAG_DAMPED (1 << 1)
  2087. NTDSAPI
  2088. DWORD
  2089. WINAPI
  2090. DsReplicaConsistencyCheck(
  2091. HANDLE hDS, // in
  2092. DS_KCC_TASKID TaskID, // in
  2093. DWORD dwFlags); // in
  2094. NTDSAPI
  2095. DWORD
  2096. WINAPI
  2097. DsReplicaVerifyObjectsW(
  2098. HANDLE hDS, // in
  2099. LPCWSTR NameContext,// in
  2100. const UUID * pUuidDsaSrc,// in
  2101. ULONG ulOptions); // in
  2102. NTDSAPI
  2103. DWORD
  2104. WINAPI
  2105. DsReplicaVerifyObjectsA(
  2106. HANDLE hDS, // in
  2107. LPCSTR NameContext,// in
  2108. const UUID * pUuidDsaSrc,// in
  2109. ULONG ulOptions); // in
  2110. #ifdef UNICODE
  2111. #define DsReplicaVerifyObjects DsReplicaVerifyObjectsW
  2112. #else
  2113. #define DsReplicaVerifyObjects DsReplicaVerifyObjectsA
  2114. #endif
  2115. // Do not delete objects on DsReplicaVerifyObjects call
  2116. #define DS_EXIST_ADVISORY_MODE (0x1)
  2117. typedef enum _DS_REPL_INFO_TYPE {
  2118. DS_REPL_INFO_NEIGHBORS = 0, // returns DS_REPL_NEIGHBORS *
  2119. DS_REPL_INFO_CURSORS_FOR_NC = 1, // returns DS_REPL_CURSORS *
  2120. DS_REPL_INFO_METADATA_FOR_OBJ = 2, // returns DS_REPL_OBJECT_META_DATA *
  2121. DS_REPL_INFO_KCC_DSA_CONNECT_FAILURES = 3, // both return
  2122. DS_REPL_INFO_KCC_DSA_LINK_FAILURES = 4, // DS_REPL_KCC_DSA_FAILURES *
  2123. DS_REPL_INFO_PENDING_OPS = 5, // returns DS_REPL_PENDING_OPS *
  2124. ////////////////////////////////////////////////////////////////////////////
  2125. //
  2126. // The following info types are not supported by Windows 2000. Calling
  2127. // DsReplicaGetInfo() with one of the types on a Windows 2000 client or
  2128. // where hDS is bound to a Windows 2000 DC will fail with
  2129. // ERROR_NOT_SUPPORTED.
  2130. //
  2131. DS_REPL_INFO_METADATA_FOR_ATTR_VALUE = 6, // returns DS_REPL_ATTR_VALUE_META_DATA *
  2132. DS_REPL_INFO_CURSORS_2_FOR_NC = 7, // returns DS_REPL_CURSORS_2 *
  2133. DS_REPL_INFO_CURSORS_3_FOR_NC = 8, // returns DS_REPL_CURSORS_3 *
  2134. DS_REPL_INFO_METADATA_2_FOR_OBJ = 9, // returns DS_REPL_OBJECT_META_DATA_2 *
  2135. DS_REPL_INFO_METADATA_2_FOR_ATTR_VALUE = 10,// returns DS_REPL_ATTR_VALUE_META_DATA_2 *
  2136. // <- insert new DS_REPL_INFO_* types here.
  2137. DS_REPL_INFO_TYPE_MAX
  2138. } DS_REPL_INFO_TYPE;
  2139. // Bit values for flags argument to DsReplicaGetInfo2
  2140. #define DS_REPL_INFO_FLAG_IMPROVE_LINKED_ATTRS (0x00000001)
  2141. // Bit values for the dwReplicaFlags field of the DS_REPL_NEIGHBOR structure.
  2142. // Also used for the ulReplicaFlags argument to DsReplicaModify
  2143. #define DS_REPL_NBR_WRITEABLE (0x00000010)
  2144. #define DS_REPL_NBR_SYNC_ON_STARTUP (0x00000020)
  2145. #define DS_REPL_NBR_DO_SCHEDULED_SYNCS (0x00000040)
  2146. #define DS_REPL_NBR_USE_ASYNC_INTERSITE_TRANSPORT (0x00000080)
  2147. #define DS_REPL_NBR_TWO_WAY_SYNC (0x00000200)
  2148. #define DS_REPL_NBR_RETURN_OBJECT_PARENTS (0x00000800)
  2149. #define DS_REPL_NBR_FULL_SYNC_IN_PROGRESS (0x00010000)
  2150. #define DS_REPL_NBR_FULL_SYNC_NEXT_PACKET (0x00020000)
  2151. #define DS_REPL_NBR_NEVER_SYNCED (0x00200000)
  2152. #define DS_REPL_NBR_PREEMPTED (0x01000000)
  2153. #define DS_REPL_NBR_IGNORE_CHANGE_NOTIFICATIONS (0x04000000)
  2154. #define DS_REPL_NBR_DISABLE_SCHEDULED_SYNC (0x08000000)
  2155. #define DS_REPL_NBR_COMPRESS_CHANGES (0x10000000)
  2156. #define DS_REPL_NBR_NO_CHANGE_NOTIFICATIONS (0x20000000)
  2157. #define DS_REPL_NBR_PARTIAL_ATTRIBUTE_SET (0x40000000)
  2158. // This is the mask of replica flags that may be changed on the DsReplicaModify
  2159. // call using the ulReplicaFlags parameter. The other flags are protected
  2160. // system flags. The previous values of the system flags must be read in
  2161. // advance and merged into the ulReplicaFlags parameter unchanged.
  2162. #define DS_REPL_NBR_MODIFIABLE_MASK \
  2163. ( \
  2164. DS_REPL_NBR_SYNC_ON_STARTUP | \
  2165. DS_REPL_NBR_DO_SCHEDULED_SYNCS | \
  2166. DS_REPL_NBR_TWO_WAY_SYNC | \
  2167. DS_REPL_NBR_IGNORE_CHANGE_NOTIFICATIONS | \
  2168. DS_REPL_NBR_DISABLE_SCHEDULED_SYNC | \
  2169. DS_REPL_NBR_COMPRESS_CHANGES | \
  2170. DS_REPL_NBR_NO_CHANGE_NOTIFICATIONS \
  2171. )
  2172. typedef struct _DS_REPL_NEIGHBORW {
  2173. LPWSTR pszNamingContext;
  2174. LPWSTR pszSourceDsaDN;
  2175. LPWSTR pszSourceDsaAddress;
  2176. LPWSTR pszAsyncIntersiteTransportDN;
  2177. DWORD dwReplicaFlags;
  2178. DWORD dwReserved; // alignment
  2179. UUID uuidNamingContextObjGuid;
  2180. UUID uuidSourceDsaObjGuid;
  2181. UUID uuidSourceDsaInvocationID;
  2182. UUID uuidAsyncIntersiteTransportObjGuid;
  2183. USN usnLastObjChangeSynced;
  2184. USN usnAttributeFilter;
  2185. FILETIME ftimeLastSyncSuccess;
  2186. FILETIME ftimeLastSyncAttempt;
  2187. DWORD dwLastSyncResult;
  2188. DWORD cNumConsecutiveSyncFailures;
  2189. } DS_REPL_NEIGHBORW;
  2190. // Fields can be added only to the end of this structure.
  2191. typedef struct _DS_REPL_NEIGHBORW_BLOB {
  2192. DWORD oszNamingContext;
  2193. DWORD oszSourceDsaDN;
  2194. DWORD oszSourceDsaAddress;
  2195. DWORD oszAsyncIntersiteTransportDN;
  2196. DWORD dwReplicaFlags;
  2197. DWORD dwReserved;
  2198. UUID uuidNamingContextObjGuid;
  2199. UUID uuidSourceDsaObjGuid;
  2200. UUID uuidSourceDsaInvocationID;
  2201. UUID uuidAsyncIntersiteTransportObjGuid;
  2202. USN usnLastObjChangeSynced;
  2203. USN usnAttributeFilter;
  2204. FILETIME ftimeLastSyncSuccess;
  2205. FILETIME ftimeLastSyncAttempt;
  2206. DWORD dwLastSyncResult;
  2207. DWORD cNumConsecutiveSyncFailures;
  2208. } DS_REPL_NEIGHBORW_BLOB;
  2209. typedef struct _DS_REPL_NEIGHBORSW {
  2210. DWORD cNumNeighbors;
  2211. DWORD dwReserved; // alignment
  2212. #ifdef MIDL_PASS
  2213. [size_is(cNumNeighbors)] DS_REPL_NEIGHBORW rgNeighbor[];
  2214. #else
  2215. DS_REPL_NEIGHBORW rgNeighbor[1];
  2216. #endif
  2217. } DS_REPL_NEIGHBORSW;
  2218. typedef struct _DS_REPL_CURSOR {
  2219. UUID uuidSourceDsaInvocationID;
  2220. USN usnAttributeFilter;
  2221. } DS_REPL_CURSOR;
  2222. typedef struct _DS_REPL_CURSOR_2 {
  2223. UUID uuidSourceDsaInvocationID;
  2224. USN usnAttributeFilter;
  2225. FILETIME ftimeLastSyncSuccess;
  2226. } DS_REPL_CURSOR_2;
  2227. typedef struct _DS_REPL_CURSOR_3W {
  2228. UUID uuidSourceDsaInvocationID;
  2229. USN usnAttributeFilter;
  2230. FILETIME ftimeLastSyncSuccess;
  2231. LPWSTR pszSourceDsaDN;
  2232. } DS_REPL_CURSOR_3W;
  2233. // Fields can be added only to the end of this structure.
  2234. typedef struct _DS_REPL_CURSOR_BLOB {
  2235. UUID uuidSourceDsaInvocationID;
  2236. USN usnAttributeFilter;
  2237. FILETIME ftimeLastSyncSuccess;
  2238. DWORD oszSourceDsaDN;
  2239. } DS_REPL_CURSOR_BLOB;
  2240. typedef struct _DS_REPL_CURSORS {
  2241. DWORD cNumCursors;
  2242. DWORD dwReserved; // alignment
  2243. #ifdef MIDL_PASS
  2244. [size_is(cNumCursors)] DS_REPL_CURSOR rgCursor[];
  2245. #else
  2246. DS_REPL_CURSOR rgCursor[1];
  2247. #endif
  2248. } DS_REPL_CURSORS;
  2249. typedef struct _DS_REPL_CURSORS_2 {
  2250. DWORD cNumCursors;
  2251. DWORD dwEnumerationContext;
  2252. // keep this 8 byte aligned
  2253. #ifdef MIDL_PASS
  2254. [size_is(cNumCursors)] DS_REPL_CURSOR_2 rgCursor[];
  2255. #else
  2256. DS_REPL_CURSOR_2 rgCursor[1];
  2257. #endif
  2258. } DS_REPL_CURSORS_2;
  2259. typedef struct _DS_REPL_CURSORS_3W {
  2260. DWORD cNumCursors;
  2261. DWORD dwEnumerationContext;
  2262. // keep this 8 byte aligned
  2263. #ifdef MIDL_PASS
  2264. [size_is(cNumCursors)] DS_REPL_CURSOR_3W rgCursor[];
  2265. #else
  2266. DS_REPL_CURSOR_3W rgCursor[1];
  2267. #endif
  2268. } DS_REPL_CURSORS_3W;
  2269. typedef struct _DS_REPL_ATTR_META_DATA {
  2270. LPWSTR pszAttributeName;
  2271. DWORD dwVersion;
  2272. FILETIME ftimeLastOriginatingChange;
  2273. UUID uuidLastOriginatingDsaInvocationID;
  2274. USN usnOriginatingChange; // in the originating DSA's USN space
  2275. USN usnLocalChange; // in the local DSA's USN space
  2276. } DS_REPL_ATTR_META_DATA;
  2277. typedef struct _DS_REPL_ATTR_META_DATA_2 {
  2278. LPWSTR pszAttributeName;
  2279. DWORD dwVersion;
  2280. FILETIME ftimeLastOriginatingChange;
  2281. UUID uuidLastOriginatingDsaInvocationID;
  2282. USN usnOriginatingChange; // in the originating DSA's USN space
  2283. USN usnLocalChange; // in the local DSA's USN space
  2284. LPWSTR pszLastOriginatingDsaDN;
  2285. } DS_REPL_ATTR_META_DATA_2;
  2286. // Fields can be added only to the end of this structure.
  2287. typedef struct _DS_REPL_ATTR_META_DATA_BLOB {
  2288. DWORD oszAttributeName;
  2289. DWORD dwVersion;
  2290. FILETIME ftimeLastOriginatingChange;
  2291. UUID uuidLastOriginatingDsaInvocationID;
  2292. USN usnOriginatingChange; // in the originating DSA's USN space
  2293. USN usnLocalChange; // in the local DSA's USN space
  2294. DWORD oszLastOriginatingDsaDN;
  2295. } DS_REPL_ATTR_META_DATA_BLOB;
  2296. typedef struct _DS_REPL_OBJ_META_DATA {
  2297. DWORD cNumEntries;
  2298. DWORD dwReserved; // alignment
  2299. #ifdef MIDL_PASS
  2300. [size_is(cNumEntries)] DS_REPL_ATTR_META_DATA rgMetaData[];
  2301. #else
  2302. DS_REPL_ATTR_META_DATA rgMetaData[1];
  2303. #endif
  2304. } DS_REPL_OBJ_META_DATA;
  2305. typedef struct _DS_REPL_OBJ_META_DATA_2 {
  2306. DWORD cNumEntries;
  2307. DWORD dwReserved; // alignment
  2308. #ifdef MIDL_PASS
  2309. [size_is(cNumEntries)] DS_REPL_ATTR_META_DATA_2 rgMetaData[];
  2310. #else
  2311. DS_REPL_ATTR_META_DATA_2 rgMetaData[1];
  2312. #endif
  2313. } DS_REPL_OBJ_META_DATA_2;
  2314. typedef struct _DS_REPL_KCC_DSA_FAILUREW {
  2315. LPWSTR pszDsaDN;
  2316. UUID uuidDsaObjGuid;
  2317. FILETIME ftimeFirstFailure;
  2318. DWORD cNumFailures;
  2319. DWORD dwLastResult; // Win32 error code
  2320. } DS_REPL_KCC_DSA_FAILUREW;
  2321. // Fields can be added only to the end of this structure.
  2322. typedef struct _DS_REPL_KCC_DSA_FAILUREW_BLOB {
  2323. DWORD oszDsaDN;
  2324. UUID uuidDsaObjGuid;
  2325. FILETIME ftimeFirstFailure;
  2326. DWORD cNumFailures;
  2327. DWORD dwLastResult; // Win32 error code
  2328. } DS_REPL_KCC_DSA_FAILUREW_BLOB;
  2329. typedef struct _DS_REPL_KCC_DSA_FAILURESW {
  2330. DWORD cNumEntries;
  2331. DWORD dwReserved; // alignment
  2332. #ifdef MIDL_PASS
  2333. [size_is(cNumEntries)] DS_REPL_KCC_DSA_FAILUREW rgDsaFailure[];
  2334. #else
  2335. DS_REPL_KCC_DSA_FAILUREW rgDsaFailure[1];
  2336. #endif
  2337. } DS_REPL_KCC_DSA_FAILURESW;
  2338. typedef enum _DS_REPL_OP_TYPE {
  2339. DS_REPL_OP_TYPE_SYNC = 0,
  2340. DS_REPL_OP_TYPE_ADD,
  2341. DS_REPL_OP_TYPE_DELETE,
  2342. DS_REPL_OP_TYPE_MODIFY,
  2343. DS_REPL_OP_TYPE_UPDATE_REFS
  2344. } DS_REPL_OP_TYPE;
  2345. typedef struct _DS_REPL_OPW {
  2346. FILETIME ftimeEnqueued; // time at which the operation was enqueued
  2347. ULONG ulSerialNumber; // ID of this sync; unique per machine per boot
  2348. ULONG ulPriority; // > priority, > urgency
  2349. DS_REPL_OP_TYPE OpType;
  2350. ULONG ulOptions; // Zero or more bits specific to OpType; e.g.,
  2351. // DS_REPADD_* for DS_REPL_OP_TYPE_ADD,
  2352. // DS_REPSYNC_* for DS_REPL_OP_TYPE_SYNC, etc.
  2353. LPWSTR pszNamingContext;
  2354. LPWSTR pszDsaDN;
  2355. LPWSTR pszDsaAddress;
  2356. UUID uuidNamingContextObjGuid;
  2357. UUID uuidDsaObjGuid;
  2358. } DS_REPL_OPW;
  2359. // Fields can be added only to the end of this structure.
  2360. typedef struct _DS_REPL_OPW_BLOB {
  2361. FILETIME ftimeEnqueued; // time at which the operation was enqueued
  2362. ULONG ulSerialNumber; // ID of this sync; unique per machine per boot
  2363. ULONG ulPriority; // > priority, > urgency
  2364. DS_REPL_OP_TYPE OpType;
  2365. ULONG ulOptions; // Zero or more bits specific to OpType; e.g.,
  2366. // DS_REPADD_* for DS_REPL_OP_TYPE_ADD,
  2367. // DS_REPSYNC_* for DS_REPL_OP_TYPE_SYNC, etc.
  2368. DWORD oszNamingContext;
  2369. DWORD oszDsaDN;
  2370. DWORD oszDsaAddress;
  2371. UUID uuidNamingContextObjGuid;
  2372. UUID uuidDsaObjGuid;
  2373. } DS_REPL_OPW_BLOB;
  2374. typedef struct _DS_REPL_PENDING_OPSW {
  2375. FILETIME ftimeCurrentOpStarted;
  2376. DWORD cNumPendingOps;
  2377. #ifdef MIDL_PASS
  2378. [size_is(cNumPendingOps)] DS_REPL_OPW rgPendingOp[];
  2379. #else
  2380. DS_REPL_OPW rgPendingOp[1];
  2381. #endif
  2382. } DS_REPL_PENDING_OPSW;
  2383. typedef struct _DS_REPL_VALUE_META_DATA {
  2384. LPWSTR pszAttributeName;
  2385. LPWSTR pszObjectDn;
  2386. DWORD cbData;
  2387. #ifdef MIDL_PASS
  2388. [size_is(cbData), ptr] BYTE *pbData;
  2389. #else
  2390. BYTE *pbData;
  2391. #endif
  2392. FILETIME ftimeDeleted;
  2393. FILETIME ftimeCreated;
  2394. DWORD dwVersion;
  2395. FILETIME ftimeLastOriginatingChange;
  2396. UUID uuidLastOriginatingDsaInvocationID;
  2397. USN usnOriginatingChange; // in the originating DSA's USN space
  2398. USN usnLocalChange; // in the local DSA's USN space
  2399. } DS_REPL_VALUE_META_DATA;
  2400. typedef struct _DS_REPL_VALUE_META_DATA_2 {
  2401. LPWSTR pszAttributeName;
  2402. LPWSTR pszObjectDn;
  2403. DWORD cbData;
  2404. #ifdef MIDL_PASS
  2405. [size_is(cbData), ptr] BYTE *pbData;
  2406. #else
  2407. BYTE *pbData;
  2408. #endif
  2409. FILETIME ftimeDeleted;
  2410. FILETIME ftimeCreated;
  2411. DWORD dwVersion;
  2412. FILETIME ftimeLastOriginatingChange;
  2413. UUID uuidLastOriginatingDsaInvocationID;
  2414. USN usnOriginatingChange; // in the originating DSA's USN space
  2415. USN usnLocalChange; // in the local DSA's USN space
  2416. LPWSTR pszLastOriginatingDsaDN;
  2417. } DS_REPL_VALUE_META_DATA_2;
  2418. // Fields can be added only to the end of this structure.
  2419. typedef struct _DS_REPL_VALUE_META_DATA_BLOB {
  2420. DWORD oszAttributeName;
  2421. DWORD oszObjectDn;
  2422. DWORD cbData;
  2423. DWORD obData;
  2424. FILETIME ftimeDeleted;
  2425. FILETIME ftimeCreated;
  2426. DWORD dwVersion;
  2427. FILETIME ftimeLastOriginatingChange;
  2428. UUID uuidLastOriginatingDsaInvocationID;
  2429. USN usnOriginatingChange; // in the originating DSA's USN space
  2430. USN usnLocalChange; // in the local DSA's USN space
  2431. DWORD oszLastOriginatingDsaDN;
  2432. } DS_REPL_VALUE_META_DATA_BLOB;
  2433. typedef struct _DS_REPL_ATTR_VALUE_META_DATA {
  2434. DWORD cNumEntries;
  2435. DWORD dwEnumerationContext;
  2436. #ifdef MIDL_PASS
  2437. [size_is(cNumEntries)] DS_REPL_VALUE_META_DATA rgMetaData[];
  2438. #else
  2439. DS_REPL_VALUE_META_DATA rgMetaData[1];
  2440. #endif
  2441. } DS_REPL_ATTR_VALUE_META_DATA;
  2442. typedef struct _DS_REPL_ATTR_VALUE_META_DATA_2 {
  2443. DWORD cNumEntries;
  2444. DWORD dwEnumerationContext;
  2445. #ifdef MIDL_PASS
  2446. [size_is(cNumEntries)] DS_REPL_VALUE_META_DATA_2 rgMetaData[];
  2447. #else
  2448. DS_REPL_VALUE_META_DATA_2 rgMetaData[1];
  2449. #endif
  2450. } DS_REPL_ATTR_VALUE_META_DATA_2;
  2451. typedef struct _DS_REPL_QUEUE_STATISTICSW
  2452. {
  2453. FILETIME ftimeCurrentOpStarted;
  2454. DWORD cNumPendingOps;
  2455. FILETIME ftimeOldestSync;
  2456. FILETIME ftimeOldestAdd;
  2457. FILETIME ftimeOldestMod;
  2458. FILETIME ftimeOldestDel;
  2459. FILETIME ftimeOldestUpdRefs;
  2460. } DS_REPL_QUEUE_STATISTICSW;
  2461. // Fields can be added only to the end of this structure.
  2462. typedef struct _DS_REPL_QUEUE_STATISTICSW DS_REPL_QUEUE_STATISTICSW_BLOB;
  2463. NTDSAPI
  2464. DWORD
  2465. WINAPI
  2466. DsReplicaGetInfoW(
  2467. HANDLE hDS, // in
  2468. DS_REPL_INFO_TYPE InfoType, // in
  2469. LPCWSTR pszObject, // in
  2470. UUID * puuidForSourceDsaObjGuid, // in
  2471. VOID ** ppInfo); // out
  2472. // This API is not supported by Windows 2000 clients or Windows 2000 DCs.
  2473. NTDSAPI
  2474. DWORD
  2475. WINAPI
  2476. DsReplicaGetInfo2W(
  2477. HANDLE hDS, // in
  2478. DS_REPL_INFO_TYPE InfoType, // in
  2479. LPCWSTR pszObject, // in
  2480. UUID * puuidForSourceDsaObjGuid, // in
  2481. LPCWSTR pszAttributeName, // in
  2482. LPCWSTR pszValue, // in
  2483. DWORD dwFlags, // in
  2484. DWORD dwEnumerationContext, // in
  2485. VOID ** ppInfo); // out
  2486. NTDSAPI
  2487. void
  2488. WINAPI
  2489. DsReplicaFreeInfo(
  2490. DS_REPL_INFO_TYPE InfoType, // in
  2491. VOID * pInfo); // in
  2492. #ifdef UNICODE
  2493. #define DsReplicaGetInfo DsReplicaGetInfoW
  2494. #define DsReplicaGetInfo2 DsReplicaGetInfo2W
  2495. #define DS_REPL_NEIGHBOR DS_REPL_NEIGHBORW
  2496. #define DS_REPL_NEIGHBORS DS_REPL_NEIGHBORSW
  2497. #define DS_REPL_CURSOR_3 DS_REPL_CURSOR_3W
  2498. #define DS_REPL_CURSORS_3 DS_REPL_CURSORS_3W
  2499. #define DS_REPL_KCC_DSA_FAILURES DS_REPL_KCC_DSA_FAILURESW
  2500. #define DS_REPL_KCC_DSA_FAILURE DS_REPL_KCC_DSA_FAILUREW
  2501. #define DS_REPL_OP DS_REPL_OPW
  2502. #define DS_REPL_PENDING_OPS DS_REPL_PENDING_OPSW
  2503. #else
  2504. // No ANSI equivalents currently supported.
  2505. #endif
  2506. NTDSAPI
  2507. DWORD
  2508. WINAPI
  2509. DsAddSidHistoryW(
  2510. HANDLE hDS, // in
  2511. DWORD Flags, // in - sbz for now
  2512. LPCWSTR SrcDomain, // in - DNS or NetBIOS
  2513. LPCWSTR SrcPrincipal, // in - SAM account name
  2514. LPCWSTR SrcDomainController, // in, optional
  2515. RPC_AUTH_IDENTITY_HANDLE SrcDomainCreds, // in - creds for src domain
  2516. LPCWSTR DstDomain, // in - DNS or NetBIOS
  2517. LPCWSTR DstPrincipal); // in - SAM account name
  2518. NTDSAPI
  2519. DWORD
  2520. WINAPI
  2521. DsAddSidHistoryA(
  2522. HANDLE hDS, // in
  2523. DWORD Flags, // in - sbz for now
  2524. LPCSTR SrcDomain, // in - DNS or NetBIOS
  2525. LPCSTR SrcPrincipal, // in - SAM account name
  2526. LPCSTR SrcDomainController, // in, optional
  2527. RPC_AUTH_IDENTITY_HANDLE SrcDomainCreds, // in - creds for src domain
  2528. LPCSTR DstDomain, // in - DNS or NetBIOS
  2529. LPCSTR DstPrincipal); // in - SAM account name
  2530. #ifdef UNICODE
  2531. #define DsAddSidHistory DsAddSidHistoryW
  2532. #else
  2533. #define DsAddSidHistory DsAddSidHistoryA
  2534. #endif
  2535. // The DsInheritSecurityIdentity API adds the source principal's SID and
  2536. // SID history to the destination principal's SID history and then DELETES
  2537. // THE SOURCE PRINCIPAL. Source and destination principal must be in the
  2538. // same domain.
  2539. NTDSAPI
  2540. DWORD
  2541. WINAPI
  2542. DsInheritSecurityIdentityW(
  2543. HANDLE hDS, // in
  2544. DWORD Flags, // in - sbz for now
  2545. LPCWSTR SrcPrincipal, // in - distinguished name
  2546. LPCWSTR DstPrincipal); // in - distinguished name
  2547. NTDSAPI
  2548. DWORD
  2549. WINAPI
  2550. DsInheritSecurityIdentityA(
  2551. HANDLE hDS, // in
  2552. DWORD Flags, // in - sbz for now
  2553. LPCSTR SrcPrincipal, // in - distinguished name
  2554. LPCSTR DstPrincipal); // in - distinguished name
  2555. #ifdef UNICODE
  2556. #define DsInheritSecurityIdentity DsInheritSecurityIdentityW
  2557. #else
  2558. #define DsInheritSecurityIdentity DsInheritSecurityIdentityA
  2559. #endif
  2560. #ifndef MIDL_PASS
  2561. /*++
  2562. ==========================================================
  2563. NTDSAPI
  2564. DWORD
  2565. WINAPI
  2566. DsQuoteRdnValue(
  2567. IN DWORD cUnquotedRdnValueLength,
  2568. IN LPCTCH psUnquotedRdnValue,
  2569. IN OUT DWORD *pcQuotedRdnValueLength,
  2570. OUT LPTCH psQuotedRdnValue
  2571. )
  2572. /*++
  2573. Description
  2574. This client call converts an RDN value into a quoted RDN value if
  2575. the RDN value contains characters that require quotes. The resultant
  2576. RDN can be submitted as part of a DN to the DS using various APIs
  2577. such as LDAP.
  2578. No quotes are added if none are needed. In this case, the
  2579. output RDN value will be the same as the input RDN value.
  2580. The RDN is quoted in accordance with the specification "Lightweight
  2581. Directory Access Protocol (v3): UTF-8 String Representation of
  2582. Distinguished Names", RFC 2253.
  2583. The input and output RDN values are *NOT* NULL terminated.
  2584. The changes made by this call can be undone by calling
  2585. DsUnquoteRdnValue().
  2586. Arguments:
  2587. cUnquotedRdnValueLength - The length of psUnquotedRdnValue in chars.
  2588. psUnquotedRdnValue - Unquoted RDN value.
  2589. pcQuotedRdnValueeLength - IN, maximum length of psQuotedRdnValue, in chars
  2590. OUT ERROR_SUCCESS, chars utilized in psQuotedRdnValue
  2591. OUT ERROR_BUFFER_OVERFLOW, chars needed in psQuotedRdnValue
  2592. psQuotedRdnValue - The resultant and perhaps quoted RDN value
  2593. Return Value:
  2594. ERROR_SUCCESS
  2595. If quotes or escapes were needed, then psQuotedRdnValue contains
  2596. the quoted, escaped version of psUnquotedRdnValue. Otherwise,
  2597. psQuotedRdnValue contains a copy of psUnquotedRdnValue. In either
  2598. case, pcQuotedRdnValueLength contains the space utilized, in chars.
  2599. ERROR_BUFFER_OVERFLOW
  2600. psQuotedRdnValueLength contains the space needed, in chars,
  2601. to hold psQuotedRdnValue.
  2602. ERROR_INVALID_PARAMETER
  2603. Invalid parameter.
  2604. ERROR_NOT_ENOUGH_MEMORY
  2605. Allocation error.
  2606. --*/
  2607. NTDSAPI
  2608. DWORD
  2609. WINAPI
  2610. DsQuoteRdnValueW(
  2611. IN DWORD cUnquotedRdnValueLength,
  2612. IN LPCWCH psUnquotedRdnValue,
  2613. IN OUT DWORD *pcQuotedRdnValueLength,
  2614. OUT LPWCH psQuotedRdnValue
  2615. );
  2616. NTDSAPI
  2617. DWORD
  2618. WINAPI
  2619. DsQuoteRdnValueA(
  2620. IN DWORD cUnquotedRdnValueLength,
  2621. IN LPCCH psUnquotedRdnValue,
  2622. IN OUT DWORD *pcQuotedRdnValueLength,
  2623. OUT LPCH psQuotedRdnValue
  2624. );
  2625. #ifdef UNICODE
  2626. #define DsQuoteRdnValue DsQuoteRdnValueW
  2627. #else
  2628. #define DsQuoteRdnValue DsQuoteRdnValueA
  2629. #endif
  2630. /*++
  2631. ==========================================================
  2632. NTDSAPI
  2633. DWORD
  2634. WINAPI
  2635. DsUnquoteRdnValue(
  2636. IN DWORD cQuotedRdnValueLength,
  2637. IN LPCTCH psQuotedRdnValue,
  2638. IN OUT DWORD *pcUnquotedRdnValueLength,
  2639. OUT LPTCH psUnquotedRdnValue
  2640. )
  2641. Description
  2642. This client call converts a quoted RDN Value into an unquoted RDN
  2643. Value. The resultant RDN value should *NOT* be submitted as part
  2644. of a DN to the DS using various APIs such as LDAP.
  2645. When psQuotedRdnValue is quoted:
  2646. The leading and trailing quote are removed.
  2647. Whitespace before the first quote is discarded.
  2648. Whitespace trailing the last quote is discarded.
  2649. Escapes are removed and the char following the escape is kept.
  2650. The following actions are taken when psQuotedRdnValue is unquoted:
  2651. Leading whitespace is discarded.
  2652. Trailing whitespace is kept.
  2653. Escaped non-special chars return an error.
  2654. Unescaped special chars return an error.
  2655. RDN values beginning with # (ignoring leading whitespace) are
  2656. treated as a stringized BER value and converted accordingly.
  2657. Escaped hex digits (\89) are converted into a binary byte (0x89).
  2658. Escapes are removed from escaped special chars.
  2659. The following actions are always taken:
  2660. Escaped special chars are unescaped.
  2661. The input and output RDN values are not NULL terminated.
  2662. Arguments:
  2663. cQuotedRdnValueLength - The length of psQuotedRdnValue in chars.
  2664. psQuotedRdnValue - RDN value that may be quoted and may be escaped.
  2665. pcUnquotedRdnValueLength - IN, maximum length of psUnquotedRdnValue, in chars
  2666. OUT ERROR_SUCCESS, chars used in psUnquotedRdnValue
  2667. OUT ERROR_BUFFER_OVERFLOW, chars needed for psUnquotedRdnValue
  2668. psUnquotedRdnValue - The resultant unquoted RDN value.
  2669. Return Value:
  2670. ERROR_SUCCESS
  2671. psUnquotedRdnValue contains the unquoted and unescaped version
  2672. of psQuotedRdnValue. pcUnquotedRdnValueLength contains the space
  2673. used, in chars.
  2674. ERROR_BUFFER_OVERFLOW
  2675. psUnquotedRdnValueLength contains the space needed, in chars,
  2676. to hold psUnquotedRdnValue.
  2677. ERROR_INVALID_PARAMETER
  2678. Invalid parameter.
  2679. ERROR_NOT_ENOUGH_MEMORY
  2680. Allocation error.
  2681. --*/
  2682. NTDSAPI
  2683. DWORD
  2684. WINAPI
  2685. DsUnquoteRdnValueW(
  2686. IN DWORD cQuotedRdnValueLength,
  2687. IN LPCWCH psQuotedRdnValue,
  2688. IN OUT DWORD *pcUnquotedRdnValueLength,
  2689. OUT LPWCH psUnquotedRdnValue
  2690. );
  2691. NTDSAPI
  2692. DWORD
  2693. WINAPI
  2694. DsUnquoteRdnValueA(
  2695. IN DWORD cQuotedRdnValueLength,
  2696. IN LPCCH psQuotedRdnValue,
  2697. IN OUT DWORD *pcUnquotedRdnValueLength,
  2698. OUT LPCH psUnquotedRdnValue
  2699. );
  2700. #ifdef UNICODE
  2701. #define DsUnquoteRdnValue DsUnquoteRdnValueW
  2702. #else
  2703. #define DsUnquoteRdnValue DsUnquoteRdnValueA
  2704. #endif
  2705. /*++
  2706. ==========================================================
  2707. NTDSAPI
  2708. DWORD
  2709. WINAPI
  2710. DsGetRdnW(
  2711. IN OUT LPCWCH *ppDN,
  2712. IN OUT DWORD *pcDN,
  2713. OUT LPCWCH *ppKey,
  2714. OUT DWORD *pcKey,
  2715. OUT LPCWCH *ppVal,
  2716. OUT DWORD *pcVal
  2717. )
  2718. Description
  2719. This client call accepts a DN with quoted RDNs and returns the address
  2720. and length, in chars, of the key and value for the first RDN in the DN.
  2721. The RDN value returned is still quoted. Use DsUnquoteRdnValue to unquote
  2722. the value for display.
  2723. This client call also returns the address and length of the rest of the
  2724. DN. A subsequent call using the returned DN address and length will
  2725. return information about the next RDN.
  2726. The following loop processes each RDN in pDN:
  2727. ccDN = wcslen(pDN)
  2728. while (ccDN) {
  2729. error = DsGetRdn(&pDN,
  2730. &ccDN,
  2731. &pKey,
  2732. &ccKey,
  2733. &pVal,
  2734. &ccVal);
  2735. if (error != ERROR_SUCCESS) {
  2736. process error;
  2737. return;
  2738. }
  2739. if (ccKey) {
  2740. process pKey;
  2741. }
  2742. if (ccVal) {
  2743. process pVal;
  2744. }
  2745. }
  2746. For example, given the DN "cn=bob,dc=com", the first call to DsGetRdnW
  2747. returns the addresses for ",dc=com", "cn", and "bob" with respective
  2748. lengths of 7, 2, and 3. A subsequent call with ",dc=com" returns "",
  2749. "dc", and "com" with respective lengths 0, 2, and 3.
  2750. Arguments:
  2751. ppDN
  2752. IN : *ppDN points to a DN
  2753. OUT: *ppDN points to the rest of the DN following the first RDN
  2754. pcDN
  2755. IN : *pcDN is the count of chars in the input *ppDN, not including
  2756. any terminating NULL
  2757. OUT: *pcDN is the count of chars in the output *ppDN, not including
  2758. any terminating NULL
  2759. ppKey
  2760. OUT: Undefined if *pcKey is 0. Otherwise, *ppKey points to the first
  2761. key in the DN
  2762. pcKey
  2763. OUT: *pcKey is the count of chars in *ppKey.
  2764. ppVal
  2765. OUT: Undefined if *pcVal is 0. Otherwise, *ppVal points to the first
  2766. value in the DN
  2767. pcVal
  2768. OUT: *pcVal is the count of chars in *ppVal
  2769. Return Value:
  2770. ERROR_SUCCESS
  2771. If *pccDN is not 0, then *ppDN points to the rest of the DN following
  2772. the first RDN. If *pccDN is 0, then *ppDN is undefined.
  2773. If *pccKey is not 0, then *ppKey points to the first key in DN. If
  2774. *pccKey is 0, then *ppKey is undefined.
  2775. If *pccVal is not 0, then *ppVal points to the first value in DN. If
  2776. *pccVal is 0, then *ppVal is undefined.
  2777. ERROR_DS_NAME_UNPARSEABLE
  2778. The first RDN in *ppDN could not be parsed. All output parameters
  2779. are undefined.
  2780. Any other error
  2781. All output parameters are undefined.
  2782. --*/
  2783. NTDSAPI
  2784. DWORD
  2785. WINAPI
  2786. DsGetRdnW(
  2787. IN OUT LPCWCH *ppDN,
  2788. IN OUT DWORD *pcDN,
  2789. OUT LPCWCH *ppKey,
  2790. OUT DWORD *pcKey,
  2791. OUT LPCWCH *ppVal,
  2792. OUT DWORD *pcVal
  2793. );
  2794. /*++
  2795. ==========================================================
  2796. NTDSAPI
  2797. BOOL
  2798. WINAPI
  2799. DsCrackUnquotedMangledRdnW(
  2800. IN LPCWSTR pszRDN,
  2801. IN DWORD cchRDN,
  2802. OUT OPTIONAL GUID *pGuid,
  2803. OUT OPTIONAL DS_MANGLE_FOR *peDsMangleFor
  2804. );
  2805. Description
  2806. Determine whether the given RDN is in mangled form. If so, the mangled RDN
  2807. is decoded, and the guid and mangle type are returned.
  2808. The RDN should already be in unquoted form. See DsUnquoteRdnValue.
  2809. Arguments:
  2810. pszRDN (IN) - Character string containing RDN. Termination is optional.
  2811. cchRDN (IN) - Length of RDN excluding termination, if any
  2812. pGuid (OUT, OPTIONAL) - Pointer to storage to receive decoded guid.
  2813. Only returned if RDN is mangled.
  2814. peDsMangleFor (OUT, OPTIONAL) - Pointer to storage to receive mangle type.
  2815. Only returned if RDN is mangled
  2816. Return Value:
  2817. BOOL - Whether the RDN is mangled or not
  2818. --*/
  2819. NTDSAPI
  2820. BOOL
  2821. WINAPI
  2822. DsCrackUnquotedMangledRdnW(
  2823. IN LPCWSTR pszRDN,
  2824. IN DWORD cchRDN,
  2825. OUT OPTIONAL GUID *pGuid,
  2826. OUT OPTIONAL DS_MANGLE_FOR *peDsMangleFor
  2827. );
  2828. NTDSAPI
  2829. BOOL
  2830. WINAPI
  2831. DsCrackUnquotedMangledRdnA(
  2832. IN LPCSTR pszRDN,
  2833. IN DWORD cchRDN,
  2834. OUT OPTIONAL GUID *pGuid,
  2835. OUT OPTIONAL DS_MANGLE_FOR *peDsMangleFor
  2836. );
  2837. #ifdef UNICODE
  2838. #define DsCrackUnquotedMangledRdn DsCrackUnquotedMangledRdnW
  2839. #else
  2840. #define DsCrackUnquotedMangledRdn DsCrackUnquotedMangledRdnA
  2841. #endif
  2842. /*++
  2843. ==========================================================
  2844. NTDSAPI
  2845. BOOL
  2846. WINAPI
  2847. DsIsMangledRdnValueW(
  2848. LPCWSTR pszRdn,
  2849. DWORD cRdn,
  2850. DS_MANGLE_FOR eDsMangleForDesired
  2851. );
  2852. Description
  2853. Determine if the given RDN Value is mangled, and of the given type. Note that
  2854. the key portion of an RDN should not be supplied.
  2855. The name may be quoted or unquoted. This routine tries to unquote the value. If
  2856. the unquote operation fails, the routine proceeds to attempt the unmangle.
  2857. A change was made in the default quoting behavior of DNs returned from the DS
  2858. between Windows 2000 and Windows XP. This routine transparently handles RDNs with
  2859. special characters in either form.
  2860. The routine expects the value part of the RDN.
  2861. If you have full DN, use DsIsMangledDn() below.
  2862. To check for deleted name:
  2863. DsIsMangledRdnValueW( rdn, rdnlen, DS_MANGLE_OBJECT_FOR_DELETION )
  2864. To check for a conflicted name:
  2865. DsIsMangledRdnValueW( rdn, rdnlen, DS_MANGLE_OBJECT_FOR_NAME_CONFLICT )
  2866. Arguments:
  2867. pszRdn (IN) - RDN value character string. Termination is not required and
  2868. is ignored.
  2869. cRdn (IN) - Length of RDN value in characters excluding termination
  2870. eDsMangleForDesired (IN) - Type of mangling to check for
  2871. Return Value:
  2872. BOOL - True if the Rdn is mangled and is of the required type
  2873. --*/
  2874. NTDSAPI
  2875. BOOL
  2876. WINAPI
  2877. DsIsMangledRdnValueW(
  2878. LPCWSTR pszRdn,
  2879. DWORD cRdn,
  2880. DS_MANGLE_FOR eDsMangleForDesired
  2881. );
  2882. NTDSAPI
  2883. BOOL
  2884. WINAPI
  2885. DsIsMangledRdnValueA(
  2886. LPCSTR pszRdn,
  2887. DWORD cRdn,
  2888. DS_MANGLE_FOR eDsMangleForDesired
  2889. );
  2890. #ifdef UNICODE
  2891. #define DsIsMangledRdnValue DsIsMangledRdnValueW
  2892. #else
  2893. #define DsIsMangledRdnValue DsIsMangledRdnValueA
  2894. #endif
  2895. /*++
  2896. ==========================================================
  2897. NTDSAPI
  2898. BOOL
  2899. WINAPI
  2900. DsIsMangledDnW(
  2901. LPCWSTR pszDn,
  2902. DS_MANGLE_FOR eDsMangleFor
  2903. );
  2904. Description
  2905. Determine if the first RDN in a quoted DN is a mangled name of given type.
  2906. The DN must be suitable for input to DsGetRdn().
  2907. To check for deleted name:
  2908. DsIsMangledDnW( dn, DS_MANGLE_OBJECT_FOR_DELETION )
  2909. To check for a conflicted name:
  2910. DsIsMangledDnW( Dn, DS_MANGLE_OBJECT_FOR_NAME_CONFLICT )
  2911. Arguments:
  2912. pszDn (IN) - Quoted Distinguished Name as returned by DS functions
  2913. eDsMangleFor (IN) - Type of mangling to check for
  2914. Return Value:
  2915. BOOL - True if first RDN is mangled and is of the given mangle type
  2916. --*/
  2917. NTDSAPI
  2918. BOOL
  2919. WINAPI
  2920. DsIsMangledDnA(
  2921. LPCSTR pszDn,
  2922. DS_MANGLE_FOR eDsMangleFor
  2923. );
  2924. NTDSAPI
  2925. BOOL
  2926. WINAPI
  2927. DsIsMangledDnW(
  2928. LPCWSTR pszDn,
  2929. DS_MANGLE_FOR eDsMangleFor
  2930. );
  2931. #ifdef UNICODE
  2932. #define DsIsMangledDn DsIsMangledDnW
  2933. #else
  2934. #define DsIsMangledDn DsIsMangledDnA
  2935. #endif
  2936. #ifdef __cplusplus
  2937. }
  2938. #endif
  2939. #endif !MIDL_PASS
  2940. #endif // _NTDSAPI_H_