PageRenderTime 54ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 1ms

/packages/winunits-jedi/src/jwantdsapi.pas

https://github.com/slibre/freepascal
Pascal | 5268 lines | 2848 code | 687 blank | 1733 comment | 1 complexity | 2fa5e6104dbfdbaeef6739aea0fb8c06 MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. {******************************************************************************}
  2. { }
  3. { DC and Replication Management API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: ntdsapi.h, released June 2000. The original Pascal }
  9. { code is: NtDsApi.pas, released December 2000. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  16. { }
  17. { You may retrieve the latest version of this file at the Project JEDI }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. // $Id: JwaNtDsApi.pas,v 1.12 2007/09/05 11:58:51 dezipaitor Exp $
  43. {$IFNDEF JWA_OMIT_SECTIONS}
  44. unit JwaNtDsApi;
  45. {$WEAKPACKAGEUNIT}
  46. {$ENDIF JWA_OMIT_SECTIONS}
  47. {$HPPEMIT ''}
  48. {$HPPEMIT '#include "ntdsapi.h"'}
  49. {$HPPEMIT ''}
  50. {$HPPEMIT 'typedef PDS_REPSYNCALL_ERRINFOW *PPDS_REPSYNCALL_ERRINFOW'}
  51. {$HPPEMIT 'typedef PDS_REPSYNCALL_ERRINFOA *PPDS_REPSYNCALL_ERRINFOA'}
  52. {$HPPEMIT '#ifdef UNICODE'}
  53. {$HPPEMIT 'typedef PPDS_REPSYNCALL_ERRINFOW PPDS_REPSYNCALL_ERRINFO'}
  54. {$HPPEMIT '#else'}
  55. {$HPPEMIT 'typedef PPDS_REPSYNCALL_ERRINFOA PPDS_REPSYNCALL_ERRINFO'}
  56. {$HPPEMIT '#endif'}
  57. {$HPPEMIT ''}
  58. {$IFNDEF JWA_OMIT_SECTIONS}
  59. {$I jediapilib.inc}
  60. interface
  61. uses
  62. JwaWinBase, JwaWinType, JwaWinNT, JwaWinNLS, JwaRpcDce, JwaSchedule;
  63. {$ENDIF JWA_OMIT_SECTIONS}
  64. {$IFNDEF JWA_IMPLEMENTATIONSECTION}
  65. //////////////////////////////////////////////////////////////////////////
  66. // //
  67. // Data definitions //
  68. // //
  69. //////////////////////////////////////////////////////////////////////////
  70. // Following constants define the Active Directory Behavior
  71. // Version numbers.
  72. const
  73. DS_BEHAVIOR_WIN2000 = 0;
  74. {$EXTERNALSYM DS_BEHAVIOR_WIN2000}
  75. DS_BEHAVIOR_WIN_DOT_NET_WITH_MIXED_DOMAINS = 1;
  76. {$EXTERNALSYM DS_BEHAVIOR_WIN_DOT_NET_WITH_MIXED_DOMAINS}
  77. DS_BEHAVIOR_WIN_DOT_NET = 2;
  78. {$EXTERNALSYM DS_BEHAVIOR_WIN_DOT_NET}
  79. // (MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT))
  80. DS_DEFAULT_LOCALE = DWORD((DWORD(SORT_DEFAULT) shl 16) or ((SUBLANG_ENGLISH_US shl 10) or LANG_ENGLISH));
  81. {$EXTERNALSYM DS_DEFAULT_LOCALE}
  82. DS_DEFAULT_LOCALE_COMPARE_FLAGS = (NORM_IGNORECASE or NORM_IGNOREKANATYPE or
  83. NORM_IGNORENONSPACE or NORM_IGNOREWIDTH or SORT_STRINGSORT);
  84. {$EXTERNALSYM DS_DEFAULT_LOCALE_COMPARE_FLAGS}
  85. // When booted to DS mode, this event is signalled when the DS has completed
  86. // its initial sync attempts. The period of time between system startup and
  87. // this event's state being set is indeterminate from the local service's
  88. // standpoint. In the meantime the contents of the DS should be considered
  89. // incomplete / out-dated, and the machine will not be advertised as a domain
  90. // controller to off-machine clients. Other local services that rely on
  91. // information published in the DS should avoid accessing (or at least
  92. // relying on) the contents of the DS until this event is set.
  93. DS_SYNCED_EVENT_NAME = 'NTDSInitialSyncsCompleted';
  94. {$EXTERNALSYM DS_SYNCED_EVENT_NAME}
  95. DS_SYNCED_EVENT_NAME_W = 'NTDSInitialSyncsCompleted';
  96. {$EXTERNALSYM DS_SYNCED_EVENT_NAME_W}
  97. {$IFNDEF JWA_INCLUDEMODE}
  98. // Permissions bits used in security descriptors in the directory.
  99. ACTRL_DS_OPEN = $00000000;
  100. {$EXTERNALSYM ACTRL_DS_OPEN}
  101. ACTRL_DS_CREATE_CHILD = $00000001;
  102. {$EXTERNALSYM ACTRL_DS_CREATE_CHILD}
  103. ACTRL_DS_DELETE_CHILD = $00000002;
  104. {$EXTERNALSYM ACTRL_DS_DELETE_CHILD}
  105. ACTRL_DS_LIST = $00000004;
  106. {$EXTERNALSYM ACTRL_DS_LIST}
  107. ACTRL_DS_SELF = $00000008;
  108. {$EXTERNALSYM ACTRL_DS_SELF}
  109. ACTRL_DS_READ_PROP = $00000010;
  110. {$EXTERNALSYM ACTRL_DS_READ_PROP}
  111. ACTRL_DS_WRITE_PROP = $00000020;
  112. {$EXTERNALSYM ACTRL_DS_WRITE_PROP}
  113. ACTRL_DS_DELETE_TREE = $00000040;
  114. {$EXTERNALSYM ACTRL_DS_DELETE_TREE}
  115. ACTRL_DS_LIST_OBJECT = $00000080;
  116. {$EXTERNALSYM ACTRL_DS_LIST_OBJECT}
  117. ACTRL_DS_CONTROL_ACCESS = $00000100;
  118. {$EXTERNALSYM ACTRL_DS_CONTROL_ACCESS}
  119. {$ENDIF JWA_INCLUDEMODE}
  120. // generic read
  121. DS_GENERIC_READ = STANDARD_RIGHTS_READ or ACTRL_DS_LIST or ACTRL_DS_READ_PROP or
  122. ACTRL_DS_LIST_OBJECT;
  123. {$EXTERNALSYM DS_GENERIC_READ}
  124. // generic execute
  125. DS_GENERIC_EXECUTE = STANDARD_RIGHTS_EXECUTE or ACTRL_DS_LIST;
  126. {$EXTERNALSYM DS_GENERIC_EXECUTE}
  127. // generic right
  128. DS_GENERIC_WRITE = STANDARD_RIGHTS_WRITE or ACTRL_DS_SELF or ACTRL_DS_WRITE_PROP;
  129. {$EXTERNALSYM DS_GENERIC_WRITE}
  130. // generic all
  131. DS_GENERIC_ALL = STANDARD_RIGHTS_REQUIRED or ACTRL_DS_CREATE_CHILD or
  132. ACTRL_DS_DELETE_CHILD or ACTRL_DS_DELETE_TREE or ACTRL_DS_READ_PROP or
  133. ACTRL_DS_WRITE_PROP or ACTRL_DS_LIST or ACTRL_DS_LIST_OBJECT or
  134. ACTRL_DS_CONTROL_ACCESS or ACTRL_DS_SELF;
  135. {$EXTERNALSYM DS_GENERIC_ALL}
  136. type
  137. DS_NAME_FORMAT = (
  138. // unknown name type
  139. DS_UNKNOWN_NAME,
  140. // eg: CN=User Name,OU=Users,DC=Example,DC=Microsoft,DC=Com
  141. DS_FQDN_1779_NAME,
  142. // eg: Exmaple\UserName
  143. // Domain-only version includes trailing '\\'.
  144. DS_NT4_ACCOUNT_NAME,
  145. // Probably "User Name" but could be something else. I.e. The
  146. // display name is not necessarily the defining RDN.
  147. DS_DISPLAY_NAME,
  148. // obsolete - see #define later
  149. // DS_DOMAIN_SIMPLE_NAME,
  150. DS_STUB_4,
  151. // obsolete - see #define later
  152. // DS_ENTERPRISE_SIMPLE_NAME,
  153. DS_STUB_5,
  154. // String-ized GUID as returned by IIDFromString().
  155. // eg: {4fa050f0-f561-11cf-bdd9-00aa003a77b6}
  156. DS_UNIQUE_ID_NAME,
  157. // eg: example.microsoft.com/software/user name
  158. // Domain-only version includes trailing '/'.
  159. DS_CANONICAL_NAME,
  160. // eg: usern@example.microsoft.com
  161. DS_USER_PRINCIPAL_NAME,
  162. // Same as DS_CANONICAL_NAME except that rightmost '/' is
  163. // replaced with '\n' - even in domain-only case.
  164. // eg: example.microsoft.com/software\nuser name
  165. DS_CANONICAL_NAME_EX,
  166. // eg: www/www.microsoft.com@example.com - generalized service principal
  167. // names.
  168. DS_SERVICE_PRINCIPAL_NAME,
  169. // This is the string representation of a SID. Invalid for formatDesired.
  170. // See sddl.h for SID binary <--> text conversion routines.
  171. // eg: S-1-5-21-397955417-626881126-188441444-501
  172. DS_SID_OR_SID_HISTORY_NAME,
  173. // Pseudo-name format so GetUserNameEx can return the DNS domain name to
  174. // a caller. This level is not supported by the DS APIs.
  175. DS_DNS_DOMAIN_NAME);
  176. {$EXTERNALSYM DS_NAME_FORMAT}
  177. TDsNameFormat = DS_NAME_FORMAT;
  178. // Map old name formats to closest new format so that old code builds
  179. // against new headers w/o errors and still gets (almost) correct result.
  180. const
  181. DS_DOMAIN_SIMPLE_NAME = DS_USER_PRINCIPAL_NAME;
  182. {$EXTERNALSYM DS_DOMAIN_SIMPLE_NAME}
  183. DS_ENTERPRISE_SIMPLE_NAME = DS_USER_PRINCIPAL_NAME;
  184. {$EXTERNALSYM DS_ENTERPRISE_SIMPLE_NAME}
  185. type
  186. DS_NAME_FLAGS = DWORD;
  187. {$EXTERNALSYM DS_NAME_FLAGS}
  188. TDsNameFlags = DS_NAME_FLAGS;
  189. const
  190. DS_NAME_NO_FLAGS = $0;
  191. {$EXTERNALSYM DS_NAME_NO_FLAGS}
  192. // Perform a syntactical mapping at the client (if possible) without
  193. // going out on the wire. Returns DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING
  194. // if a purely syntactical mapping is not possible.
  195. DS_NAME_FLAG_SYNTACTICAL_ONLY = $1;
  196. {$EXTERNALSYM DS_NAME_FLAG_SYNTACTICAL_ONLY}
  197. // Force a trip to the DC for evaluation, even if this could be
  198. // locally cracked syntactically.
  199. DS_NAME_FLAG_EVAL_AT_DC = $2;
  200. {$EXTERNALSYM DS_NAME_FLAG_EVAL_AT_DC}
  201. // The call fails if the DC is not a GC
  202. DS_NAME_FLAG_GCVERIFY = $4;
  203. {$EXTERNALSYM DS_NAME_FLAG_GCVERIFY}
  204. // Enable cross forest trust referral
  205. DS_NAME_FLAG_TRUST_REFERRAL = $8;
  206. {$EXTERNALSYM DS_NAME_FLAG_TRUST_REFERRAL}
  207. type
  208. DS_NAME_ERROR = (
  209. DS_NAME_NO_ERROR,
  210. // Generic processing error.
  211. DS_NAME_ERROR_RESOLVING,
  212. // Couldn't find the name at all - or perhaps caller doesn't have
  213. // rights to see it.
  214. DS_NAME_ERROR_NOT_FOUND,
  215. // Input name mapped to more than one output name.
  216. DS_NAME_ERROR_NOT_UNIQUE,
  217. // Input name found, but not the associated output format.
  218. // Can happen if object doesn't have all the required attributes.
  219. DS_NAME_ERROR_NO_MAPPING,
  220. // Unable to resolve entire name, but was able to determine which
  221. // domain object resides in. Thus DS_NAME_RESULT_ITEM?.pDomain
  222. // is valid on return.
  223. DS_NAME_ERROR_DOMAIN_ONLY,
  224. // Unable to perform a purely syntactical mapping at the client
  225. // without going out on the wire.
  226. DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING,
  227. // The name is from an external trusted forest.
  228. DS_NAME_ERROR_TRUST_REFERRAL);
  229. {$EXTERNALSYM DS_NAME_ERROR}
  230. TDsNameError = DS_NAME_ERROR;
  231. const
  232. DS_NAME_LEGAL_FLAGS = DS_NAME_FLAG_SYNTACTICAL_ONLY;
  233. {$EXTERNALSYM DS_NAME_LEGAL_FLAGS}
  234. type
  235. DS_SPN_NAME_TYPE = (
  236. // "paulle-nec.ntwksta.ms.com"
  237. DS_SPN_DNS_HOST,
  238. // "cn=paulle-nec,ou=computers,dc=ntwksta,dc=ms,dc=com"
  239. DS_SPN_DN_HOST,
  240. // "paulle-nec"
  241. DS_SPN_NB_HOST,
  242. // "ntdev.ms.com"
  243. DS_SPN_DOMAIN,
  244. // "ntdev"
  245. DS_SPN_NB_DOMAIN,
  246. // "cn=anRpcService,cn=RPC Services,cn=system,dc=ms,dc=com"
  247. // "cn=aWsService,cn=Winsock Services,cn=system,dc=ms,dc=com"
  248. // "cn=aService,dc=itg,dc=ms,dc=com"
  249. // "www.ms.com", "ftp.ms.com", "ldap.ms.com"
  250. // "products.ms.com"
  251. DS_SPN_SERVICE);
  252. {$EXTERNALSYM DS_SPN_NAME_TYPE}
  253. TDsSpnNameType = DS_SPN_NAME_TYPE;
  254. DS_SPN_WRITE_OP = (
  255. DS_SPN_ADD_SPN_OP, // add SPNs
  256. DS_SPN_REPLACE_SPN_OP, // set all SPNs
  257. DS_SPN_DELETE_SPN_OP); // Delete SPNs
  258. {$EXTERNALSYM DS_SPN_WRITE_OP}
  259. TDsSpnWriteOp = DS_SPN_WRITE_OP;
  260. PDS_NAME_RESULT_ITEMA = ^DS_NAME_RESULT_ITEMA;
  261. {$EXTERNALSYM PDS_NAME_RESULT_ITEMA}
  262. DS_NAME_RESULT_ITEMA = record
  263. status: DWORD; // DS_NAME_ERROR
  264. pDomain: LPSTR; // DNS domain
  265. pName: LPSTR; // name in requested format
  266. end;
  267. {$EXTERNALSYM DS_NAME_RESULT_ITEMA}
  268. TDsNameResultItemA = DS_NAME_RESULT_ITEMA;
  269. PDsNameResultItemA = PDS_NAME_RESULT_ITEMA;
  270. PDS_NAME_RESULTA = ^DS_NAME_RESULTA;
  271. {$EXTERNALSYM PDS_NAME_RESULTA}
  272. DS_NAME_RESULTA = record
  273. cItems: DWORD; // item count
  274. rItems: PDS_NAME_RESULT_ITEMA; // item array
  275. end;
  276. {$EXTERNALSYM DS_NAME_RESULTA}
  277. TDsNameResultA = DS_NAME_RESULTA;
  278. PDsNameResultA = PDS_NAME_RESULTA;
  279. PDS_NAME_RESULT_ITEMW = ^DS_NAME_RESULT_ITEMW;
  280. {$EXTERNALSYM PDS_NAME_RESULT_ITEMW}
  281. DS_NAME_RESULT_ITEMW = record
  282. status: DWORD; // DS_NAME_ERROR
  283. pDomain: LPWSTR; // DNS domain
  284. pName: LPWSTR; // name in requested format
  285. end;
  286. {$EXTERNALSYM DS_NAME_RESULT_ITEMW}
  287. TDsNameResultItemW = DS_NAME_RESULT_ITEMW;
  288. PDsNameResultItemW = PDS_NAME_RESULT_ITEMW;
  289. PDS_NAME_RESULTW = ^DS_NAME_RESULTW;
  290. {$EXTERNALSYM PDS_NAME_RESULTW}
  291. DS_NAME_RESULTW = record
  292. cItems: DWORD; // item count
  293. rItems: PDS_NAME_RESULT_ITEMW; // item array
  294. end;
  295. {$EXTERNALSYM DS_NAME_RESULTW}
  296. TDsNameResultW = DS_NAME_RESULTW;
  297. PDsNameResultW = PDS_NAME_RESULTW;
  298. {$IFDEF UNICODE}
  299. DS_NAME_RESULT = DS_NAME_RESULTW;
  300. {$EXTERNALSYM DS_NAME_RESULT}
  301. PDS_NAME_RESULT = PDS_NAME_RESULTW;
  302. {$EXTERNALSYM PDS_NAME_RESULT}
  303. DS_NAME_RESULT_ITEM = DS_NAME_RESULT_ITEMW;
  304. {$EXTERNALSYM DS_NAME_RESULT_ITEM}
  305. PDS_NAME_RESULT_ITEM = PDS_NAME_RESULT_ITEMW;
  306. {$EXTERNALSYM PDS_NAME_RESULT_ITEM}
  307. TDsNameResult = TDsNameResultW;
  308. PDsNameResult = PDsNameResultW;
  309. TDsNameResultItem = TDsNameResultItemW;
  310. PDsNameResultItem = PDsNameResultItemW;
  311. {$ELSE}
  312. DS_NAME_RESULT = DS_NAME_RESULTA;
  313. {$EXTERNALSYM DS_NAME_RESULT}
  314. PDS_NAME_RESULT = PDS_NAME_RESULTA;
  315. {$EXTERNALSYM PDS_NAME_RESULT}
  316. DS_NAME_RESULT_ITEM = DS_NAME_RESULT_ITEMA;
  317. {$EXTERNALSYM DS_NAME_RESULT_ITEM}
  318. PDS_NAME_RESULT_ITEM = PDS_NAME_RESULT_ITEMA;
  319. {$EXTERNALSYM PDS_NAME_RESULT_ITEM}
  320. TDsNameResult = TDsNameResultA;
  321. PDsNameResult = PDsNameResultA;
  322. TDsNameResultItem = TDsNameResultItemA;
  323. PDsNameResultItem = PDsNameResultItemA;
  324. {$ENDIF UNICODE}
  325. // Public replication option flags
  326. // ********************
  327. // DsBindWithSpnEx flags
  328. // ********************
  329. // Allow the Bind to use delegate service level, so that you can
  330. // do ntdsapi operations that require delegation, such as
  331. // DsAddSidHistory, and DsReplicaSyncAll(). Most operations do
  332. // not require DELEGATE so this flag should only be specified
  333. // if you need it, because if you bind to a rogue server with
  334. // the DELEGATE flag, you'll allow the rogue server to use your
  335. // credentials to connect back to a non-rogue server and perform
  336. // operations other than you intended.
  337. const
  338. NTDSAPI_BIND_ALLOW_DELEGATION = $00000001;
  339. {$EXTERNALSYM NTDSAPI_BIND_ALLOW_DELEGATION}
  340. // ********************
  341. // Replica Sync flags
  342. // These flag values are used both as input to DsReplicaSync and
  343. // as output from DsReplicaGetInfo, PENDING_OPS, DS_REPL_OPW.ulOptions
  344. // ********************
  345. // Perform this operation asynchronously.
  346. // Required when using DS_REPSYNC_ALL_SOURCES
  347. const
  348. DS_REPSYNC_ASYNCHRONOUS_OPERATION = $00000001;
  349. {$EXTERNALSYM DS_REPSYNC_ASYNCHRONOUS_OPERATION}
  350. // Writeable replica. Otherwise, read-only.
  351. DS_REPSYNC_WRITEABLE = $00000002;
  352. {$EXTERNALSYM DS_REPSYNC_WRITEABLE}
  353. // This is a periodic sync request as scheduled by the admin.
  354. DS_REPSYNC_PERIODIC = $00000004;
  355. {$EXTERNALSYM DS_REPSYNC_PERIODIC}
  356. // Use inter-site messaging
  357. DS_REPSYNC_INTERSITE_MESSAGING = $00000008;
  358. {$EXTERNALSYM DS_REPSYNC_INTERSITE_MESSAGING}
  359. // Sync from all sources.
  360. DS_REPSYNC_ALL_SOURCES = $00000010;
  361. {$EXTERNALSYM DS_REPSYNC_ALL_SOURCES}
  362. // Sync starting from scratch (i.e., at the first USN).
  363. DS_REPSYNC_FULL = $00000020;
  364. {$EXTERNALSYM DS_REPSYNC_FULL}
  365. // This is a notification of an update that was marked urgent.
  366. DS_REPSYNC_URGENT = $00000040;
  367. {$EXTERNALSYM DS_REPSYNC_URGENT}
  368. // Don't discard this synchronization request, even if a similar
  369. // sync is pending.
  370. DS_REPSYNC_NO_DISCARD = $00000080;
  371. {$EXTERNALSYM DS_REPSYNC_NO_DISCARD}
  372. // Sync even if link is currently disabled.
  373. DS_REPSYNC_FORCE = $00000100;
  374. {$EXTERNALSYM DS_REPSYNC_FORCE}
  375. // Causes the source DSA to check if a reps-to is present for the local DSA
  376. // (aka the destination). If not, one is added. This ensures that
  377. // source sends change notifications.
  378. DS_REPSYNC_ADD_REFERENCE = $00000200;
  379. {$EXTERNALSYM DS_REPSYNC_ADD_REFERENCE}
  380. // A sync from this source has never completed (e.g., a new source).
  381. DS_REPSYNC_NEVER_COMPLETED = $00000400;
  382. {$EXTERNALSYM DS_REPSYNC_NEVER_COMPLETED}
  383. // When this sync is complete, requests a sync in the opposite direction.
  384. DS_REPSYNC_TWO_WAY = $00000800;
  385. {$EXTERNALSYM DS_REPSYNC_TWO_WAY}
  386. // Do not request change notifications from this source.
  387. DS_REPSYNC_NEVER_NOTIFY = $00001000;
  388. {$EXTERNALSYM DS_REPSYNC_NEVER_NOTIFY}
  389. // Sync the NC from this source when the DSA is started.
  390. DS_REPSYNC_INITIAL = $00002000;
  391. {$EXTERNALSYM DS_REPSYNC_INITIAL}
  392. // Use compression when replicating. Saves message size (e.g., network
  393. // bandwidth) at the expense of extra CPU overhead at both the source and
  394. // destination servers.
  395. DS_REPSYNC_USE_COMPRESSION = $00004000;
  396. {$EXTERNALSYM DS_REPSYNC_USE_COMPRESSION}
  397. // Sync was abandoned for lack of updates
  398. DS_REPSYNC_ABANDONED = $00008000;
  399. {$EXTERNALSYM DS_REPSYNC_ABANDONED}
  400. // Initial sync in progress
  401. DS_REPSYNC_INITIAL_IN_PROGRESS = $00010000;
  402. {$EXTERNALSYM DS_REPSYNC_INITIAL_IN_PROGRESS}
  403. // Partial Attribute Set sync in progress
  404. DS_REPSYNC_PARTIAL_ATTRIBUTE_SET = $00020000;
  405. {$EXTERNALSYM DS_REPSYNC_PARTIAL_ATTRIBUTE_SET}
  406. // Sync is being retried
  407. DS_REPSYNC_REQUEUE = $00040000;
  408. {$EXTERNALSYM DS_REPSYNC_REQUEUE}
  409. // Sync is a notification request from a source
  410. DS_REPSYNC_NOTIFICATION = $00080000;
  411. {$EXTERNALSYM DS_REPSYNC_NOTIFICATION}
  412. // Sync is a special form which requests to establish contact
  413. // now and do the rest of the sync later
  414. DS_REPSYNC_ASYNCHRONOUS_REPLICA = $00100000;
  415. {$EXTERNALSYM DS_REPSYNC_ASYNCHRONOUS_REPLICA}
  416. // Request critical objects only
  417. DS_REPSYNC_CRITICAL = $00200000;
  418. {$EXTERNALSYM DS_REPSYNC_CRITICAL}
  419. // A full synchronization is in progress
  420. DS_REPSYNC_FULL_IN_PROGRESS = $00400000;
  421. {$EXTERNALSYM DS_REPSYNC_FULL_IN_PROGRESS}
  422. // Synchronization request was previously preempted
  423. DS_REPSYNC_PREEMPTED = $00800000;
  424. {$EXTERNALSYM DS_REPSYNC_PREEMPTED}
  425. // ********************
  426. // Replica Add flags
  427. // ********************
  428. // Perform this operation asynchronously.
  429. DS_REPADD_ASYNCHRONOUS_OPERATION = $00000001;
  430. {$EXTERNALSYM DS_REPADD_ASYNCHRONOUS_OPERATION}
  431. // Create a writeable replica. Otherwise, read-only.
  432. DS_REPADD_WRITEABLE = $00000002;
  433. {$EXTERNALSYM DS_REPADD_WRITEABLE}
  434. // Sync the NC from this source when the DSA is started.
  435. DS_REPADD_INITIAL = $00000004;
  436. {$EXTERNALSYM DS_REPADD_INITIAL}
  437. // Sync the NC from this source periodically, as defined by the
  438. // schedule passed in the preptimesSync argument.
  439. DS_REPADD_PERIODIC = $00000008;
  440. {$EXTERNALSYM DS_REPADD_PERIODIC}
  441. // Sync from the source DSA via an Intersite Messaging Service (ISM) transport
  442. // (e.g., SMTP) rather than native DS RPC.
  443. DS_REPADD_INTERSITE_MESSAGING = $00000010;
  444. {$EXTERNALSYM DS_REPADD_INTERSITE_MESSAGING}
  445. // Don't replicate the NC now -- just save enough state such that we
  446. // know to replicate it later.
  447. DS_REPADD_ASYNCHRONOUS_REPLICA = $00000020;
  448. {$EXTERNALSYM DS_REPADD_ASYNCHRONOUS_REPLICA}
  449. // Disable notification-based synchronization for the NC from this source.
  450. // This is expected to be a temporary state; the similar flag
  451. // DS_REPADD_NEVER_NOTIFY should be used if the disable is to be more permanent.
  452. DS_REPADD_DISABLE_NOTIFICATION = $00000040;
  453. {$EXTERNALSYM DS_REPADD_DISABLE_NOTIFICATION}
  454. // Disable periodic synchronization for the NC from this source
  455. DS_REPADD_DISABLE_PERIODIC = $00000080;
  456. {$EXTERNALSYM DS_REPADD_DISABLE_PERIODIC}
  457. // Use compression when replicating. Saves message size (e.g., network
  458. // bandwidth) at the expense of extra CPU overhead at both the source and
  459. // destination servers.
  460. DS_REPADD_USE_COMPRESSION = $00000100;
  461. {$EXTERNALSYM DS_REPADD_USE_COMPRESSION}
  462. // Do not request change notifications from this source. When this flag is
  463. // set, the source will not notify the destination when changes occur.
  464. // Recommended for all intersite replication, which may occur over WAN links.
  465. // This is expected to be a more or less permanent state; the similar flag
  466. // DS_REPADD_DISABLE_NOTIFICATION should be used if notifications are to be
  467. // disabled only temporarily.
  468. DS_REPADD_NEVER_NOTIFY = $00000200;
  469. {$EXTERNALSYM DS_REPADD_NEVER_NOTIFY}
  470. // When this sync is complete, requests a sync in the opposite direction.
  471. DS_REPADD_TWO_WAY = $00000400;
  472. {$EXTERNALSYM DS_REPADD_TWO_WAY}
  473. // Request critical objects only
  474. // Critical only is only allowed while installing
  475. // A critical only sync does not bring all objects in the partition. It
  476. // replicates just the ones necessary for minimal directory operation.
  477. // A normal, non-critical sync must be performed before the partition
  478. // can be considered fully synchronized.
  479. DS_REPADD_CRITICAL = $00000800;
  480. {$EXTERNALSYM DS_REPADD_CRITICAL}
  481. // ********************
  482. // Replica Delete flags
  483. // ********************
  484. // Perform this operation asynchronously.
  485. DS_REPDEL_ASYNCHRONOUS_OPERATION = $00000001;
  486. {$EXTERNALSYM DS_REPDEL_ASYNCHRONOUS_OPERATION}
  487. // The replica being deleted is writeable.
  488. DS_REPDEL_WRITEABLE = $00000002;
  489. {$EXTERNALSYM DS_REPDEL_WRITEABLE}
  490. // Replica is a mail-based replica
  491. DS_REPDEL_INTERSITE_MESSAGING = $00000004;
  492. {$EXTERNALSYM DS_REPDEL_INTERSITE_MESSAGING}
  493. // Ignore any error generated by contacting the source to tell it to scratch
  494. // this server from its Reps-To for this NC.
  495. DS_REPDEL_IGNORE_ERRORS = $00000008;
  496. {$EXTERNALSYM DS_REPDEL_IGNORE_ERRORS}
  497. // Do not contact the source telling it to scratch this server from its
  498. // Rep-To for this NC. Otherwise, if the link is RPC-based, the source will
  499. // be contacted.
  500. DS_REPDEL_LOCAL_ONLY = $00000010;
  501. {$EXTERNALSYM DS_REPDEL_LOCAL_ONLY}
  502. // Delete all the objects in the NC
  503. // "No source" is incompatible with (and rejected for) writeable NCs. This is
  504. // valid only for read-only NCs, and then only if the NC has no source. This
  505. // can occur when the NC has been partially deleted (in which case the KCC
  506. // periodically calls the delete API with the "no source" flag set).
  507. DS_REPDEL_NO_SOURCE = $00000020;
  508. {$EXTERNALSYM DS_REPDEL_NO_SOURCE}
  509. // Allow deletion of read-only replica even if it sources
  510. // other read-only replicas.
  511. DS_REPDEL_REF_OK = $00000040;
  512. {$EXTERNALSYM DS_REPDEL_REF_OK}
  513. // ********************
  514. // Replica Modify flags
  515. // ********************
  516. // Perform this operation asynchronously.
  517. DS_REPMOD_ASYNCHRONOUS_OPERATION = $00000001;
  518. {$EXTERNALSYM DS_REPMOD_ASYNCHRONOUS_OPERATION}
  519. // The replica is writeable.
  520. DS_REPMOD_WRITEABLE = $00000002;
  521. {$EXTERNALSYM DS_REPMOD_WRITEABLE}
  522. // ********************
  523. // Replica Modify fields
  524. // ********************
  525. DS_REPMOD_UPDATE_FLAGS = $00000001;
  526. {$EXTERNALSYM DS_REPMOD_UPDATE_FLAGS}
  527. DS_REPMOD_UPDATE_ADDRESS = $00000002;
  528. {$EXTERNALSYM DS_REPMOD_UPDATE_ADDRESS}
  529. DS_REPMOD_UPDATE_SCHEDULE = $00000004;
  530. {$EXTERNALSYM DS_REPMOD_UPDATE_SCHEDULE}
  531. DS_REPMOD_UPDATE_RESULT = $00000008;
  532. {$EXTERNALSYM DS_REPMOD_UPDATE_RESULT}
  533. DS_REPMOD_UPDATE_TRANSPORT = $00000010;
  534. {$EXTERNALSYM DS_REPMOD_UPDATE_TRANSPORT}
  535. // ********************
  536. // Update Refs fields
  537. // ********************
  538. // Perform this operation asynchronously.
  539. DS_REPUPD_ASYNCHRONOUS_OPERATION = $00000001;
  540. {$EXTERNALSYM DS_REPUPD_ASYNCHRONOUS_OPERATION}
  541. // The replica being deleted is writeable.
  542. DS_REPUPD_WRITEABLE = $00000002;
  543. {$EXTERNALSYM DS_REPUPD_WRITEABLE}
  544. // Add a reference
  545. DS_REPUPD_ADD_REFERENCE = $00000004;
  546. {$EXTERNALSYM DS_REPUPD_ADD_REFERENCE}
  547. // Remove a reference
  548. DS_REPUPD_DELETE_REFERENCE = $00000008;
  549. {$EXTERNALSYM DS_REPUPD_DELETE_REFERENCE}
  550. // ********************
  551. // NC Related Flags
  552. // ********************
  553. //
  554. // Instance Type bits, specifies flags for NC head creation.
  555. //
  556. DS_INSTANCETYPE_IS_NC_HEAD = $00000001; // This if what to specify on an object to indicate it's an NC Head.
  557. {$EXTERNALSYM DS_INSTANCETYPE_IS_NC_HEAD}
  558. DS_INSTANCETYPE_NC_IS_WRITEABLE = $00000004; // This is to indicate that the NC Head is writeable.
  559. {$EXTERNALSYM DS_INSTANCETYPE_NC_IS_WRITEABLE}
  560. DS_INSTANCETYPE_NC_COMING = $00000010; // This is to indicate that this NC is still replicating in objects to this DC, and may not be a complete NC.
  561. {$EXTERNALSYM DS_INSTANCETYPE_NC_COMING}
  562. DS_INSTANCETYPE_NC_GOING = $00000020; // This is to indicate that this NC is in the process of being removed from this DC, and may not be a complete NC.
  563. {$EXTERNALSYM DS_INSTANCETYPE_NC_GOING}
  564. // ********************
  565. // xxx_OPT_xxx Flags
  566. // ********************
  567. // These macros define bit flags which can be set in the "options" attribute
  568. // of objects of the specified object class.
  569. // Bit flags valid for options attribute on NTDS-DSA objects.
  570. //
  571. NTDSDSA_OPT_IS_GC = 1 shl 0; // DSA is a global catalog
  572. {$EXTERNALSYM NTDSDSA_OPT_IS_GC}
  573. NTDSDSA_OPT_DISABLE_INBOUND_REPL = 1 shl 1; // disable inbound replication
  574. {$EXTERNALSYM NTDSDSA_OPT_DISABLE_INBOUND_REPL}
  575. NTDSDSA_OPT_DISABLE_OUTBOUND_REPL = 1 shl 2; // disable outbound replication
  576. {$EXTERNALSYM NTDSDSA_OPT_DISABLE_OUTBOUND_REPL}
  577. NTDSDSA_OPT_DISABLE_NTDSCONN_XLATE = 1 shl 3; // disable logical conn xlation
  578. {$EXTERNALSYM NTDSDSA_OPT_DISABLE_NTDSCONN_XLATE}
  579. // Bit flags for options attribute on NTDS-Connection objects.
  580. //
  581. // The reasons that two bits are required to control notification are as follows.
  582. // We must support existing connections with the old behavior and the UI does not
  583. // create manual connections with the new bit set.
  584. // The default for existing and manually created connections with bits 2 and 3
  585. // clear must be the standard prior behavior: notification for intra-site and
  586. // no notification for inter-site.
  587. // We need a way to distinguish a old connection which desires the default
  588. // notification rules, and a new connection for which we desire to explicitly
  589. // control the notification state as passed down from a site link. Thus we
  590. // have a new bit to say we are overriding the default, and a new bit to indicate
  591. // what the overridden default shall be.
  592. //
  593. NTDSCONN_OPT_IS_GENERATED = 1 shl 0; // object generated by DS, not admin
  594. {$EXTERNALSYM NTDSCONN_OPT_IS_GENERATED}
  595. NTDSCONN_OPT_TWOWAY_SYNC = 1 shl 1; // force sync in opposite direction at end of sync
  596. {$EXTERNALSYM NTDSCONN_OPT_TWOWAY_SYNC}
  597. NTDSCONN_OPT_OVERRIDE_NOTIFY_DEFAULT = 1 shl 2; // Do not use defaults to determine notification
  598. {$EXTERNALSYM NTDSCONN_OPT_OVERRIDE_NOTIFY_DEFAULT}
  599. NTDSCONN_OPT_USE_NOTIFY = 1 shl 3; // Does source notify destination
  600. {$EXTERNALSYM NTDSCONN_OPT_USE_NOTIFY}
  601. // For intra-site connections, this bit has no meaning.
  602. // For inter-site connections, this bit means:
  603. // 0 - Compression of replication data enabled
  604. // 1 - Compression of replication data disabled
  605. NTDSCONN_OPT_DISABLE_INTERSITE_COMPRESSION = 1 shl 4;
  606. {$EXTERNALSYM NTDSCONN_OPT_DISABLE_INTERSITE_COMPRESSION}
  607. // For connections whose IS_GENERATED bit is 0, this bit has no effect.
  608. // For KCC-generated connections, this bit indicates that the schedule attribute
  609. // is owned by the user and should not be touched by the KCC.
  610. NTDSCONN_OPT_USER_OWNED_SCHEDULE = 1 shl 5;
  611. {$EXTERNALSYM NTDSCONN_OPT_USER_OWNED_SCHEDULE}
  612. //
  613. // The high 4 bits of the options attribute are used by NTFRS to assign priority
  614. // for inbound connections. Bit 31 is used to force FRS to ignore schedule during
  615. // the initial sync. Bits 30 - 28 are used to specify a priority between 0-7.
  616. //
  617. FRSCONN_PRIORITY_MASK = $70000000;
  618. {$EXTERNALSYM FRSCONN_PRIORITY_MASK}
  619. FRSCONN_MAX_PRIORITY = $8;
  620. {$EXTERNALSYM FRSCONN_MAX_PRIORITY}
  621. DSCONN_OPT_IGNORE_SCHEDULE_MASK = DWORD($80000000);
  622. {$EXTERNALSYM DSCONN_OPT_IGNORE_SCHEDULE_MASK}
  623. function NTDSCONN_IGNORE_SCHEDULE(_options_: DWORD): DWORD;
  624. {$EXTERNALSYM NTDSCONN_IGNORE_SCHEDULE}
  625. function FRSCONN_GET_PRIORITY(_options_: DWORD): DWORD;
  626. {$EXTERNALSYM FRSCONN_GET_PRIORITY}
  627. // Bit flags for options attribute on NTDS-Site-Settings objects.
  628. //
  629. const
  630. NTDSSETTINGS_OPT_IS_AUTO_TOPOLOGY_DISABLED = 1 shl 0; // automatic topology gen disabled
  631. {$EXTERNALSYM NTDSSETTINGS_OPT_IS_AUTO_TOPOLOGY_DISABLED}
  632. NTDSSETTINGS_OPT_IS_TOPL_CLEANUP_DISABLED = 1 shl 1; // automatic topology cleanup disabled
  633. {$EXTERNALSYM NTDSSETTINGS_OPT_IS_TOPL_CLEANUP_DISABLED}
  634. NTDSSETTINGS_OPT_IS_TOPL_MIN_HOPS_DISABLED = 1 shl 2; // automatic minimum hops topology disabled
  635. {$EXTERNALSYM NTDSSETTINGS_OPT_IS_TOPL_MIN_HOPS_DISABLED}
  636. NTDSSETTINGS_OPT_IS_TOPL_DETECT_STALE_DISABLED = 1 shl 3; // automatic stale server detection disabled
  637. {$EXTERNALSYM NTDSSETTINGS_OPT_IS_TOPL_DETECT_STALE_DISABLED}
  638. NTDSSETTINGS_OPT_IS_INTER_SITE_AUTO_TOPOLOGY_DISABLED = 1 shl 4; // automatic inter-site topology gen disabled
  639. {$EXTERNALSYM NTDSSETTINGS_OPT_IS_INTER_SITE_AUTO_TOPOLOGY_DISABLED}
  640. NTDSSETTINGS_OPT_IS_GROUP_CACHING_ENABLED = 1 shl 5; // group memberships for users enabled
  641. {$EXTERNALSYM NTDSSETTINGS_OPT_IS_GROUP_CACHING_ENABLED}
  642. NTDSSETTINGS_OPT_FORCE_KCC_WHISTLER_BEHAVIOR = 1 shl 6; // force KCC to operate in Whistler behavior mode
  643. {$EXTERNALSYM NTDSSETTINGS_OPT_FORCE_KCC_WHISTLER_BEHAVIOR}
  644. NTDSSETTINGS_OPT_FORCE_KCC_W2K_ELECTION = 1 shl 7; // force KCC to use the Windows 2000 ISTG election algorithm
  645. {$EXTERNALSYM NTDSSETTINGS_OPT_FORCE_KCC_W2K_ELECTION}
  646. NTDSSETTINGS_OPT_IS_RAND_BH_SELECTION_DISABLED = 1 shl 8; // prevent the KCC from randomly picking a bridgehead when creating a connection
  647. {$EXTERNALSYM NTDSSETTINGS_OPT_IS_RAND_BH_SELECTION_DISABLED}
  648. NTDSSETTINGS_OPT_IS_SCHEDULE_HASHING_ENABLED = 1 shl 9; // allow the KCC to use hashing when creating a replication schedule
  649. {$EXTERNALSYM NTDSSETTINGS_OPT_IS_SCHEDULE_HASHING_ENABLED}
  650. // Bit flags for options attribute on Inter-Site-Transport objects
  651. //
  652. // Note, the sense of the flag should be such that the default state or
  653. // behavior corresponds to the flag NOT being present. Put another way, the
  654. // flag should state the OPPOSITE of the default
  655. //
  656. // default: schedules are significant
  657. NTDSTRANSPORT_OPT_IGNORE_SCHEDULES = 1 shl 0; // Schedules disabled
  658. {$EXTERNALSYM NTDSTRANSPORT_OPT_IGNORE_SCHEDULES}
  659. // default: links transitive (bridges not required)
  660. NTDSTRANSPORT_OPT_BRIDGES_REQUIRED = 1 shl 1; // siteLink bridges are required
  661. {$EXTERNALSYM NTDSTRANSPORT_OPT_BRIDGES_REQUIRED}
  662. // Bit flags for options attribute on site-Connection objects
  663. //
  664. // These are not realized in the DS, but are built up in the KCC
  665. NTDSSITECONN_OPT_USE_NOTIFY = 1 shl 0; // Use notification on this link
  666. {$EXTERNALSYM NTDSSITECONN_OPT_USE_NOTIFY}
  667. NTDSSITECONN_OPT_TWOWAY_SYNC = 1 shl 1; // force sync in opposite direction at end of sync
  668. {$EXTERNALSYM NTDSSITECONN_OPT_TWOWAY_SYNC}
  669. // This bit means:
  670. // 0 - Compression of replication data across this site connection enabled
  671. // 1 - Compression of replication data across this site connection disabled
  672. NTDSSITECONN_OPT_DISABLE_COMPRESSION = 1 shl 2;
  673. {$EXTERNALSYM NTDSSITECONN_OPT_DISABLE_COMPRESSION}
  674. // Bit flags for options attribute on site-Link objects
  675. // Note that these options are AND-ed along a site-link path
  676. //
  677. NTDSSITELINK_OPT_USE_NOTIFY = 1 shl 0; // Use notification on this link
  678. {$EXTERNALSYM NTDSSITELINK_OPT_USE_NOTIFY}
  679. NTDSSITELINK_OPT_TWOWAY_SYNC = 1 shl 1; // force sync in opposite direction at end of sync
  680. {$EXTERNALSYM NTDSSITELINK_OPT_TWOWAY_SYNC}
  681. // This bit means:
  682. // 0 - Compression of replication data across this site link enabled
  683. // 1 - Compression of replication data across this site link disabled
  684. NTDSSITELINK_OPT_DISABLE_COMPRESSION = 1 shl 2;
  685. {$EXTERNALSYM NTDSSITELINK_OPT_DISABLE_COMPRESSION}
  686. // ***********************
  687. // Well Known Object Guids
  688. // ***********************
  689. GUID_USERS_CONTAINER_A = 'a9d1ca15768811d1aded00c04fd8d5cd';
  690. {$EXTERNALSYM GUID_USERS_CONTAINER_A}
  691. GUID_COMPUTRS_CONTAINER_A = 'aa312825768811d1aded00c04fd8d5cd';
  692. {$EXTERNALSYM GUID_COMPUTRS_CONTAINER_A}
  693. GUID_SYSTEMS_CONTAINER_A = 'ab1d30f3768811d1aded00c04fd8d5cd';
  694. {$EXTERNALSYM GUID_SYSTEMS_CONTAINER_A}
  695. GUID_DOMAIN_CONTROLLERS_CONTAINER_A = 'a361b2ffffd211d1aa4b00c04fd7d83a';
  696. {$EXTERNALSYM GUID_DOMAIN_CONTROLLERS_CONTAINER_A}
  697. GUID_INFRASTRUCTURE_CONTAINER_A = '2fbac1870ade11d297c400c04fd8d5cd';
  698. {$EXTERNALSYM GUID_INFRASTRUCTURE_CONTAINER_A}
  699. GUID_DELETED_OBJECTS_CONTAINER_A = '18e2ea80684f11d2b9aa00c04f79f805';
  700. {$EXTERNALSYM GUID_DELETED_OBJECTS_CONTAINER_A}
  701. GUID_LOSTANDFOUND_CONTAINER_A = 'ab8153b7768811d1aded00c04fd8d5cd';
  702. {$EXTERNALSYM GUID_LOSTANDFOUND_CONTAINER_A}
  703. GUID_FOREIGNSECURITYPRINCIPALS_CONTAINER_A = '22b70c67d56e4efb91e9300fca3dc1aa';
  704. {$EXTERNALSYM GUID_FOREIGNSECURITYPRINCIPALS_CONTAINER_A}
  705. GUID_PROGRAM_DATA_CONTAINER_A = '09460c08ae1e4a4ea0f64aee7daa1e5a';
  706. {$EXTERNALSYM GUID_PROGRAM_DATA_CONTAINER_A}
  707. GUID_MICROSOFT_PROGRAM_DATA_CONTAINER_A = 'f4be92a4c777485e878e9421d53087db';
  708. {$EXTERNALSYM GUID_MICROSOFT_PROGRAM_DATA_CONTAINER_A}
  709. GUID_USERS_CONTAINER_W = WideString('a9d1ca15768811d1aded00c04fd8d5cd');
  710. {$EXTERNALSYM GUID_USERS_CONTAINER_W}
  711. GUID_COMPUTRS_CONTAINER_W = WideString('aa312825768811d1aded00c04fd8d5cd');
  712. {$EXTERNALSYM GUID_COMPUTRS_CONTAINER_W}
  713. GUID_SYSTEMS_CONTAINER_W = WideString('ab1d30f3768811d1aded00c04fd8d5cd');
  714. {$EXTERNALSYM GUID_SYSTEMS_CONTAINER_W}
  715. GUID_DOMAIN_CONTROLLERS_CONTAINER_W = WideString('a361b2ffffd211d1aa4b00c04fd7d83a');
  716. {$EXTERNALSYM GUID_DOMAIN_CONTROLLERS_CONTAINER_W}
  717. GUID_INFRASTRUCTURE_CONTAINER_W = WideString('2fbac1870ade11d297c400c04fd8d5cd');
  718. {$EXTERNALSYM GUID_INFRASTRUCTURE_CONTAINER_W}
  719. GUID_DELETED_OBJECTS_CONTAINER_W = WideString('18e2ea80684f11d2b9aa00c04f79f805');
  720. {$EXTERNALSYM GUID_DELETED_OBJECTS_CONTAINER_W}
  721. GUID_LOSTANDFOUND_CONTAINER_W = WideString('ab8153b7768811d1aded00c04fd8d5cd');
  722. {$EXTERNALSYM GUID_LOSTANDFOUND_CONTAINER_W}
  723. GUID_FOREIGNSECURITYPRINCIPALS_CONTAINER_W = WideString('22b70c67d56e4efb91e9300fca3dc1aa');
  724. {$EXTERNALSYM GUID_FOREIGNSECURITYPRINCIPALS_CONTAINER_W}
  725. GUID_PROGRAM_DATA_CONTAINER_W = WideString('09460c08ae1e4a4ea0f64aee7daa1e5a');
  726. {$EXTERNALSYM GUID_PROGRAM_DATA_CONTAINER_W}
  727. GUID_MICROSOFT_PROGRAM_DATA_CONTAINER_W = WideString('f4be92a4c777485e878e9421d53087db');
  728. {$EXTERNALSYM GUID_MICROSOFT_PROGRAM_DATA_CONTAINER_W}
  729. GUID_USERS_CONTAINER_BYTE = '\xa9\xd1\xca\x15\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd';
  730. {$EXTERNALSYM GUID_USERS_CONTAINER_BYTE}
  731. GUID_COMPUTRS_CONTAINER_BYTE = '\xaa\x31\x28\x25\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd';
  732. {$EXTERNALSYM GUID_COMPUTRS_CONTAINER_BYTE}
  733. GUID_SYSTEMS_CONTAINER_BYTE = '\xab\x1d\x30\xf3\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd';
  734. {$EXTERNALSYM GUID_SYSTEMS_CONTAINER_BYTE}
  735. GUID_DOMAIN_CONTROLLERS_CONTAINER_BYTE = '\xa3\x61\xb2\xff\xff\xd2\x11\xd1\xaa\x4b\x00\xc0\x4f\xd7\xd8\x3a';
  736. {$EXTERNALSYM GUID_DOMAIN_CONTROLLERS_CONTAINER_BYTE}
  737. GUID_INFRASTRUCTURE_CONTAINER_BYTE = '\x2f\xba\xc1\x87\x0a\xde\x11\xd2\x97\xc4\x00\xc0\x4f\xd8\xd5\xcd';
  738. {$EXTERNALSYM GUID_INFRASTRUCTURE_CONTAINER_BYTE}
  739. GUID_DELETED_OBJECTS_CONTAINER_BYTE = '\x18\xe2\xea\x80\x68\x4f\x11\xd2\xb9\xaa\x00\xc0\x4f\x79\xf8\x05';
  740. {$EXTERNALSYM GUID_DELETED_OBJECTS_CONTAINER_BYTE}
  741. GUID_LOSTANDFOUND_CONTAINER_BYTE = '\xab\x81\x53\xb7\x76\x88\x11\xd1\xad\xed\x00\xc0\x4f\xd8\xd5\xcd';
  742. {$EXTERNALSYM GUID_LOSTANDFOUND_CONTAINER_BYTE}
  743. GUID_FOREIGNSECURITYPRINCIPALS_CONTAINER_BYTE = '\x22\xb7\x0c\x67\xd5\x6e\x4e\xfb\x91\xe9\x30\x0f\xca\x3d\xc1\xaa';
  744. {$EXTERNALSYM GUID_FOREIGNSECURITYPRINCIPALS_CONTAINER_BYTE}
  745. GUID_PROGRAM_DATA_CONTAINER_BYTE = '\x09\x46\x0c\x08\xae\x1e\x4a\x4e\xa0\xf6\x4a\xee\x7d\xaa\x1e\x5a';
  746. {$EXTERNALSYM GUID_PROGRAM_DATA_CONTAINER_BYTE}
  747. GUID_MICROSOFT_PROGRAM_DATA_CONTAINER_BYTE = '\xf4\xbe\x92\xa4\xc7\x77\x48\x5e\x87\x8e\x94\x21\xd5\x30\x87\xdb';
  748. {$EXTERNALSYM GUID_MICROSOFT_PROGRAM_DATA_CONTAINER_BYTE}
  749. type
  750. _DS_MANGLE_FOR = (
  751. DS_MANGLE_UNKNOWN,
  752. DS_MANGLE_OBJECT_RDN_FOR_DELETION,
  753. DS_MANGLE_OBJECT_RDN_FOR_NAME_CONFLICT);
  754. {$EXTERNALSYM _DS_MANGLE_FOR}
  755. DS_MANGLE_FOR = _DS_MANGLE_FOR;
  756. {$EXTERNALSYM DS_MANGLE_FOR}
  757. TDsMangleFor = DS_MANGLE_FOR;
  758. PDsMangleFor = ^DS_MANGLE_FOR;
  759. //////////////////////////////////////////////////////////////////////////
  760. // //
  761. // Prototypes //
  762. // //
  763. //////////////////////////////////////////////////////////////////////////
  764. // DSBind takes two optional input parameters which identify whether the
  765. // caller found a domain controller themselves via DsGetDcName or whether
  766. // a domain controller should be found using default parameters.
  767. // Behavior of the possible combinations are outlined below.
  768. //
  769. // DomainControllerName(value), DnsDomainName(NULL)
  770. //
  771. // The value for DomainControllerName is assumed to have been
  772. // obtained via DsGetDcName (i.e. Field with the same name in a
  773. // DOMAIN_CONTROLLER_INFO struct on return from DsGetDcName call.)
  774. // The client is bound to the domain controller at this name.
  775. //
  776. // Mutual authentication will be performed using an SPN of
  777. // LDAP/DomainControllerName provided DomainControllerName
  778. // is not a NETBIOS name or IP address - i.e. it must be a
  779. // DNS host name.
  780. //
  781. // DomainControllerName(value), DnsDomainName(value)
  782. //
  783. // DsBind will connect to the server identified by DomainControllerName.
  784. //
  785. // Mutual authentication will be performed using an SPN of
  786. // LDAP/DomainControllerName/DnsDomainName provided neither value
  787. // is a NETBIOS names or IP address - i.e. they must be
  788. // valid DNS names.
  789. //
  790. // DomainControllerName(NULL), DnsDomainName(NULL)
  791. //
  792. // DsBind will attempt to find to a global catalog and fail if one
  793. // can not be found.
  794. //
  795. // Mutual authentication will be performed using an SPN of
  796. // GC/DnsHostName/ForestName where DnsHostName and ForestName
  797. // represent the DomainControllerName and DnsForestName fields
  798. // respectively of the DOMAIN_CONTROLLER_INFO returned by the
  799. // DsGetDcName call used to find a global catalog.
  800. //
  801. // DomainControllerName(NULL), DnsDomainName(value)
  802. //
  803. // DsBind will attempt to find a domain controller for the domain
  804. // identified by DnsDomainName and fail if one can not be found.
  805. //
  806. // Mutual authentication will be performed using an SPN of
  807. // LDAP/DnsHostName/DnsDomainName where DnsDomainName is that
  808. // provided by the caller and DnsHostName is that returned by
  809. // DsGetDcName for the domain specified - provided DnsDomainName
  810. // is a valid DNS domain name - i.e. not a NETBIOS domain name.
  811. function DsBindA(DomainControllerName: LPCSTR; DnsDomainName: LPCSTR;
  812. var phDS: HANDLE): DWORD; stdcall;
  813. {$EXTERNALSYM DsBindA}
  814. function DsBindW(DomainControllerName: LPCWSTR; DnsDomainName: LPCWSTR;
  815. var phDS: HANDLE): DWORD; stdcall;
  816. {$EXTERNALSYM DsBindW}
  817. function DsBind(DomainControllerName: LPCTSTR; DnsDomainName: LPCTSTR;
  818. var phDS: HANDLE): DWORD; stdcall;
  819. {$EXTERNALSYM DsBind}
  820. function DsBindWithCredA(DomainControllerName: LPCSTR; DnsDomainName: LPCSTR;
  821. AuthIdentity: RPC_AUTH_IDENTITY_HANDLE; var phDS: HANDLE): DWORD; stdcall;
  822. {$EXTERNALSYM DsBindWithCredA}
  823. function DsBindWithCredW(DomainControllerName: LPCWSTR; DnsDomainName: LPCWSTR;
  824. AuthIdentity: RPC_AUTH_IDENTITY_HANDLE; var phDS: HANDLE): DWORD; stdcall;
  825. {$EXTERNALSYM DsBindWithCredW}
  826. function DsBindWithCred(DomainControllerName: LPCTSTR; DnsDomainName: LPCTSTR;
  827. AuthIdentity: RPC_AUTH_IDENTITY_HANDLE; var phDS: HANDLE): DWORD; stdcall;
  828. {$EXTERNALSYM DsBindWithCred}
  829. //
  830. // DsBindWithSpn{A|W} allows the caller to specify the service principal
  831. // name (SPN) which will be used for mutual authentication against
  832. // the destination server. Do not provide an SPN if you are expecting
  833. // DsBind to find a server for you as SPNs are machine specific and its
  834. // unlikely the SPN you provide matches the server DsBind finds for you.
  835. // Providing a NULL ServicePrincipalName argument results in behavior
  836. // identical to DsBindWithCred{A|W}.
  837. //
  838. function DsBindWithSpnA(DomainControllerName: LPCSTR; DnsDomainName: LPCSTR;
  839. AuthIdentity: RPC_AUTH_IDENTITY_HANDLE; ServicePrincipalName: LPCSTR;
  840. var phDS: HANDLE): DWORD; stdcall;
  841. {$EXTERNALSYM DsBindWithSpnA}
  842. function DsBindWithSpnW(DomainControllerName: LPCWSTR; DnsDomainName: LPCWSTR;
  843. AuthIdentity: RPC_AUTH_IDENTITY_HANDLE; ServicePrincipalName: LPCWSTR;
  844. var phDS: HANDLE): DWORD; stdcall;
  845. {$EXTERNALSYM DsBindWithSpnW}
  846. function DsBindWithSpn(DomainControllerName: LPCTSTR; DnsDomainName: LPCTSTR;
  847. AuthIdentity: RPC_AUTH_IDENTITY_HANDLE; ServicePrincipalName: LPCTSTR;
  848. var phDS: HANDLE): DWORD; stdcall;
  849. {$EXTERNALSYM DsBindWithSpn}
  850. //
  851. // DsBindWithSpnEx{A|W} allows you all the options of the previous
  852. // DsBindWithSpn(), plus the added benefit of specifying some optional
  853. // Binding flags. Currently if you pass NTDSAPI_BIND_ALLOW_DELEGATION,
  854. // you will get the exact old behaviour. If you can avoid it, you
  855. // should not specify this flag, see flag above for details.
  856. //
  857. function DsBindWithSpnExW(DomainControllerName, DnsDomainName: LPCWSTR; AuthIdentity: RPC_AUTH_IDENTITY_HANDLE;
  858. ServicePrincipalName: LPCWSTR; BindFlags: DWORD; phDS: LPHANDLE): DWORD; stdcall;
  859. {$EXTERNALSYM DsBindWithSpnExW}
  860. function DsBindWithSpnExA(DomainControllerName, DnsDomainName: LPCSTR; AuthIdentity: RPC_AUTH_IDENTITY_HANDLE;
  861. ServicePrincipalName: LPCSTR; BindFlags: DWORD; phDS: LPHANDLE): DWORD; stdcall;
  862. {$EXTERNALSYM DsBindWithSpnExA}
  863. function DsBindWithSpnEx(DomainControllerName, DnsDomainName: LPCTSTR; AuthIdentity: RPC_AUTH_IDENTITY_HANDLE;
  864. ServicePrincipalName: LPCTSTR; BindFlags: DWORD; phDS: LPHANDLE): DWORD; stdcall;
  865. {$EXTERNALSYM DsBindWithSpnEx}
  866. //
  867. // DsBindToISTG{A|W} allows the caller to bind to the server which
  868. // holds the Inter-Site Topology Generator role in the specified site.
  869. // The site name should be the RDN of a site. If no site is specified,
  870. // the function will try to bind to the ISTG in a nearby site.
  871. //
  872. function DsBindToISTGW(SiteName: LPCWSTR; phDS: LPHANDLE): DWORD; stdcall;
  873. {$EXTERNALSYM DsBindToISTGW}
  874. function DsBindToISTGA(SiteName: LPCSTR; phDS: LPHANDLE): DWORD; stdcall;
  875. {$EXTERNALSYM DsBindToISTGA}
  876. function DsBindToISTG(SiteName: LPCTSTR; phDS: LPHANDLE): DWORD; stdcall;
  877. {$EXTERNALSYM DsBindToISTG}
  878. //
  879. // DsBindingSetTimeout allows the caller to specify a timeout value
  880. // which will be honored by all RPC calls using the specified binding
  881. // handle. RPC calls which take longer the timeout value are canceled.
  882. //
  883. function DsBindingSetTimeout(hDS: HANDLE; cTimeoutSecs: ULONG): DWORD; stdcall;
  884. {$EXTERNALSYM DsBindingSetTimeout}
  885. //
  886. // DsUnBind
  887. //
  888. function DsUnBindA(var phDS: HANDLE): DWORD; stdcall;
  889. {$EXTERNALSYM DsUnBindA}
  890. function DsUnBindW(var phDS: HANDLE): DWORD; stdcall;
  891. {$EXTERNALSYM DsUnBindW}
  892. function DsUnBind(var phDS: HANDLE): DWORD; stdcall;
  893. {$EXTERNALSYM DsUnBind}
  894. //
  895. // DsMakePasswordCredentials
  896. //
  897. // This function constructs a credential structure which is suitable for input
  898. // to the DsBindWithCredentials function, or the ldap_open function(winldap.h)
  899. // The credential must be freed using DsFreeCredential.
  900. //
  901. // None of the input parameters may be present indicating a null, default
  902. // credential. Otherwise the username must be present. If the domain or
  903. // password are null, they default to empty strings. The domain name may be
  904. // null when the username is fully qualified, for example UPN format.
  905. //
  906. function DsMakePasswordCredentialsA(User: LPCSTR; Domain: LPCSTR;
  907. Password: LPCSTR; var pAuthIdentity: RPC_AUTH_IDENTITY_HANDLE): DWORD; stdcall;
  908. {$EXTERNALSYM DsMakePasswordCredentialsA}
  909. function DsMakePasswordCredentialsW(User: LPCWSTR; Domain: LPCWSTR;
  910. Password: LPCWSTR; var pAuthIdentity: RPC_AUTH_IDENTITY_HANDLE): DWORD; stdcall;
  911. {$EXTERNALSYM DsMakePasswordCredentialsW}
  912. function DsMakePasswordCredentials(User: LPCTSTR; Domain: LPCTSTR;
  913. Password: LPCTSTR; var pAuthIdentity: RPC_AUTH_IDENTITY_HANDLE): DWORD; stdcall;
  914. {$EXTERNALSYM DsMakePasswordCredentials}
  915. procedure DsFreePasswordCredentialsA(AuthIdentity: RPC_AUTH_IDENTITY_HANDLE); stdcall;
  916. {$EXTERNALSYM DsFreePasswordCredentialsA}
  917. procedure DsFreePasswordCredentialsW(AuthIdentity: RPC_AUTH_IDENTITY_HANDLE); stdcall;
  918. {$EXTERNALSYM DsFreePasswordCredentialsW}
  919. procedure DsFreePasswordCredentials(AuthIdentity: RPC_AUTH_IDENTITY_HANDLE); stdcall;
  920. {$EXTERNALSYM DsFreePasswordCredentials}
  921. //
  922. // DsCrackNames
  923. //
  924. function DsCrackNamesA(hDS: HANDLE; flags: DS_NAME_FLAGS;
  925. formatOffered: DS_NAME_FORMAT; formatDesired: DS_NAME_FORMAT; cNames: DWORD;
  926. rpNames: LPCSTR; var ppResult: PDS_NAME_RESULTA): DWORD; stdcall;
  927. {$EXTERNALSYM DsCrackNamesA}
  928. function DsCrackNamesW(hDS: HANDLE; flags: DS_NAME_FLAGS;
  929. formatOffered: DS_NAME_FORMAT; formatDesired: DS_NAME_FORMAT; cNames: DWORD;
  930. rpNames: LPCWSTR; var ppResult: PDS_NAME_RESULTW): DWORD; stdcall;
  931. {$EXTERNALSYM DsCrackNamesW}
  932. function DsCrackNames(hDS: HANDLE; flags: DS_NAME_FLAGS;
  933. formatOffered: DS_NAME_FORMAT; formatDesired: DS_NAME_FORMAT; cNames: DWORD;
  934. rpNames: LPCTSTR; var ppResult: PDS_NAME_RESULT): DWORD; stdcall;
  935. {$EXTERNALSYM DsCrackNames}
  936. //
  937. // DsFreeNameResult
  938. //
  939. procedure DsFreeNameResultA(pResult: PDS_NAME_RESULTA); stdcall;
  940. {$EXTERNALSYM DsFreeNameResultA}
  941. procedure DsFreeNameResultW(pResult: PDS_NAME_RESULTW); stdcall;
  942. {$EXTERNALSYM DsFreeNameResultW}
  943. procedure DsFreeNameResult(pResult: PDS_NAME_RESULT); stdcall;
  944. {$EXTERNALSYM DsFreeNameResult}
  945. // ==========================================================
  946. // DSMakeSpn -- client call to create SPN for a service to which it wants to
  947. // authenticate.
  948. // This name is then passed to "pszTargetName" of InitializeSecurityContext().
  949. //
  950. // Notes:
  951. // If the service name is a DNS host name, or canonical DNS service name
  952. // e.g. "www.ms.com", i.e., caller resolved with gethostbyname, then instance
  953. // name should be NULL.
  954. // Realm is host name minus first component, unless it is in the exception list
  955. //
  956. // If the service name is NetBIOS machine name, then instance name should be
  957. // NULL
  958. // Form must be <domain>\<machine>
  959. // Realm will be <domain>
  960. //
  961. // If the service name is that of a replicated service, where each replica has
  962. // its own account (e.g., with SRV records) then the caller must supply the
  963. // instance name then realm name is same as ServiceName
  964. //
  965. // If the service name is a DN, then must also supply instance name
  966. // (DN could be name of service object (incl RPC or Winsock), name of machine
  967. // account, name of domain object)
  968. // then realm name is domain part of the DN
  969. //
  970. // If the service name is NetBIOS domain name, then must also supply instance
  971. // name; realm name is domain name
  972. //
  973. // If the service is named by an IP address -- then use referring service name
  974. // as service name
  975. //
  976. // ServiceClass - e.g. "http", "ftp", "ldap", GUID
  977. // ServiceName - DNS or DN; assumes we can compute domain from service name
  978. // InstanceName OPTIONAL- DNS name of host for instance of service
  979. // InstancePort - port number for instance (0 if default)
  980. // Referrer OPTIONAL- DNS name of host that gave this referral
  981. // pcSpnLength - in -- max length IN CHARACTERS of principal name;
  982. // out -- actual
  983. // Length includes terminator
  984. // pszSPN - server principal name
  985. //
  986. // If buffer is not large enough, ERROR_BUFFER_OVERFLOW is returned and the
  987. // needed length is returned in pcSpnLength.
  988. //
  989. //
  990. function DsMakeSpnA(ServiceClass: LPCSTR; ServiceName: LPCSTR;
  991. InstanceName: LPCSTR; InstancePort: USHORT; Referrer: LPCSTR;
  992. var pcSpnLength: DWORD; pszSpn: LPSTR): DWORD; stdcall;
  993. {$EXTERNALSYM DsMakeSpnA}
  994. function DsMakeSpnW(ServiceClass: LPCWSTR; ServiceName: LPCWSTR;
  995. InstanceName: LPCWSTR; InstancePort: USHORT; Referrer: LPCWSTR;
  996. var pcSpnLength: DWORD; pszSpn: LPWSTR): DWORD; stdcall;
  997. {$EXTERNALSYM DsMakeSpnW}
  998. function DsMakeSpn(ServiceClass: LPCTSTR; ServiceName: LPCTSTR;
  999. InstanceName: LPCTSTR; InstancePort: USHORT; Referrer: LPCTSTR;
  1000. var pcSpnLength: DWORD; pszSpn: LPTSTR): DWORD; stdcall;
  1001. {$EXTERNALSYM DsMakeSpn}
  1002. // ==========================================================
  1003. // DsGetSPN -- server's call to gets SPNs for a service name by which it is
  1004. // known to clients. N.B.: there may be more than one name by which clients
  1005. // …

Large files files are truncated, but you can click here to view the full file