Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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