1eaa242ff0cf14c7b47346fd55e783b9fce9c7fe
[bbaumbach/samba-autobuild/.git] / source4 / librpc / idl / drsuapi.idl
1 #include "idl_types.h"
2
3
4   uuid("e3514235-4b06-11d1-ab04-00c04fc2dcd2"),
5   version(4.0),
6   endpoint("ncacn_np:[\\pipe\\lsass]","ncacn_np:[\\pipe\\protected_storage]", "ncacn_ip_tcp:", "ncalrpc:"),
7   authservice("ldap"),
8   helpstring("Active Directory Replication"),
9   pointer_default(unique),
10   pointer_default_top(unique),
11   depends(security)
12
13 interface drsuapi
14 {
15         /*****************/
16         /* Function 0x00 */
17         typedef [bitmap32bit] bitmap {
18                 DRSUAPI_SUPPORTED_EXTENSION_BASE                        = 0x00000001,
19                 DRSUAPI_SUPPORTED_EXTENSION_ASYNC_REPLICATION           = 0x00000002,
20                 DRSUAPI_SUPPORTED_EXTENSION_REMOVEAPI                   = 0x00000004,
21                 DRSUAPI_SUPPORTED_EXTENSION_MOVEREQ_V2                  = 0x00000008,
22                 DRSUAPI_SUPPORTED_EXTENSION_GETCHG_COMPRESS             = 0x00000010,
23                 DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V1                   = 0x00000020,
24                 DRSUAPI_SUPPORTED_EXTENSION_RESTORE_USN_OPTIMIZATION    = 0x00000040,
25                 DRSUAPI_SUPPORTED_EXTENSION_00000080                    = 0x00000080,
26                 DRSUAPI_SUPPORTED_EXTENSION_KCC_EXECUTE                 = 0x00000100,
27                 DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY_V2                 = 0x00000200,
28                 DRSUAPI_SUPPORTED_EXTENSION_LINKED_VALUE_REPLICATION    = 0x00000400,
29                 DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V2                   = 0x00000800,
30                 DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD= 0x00001000,
31                 DRSUAPI_SUPPORTED_EXTENSION_CRYPTO_BIND                 = 0x00002000,
32                 DRSUAPI_SUPPORTED_EXTENSION_GET_REPL_INFO               = 0x00004000,
33                 DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION           = 0x00008000,
34                 DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V01                  = 0x00010000,
35                 DRSUAPI_SUPPORTED_EXTENSION_TRANSITIVE_MEMBERSHIP       = 0x00020000,
36                 DRSUAPI_SUPPORTED_EXTENSION_ADD_SID_HISTORY             = 0x00040000,
37                 DRSUAPI_SUPPORTED_EXTENSION_POST_BETA3                  = 0x00080000,
38                 DRSUAPI_SUPPORTED_EXTENSION_00100000                    = 0x00100000,
39                 DRSUAPI_SUPPORTED_EXTENSION_GET_MEMBERSHIPS2            = 0x00200000,
40                 DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V6                = 0x00400000,
41                 DRSUAPI_SUPPORTED_EXTENSION_NONDOMAIN_NCS               = 0x00800000,
42                 DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8                = 0x01000000,
43                 DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V5              = 0x02000000,
44                 DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V6              = 0x04000000,
45                 /*
46                  * the following 3 have the same value
47                  * repadmin.exe /bind says that
48                  */
49                 DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3            = 0x08000000,
50                 DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V7              = 0x08000000,
51                 DRSUAPI_SUPPORTED_EXTENSION_VERIFY_OBJECT               = 0x08000000,
52                 DRSUAPI_SUPPORTED_EXTENSION_XPRESS_COMPRESS             = 0x10000000,
53                 DRSUAPI_SUPPORTED_EXTENSION_20000000                    = 0x20000000,
54                 DRSUAPI_SUPPORTED_EXTENSION_40000000                    = 0x40000000,
55                 DRSUAPI_SUPPORTED_EXTENSION_80000000                    = 0x80000000
56         } drsuapi_SupportedExtensions;
57
58         /* this is used by w2k */
59         typedef struct {
60                 drsuapi_SupportedExtensions supported_extensions;
61                 GUID site_guid;
62                 uint32 u1;
63         } drsuapi_DsBindInfo24;
64
65         /* this is used by w2k3 */
66         typedef struct {
67                 drsuapi_SupportedExtensions supported_extensions;
68                 GUID site_guid;
69                 uint32 u1;
70                 uint32 repl_epoch;
71         } drsuapi_DsBindInfo28;
72
73         typedef struct {
74                 [flag(NDR_REMAINING)] DATA_BLOB info;
75         } drsuapi_DsBindInfoFallBack;
76
77         typedef [nodiscriminant] union {
78                 [case(24)][subcontext(4)] drsuapi_DsBindInfo24 info24;
79                 [case(28)][subcontext(4)] drsuapi_DsBindInfo28 info28;
80                 [default][subcontext(4)] drsuapi_DsBindInfoFallBack FallBack;
81         } drsuapi_DsBindInfo;
82
83         /* the drsuapi_DsBindInfoCtr was this before
84          * typedef [flag(NDR_PAHEX)] struct {
85          *      [range(1,10000)] uint32 length;
86          *      [size_is(length)] uint8 data[];
87          * } drsuapi_DsBindInfo;
88          *
89          * but we don't want the caller to manually decode this blob,
90          * so we're doing it here
91          */
92
93         typedef struct {
94                 [range(1,10000)] uint32 length;
95                 [switch_is(length)] drsuapi_DsBindInfo info;
96         } drsuapi_DsBindInfoCtr;
97
98         /* this is a magic guid you need to pass to DsBind to make drsuapi_DsWriteAccountSpn() work
99          * 
100          * maybe the bind_guid could also be the invocation_id see drsuapi_DsReplicaConnection04
101          */
102         const string DRSUAPI_DS_BIND_GUID = "e24d201a-4fd6-11d1-a3da-0000f875ae0d";
103
104         WERROR drsuapi_DsBind(
105                 [in]        GUID *bind_guid,
106                 [in,out]    drsuapi_DsBindInfoCtr *bind_info,
107                 [out,ref]   policy_handle *bind_handle
108                 );
109
110         /*****************/
111         /* Function 0x01 */
112         WERROR drsuapi_DsUnbind(
113                 [in,out,ref] policy_handle *bind_handle
114                 );
115
116         /*****************/
117         /* Function 0x02 */
118         typedef [gensize] struct {
119                 [value(ndr_size_drsuapi_DsReplicaObjectIdentifier(r, ndr->flags)-4)] uint32 __ndr_size;
120                 /*[value(ndr_length_dom_sid(&r->sid))]*/  uint32 __ndr_size_sid;
121                 GUID guid;
122                 dom_sid28 sid;
123                 [flag(STR_SIZE4|STR_CHARLEN|STR_CONFORMANT)] string dn;
124         } drsuapi_DsReplicaObjectIdentifier;
125
126         typedef [public] bitmap {
127                 DRSUAPI_DS_REPLICA_SYNC_ASYNCHRONOUS_OPERATION  = 0x00000001,
128                 DRSUAPI_DS_REPLICA_SYNC_WRITEABLE               = 0x00000002,
129                 DRSUAPI_DS_REPLICA_SYNC_PERIODIC                = 0x00000004,
130                 DRSUAPI_DS_REPLICA_SYNC_INTERSITE_MESSAGING     = 0x00000008,
131                 DRSUAPI_DS_REPLICA_SYNC_ALL_SOURCES             = 0x00000010,
132                 DRSUAPI_DS_REPLICA_SYNC_FULL                    = 0x00000020,
133                 DRSUAPI_DS_REPLICA_SYNC_URGENT                  = 0x00000040,
134                 DRSUAPI_DS_REPLICA_SYNC_NO_DISCARD              = 0x00000080,
135                 DRSUAPI_DS_REPLICA_SYNC_FORCE                   = 0x00000100,
136                 DRSUAPI_DS_REPLICA_SYNC_ADD_REFERENCE           = 0x00000200,
137                 DRSUAPI_DS_REPLICA_SYNC_NEVER_COMPLETED         = 0x00000400,
138                 DRSUAPI_DS_REPLICA_SYNC_TWO_WAY                 = 0x00000800,
139                 DRSUAPI_DS_REPLICA_SYNC_NEVER_NOTIFY            = 0x00001000,
140                 DRSUAPI_DS_REPLICA_SYNC_INITIAL                 = 0x00002000,
141                 DRSUAPI_DS_REPLICA_SYNC_USE_COMPRESSION         = 0x00004000,
142                 DRSUAPI_DS_REPLICA_SYNC_ABANDONED               = 0x00008000,
143                 DRSUAPI_DS_REPLICA_SYNC_INITIAL_IN_PROGRESS     = 0x00010000,
144                 DRSUAPI_DS_REPLICA_SYNC_PARTIAL_ATTRIBUTE_SET   = 0x00020000,
145                 DRSUAPI_DS_REPLICA_SYNC_REQUEUE                 = 0x00040000,
146                 DRSUAPI_DS_REPLICA_SYNC_NOTIFICATION            = 0x00080000,
147                 DRSUAPI_DS_REPLICA_SYNC_ASYNCHRONOUS_REPLICA    = 0x00100000,
148                 DRSUAPI_DS_REPLICA_SYNC_CRITICAL                = 0x00200000,
149                 DRSUAPI_DS_REPLICA_SYNC_FULL_IN_PROGRESS        = 0x00400000,
150                 DRSUAPI_DS_REPLICA_SYNC_PREEMPTED               = 0x00800000
151         } drsuapi_DsReplicaSyncOptions;
152
153         typedef struct {
154                 drsuapi_DsReplicaObjectIdentifier *naming_context;
155                 GUID guid1;
156                 astring *string1;
157                 drsuapi_DsReplicaSyncOptions options;
158         } drsuapi_DsReplicaSyncRequest1;
159
160         typedef [switch_type(int32)] union {
161                 [case(1)] drsuapi_DsReplicaSyncRequest1 req1;
162         } drsuapi_DsReplicaSyncRequest;
163
164         WERROR drsuapi_DsReplicaSync(
165                 [in,ref] policy_handle *bind_handle,
166                 [in] int32 level,
167                 [in,switch_is(level)] drsuapi_DsReplicaSyncRequest req
168                 );
169
170         /*****************/
171         /* Function 0x03 */
172         typedef [public] struct {
173                 hyper tmp_highest_usn; /* updated after each object update */
174                 hyper reserved_usn;
175                 hyper highest_usn; /* updated after a full replication cycle */
176         } drsuapi_DsReplicaHighWaterMark;
177
178         typedef [public] struct {
179                 GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */
180                 hyper highest_usn;  /* updated after a full replication cycle */
181         } drsuapi_DsReplicaCoursor;
182
183         typedef struct {
184                 uint32 u1;
185                 uint32 u2;
186                 [range(0,0x100000)] uint32 count;
187                 uint32 u3;
188                 [size_is(count)] drsuapi_DsReplicaCoursor coursors[];
189         } drsuapi_DsReplicaCoursorCtrEx;
190
191         typedef [public] bitmap {
192                 /* the _WRITEABLE flag seems to indicate a replication with all attributes,
193                  * and I'm currently always on error when it's set, but w2k and w2k3 uses it
194                  * in the dc join
195                  * --metze
196                  */
197                 DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE                          = 0x00000010,
198                 DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP                    = 0x00000020,
199                 DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS                 = 0x00000040,
200                 DRSUAPI_DS_REPLICA_NEIGHBOUR_USE_ASYNC_INTERSIDE_TRANSPORT      = 0x00000080,
201                 DRSUAPI_DS_REPLICA_NEIGHBOUR_TWO_WAY_SYNC                       = 0x00000200,
202                 DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS              = 0x00000800,
203                 DRSUAPI_DS_REPLICA_NEIGHBOUR_FULL_IN_PROGRESS                   = 0x00010000,
204                 DRSUAPI_DS_REPLICA_NEIGHBOUR_FULL_NEXT_PACKET                   = 0x00020000,
205                 DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED                       = 0x00200000,
206                 DRSUAPI_DS_REPLICA_NEIGHBOUR_PREEMPTED                          = 0x01000000,
207                 DRSUAPI_DS_REPLICA_NEIGHBOUR_IGNORE_CHANGE_NOTIFICATIONS        = 0x04000000,
208                 DRSUAPI_DS_REPLICA_NEIGHBOUR_DISABLE_SCHEDULED_SYNC             = 0x08000000,
209                 /* 
210                  * the following NOTE applies to DsGetNCChangesRequest5:
211                  *  - the data is only compressed when 10 or more objects are replicated
212                  *  - but there could also be a size limit of 35 KBytes or something like that
213                  *  - the reply is DsGetNCChangesCtr2
214                  *  - maybe the same applies to DsGetNCChangesRequest8...
215                  *
216                  *  --metze
217                  */
218                 DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES                   = 0x10000000,
219                 DRSUAPI_DS_REPLICA_NEIGHBOUR_NO_CHANGE_NOTIFICATIONS            = 0x20000000,
220                 DRSUAPI_DS_REPLICA_NEIGHBOUR_PARTIAL_ATTRIBUTE_SET              = 0x40000000
221         } drsuapi_DsReplicaNeighbourFlags;
222
223         typedef struct {
224                 GUID destination_dsa_guid;
225                 GUID source_dsa_guid;
226                 [ref] drsuapi_DsReplicaObjectIdentifier *naming_context;
227                 drsuapi_DsReplicaHighWaterMark highwatermark;
228                 drsuapi_DsReplicaCoursorCtrEx *uptodateness_vector;
229                 drsuapi_DsReplicaNeighbourFlags replica_flags;
230                 uint32 unknown2;
231                 uint32 unknown3;
232                 uint32 unknown4;
233                 hyper h1;
234         } drsuapi_DsGetNCChangesRequest5;
235
236         typedef [flag(NDR_PAHEX)] struct {
237                 [range(0,10000)] uint32 length;
238                 [size_is(length)] uint8 *byte_array;
239         } drsuapi_DsGetNCChangesRequest_Ctr14;
240
241         typedef struct {
242                 uint32 unknown1;
243                 drsuapi_DsGetNCChangesRequest_Ctr14 data;
244         } drsuapi_DsGetNCChangesRequest_Ctr13;
245
246         typedef struct {
247                 [range(0,0x100000)] uint32 count;
248                 [size_is(count)] drsuapi_DsGetNCChangesRequest_Ctr13 *array;
249         } drsuapi_DsGetNCChangesRequest_Ctr12;
250
251         typedef struct {
252                 GUID destination_dsa_guid;
253                 GUID source_dsa_guid;
254                 [ref] drsuapi_DsReplicaObjectIdentifier *naming_context;
255                 drsuapi_DsReplicaHighWaterMark highwatermark;
256                 drsuapi_DsReplicaCoursorCtrEx *uptodateness_vector;
257                 drsuapi_DsReplicaNeighbourFlags replica_flags;
258                 uint32 unknown2;
259                 uint32 unknown3;
260                 uint32 unknown4;
261                 hyper h1;
262                 uint32 unique_ptr1;
263                 uint32 unique_ptr2;
264                 drsuapi_DsGetNCChangesRequest_Ctr12 ctr12;
265         } drsuapi_DsGetNCChangesRequest8;
266
267         typedef [switch_type(int32)] union {
268                 [case(5)] drsuapi_DsGetNCChangesRequest5 req5;
269                 [case(8)] drsuapi_DsGetNCChangesRequest8 req8;
270         } drsuapi_DsGetNCChangesRequest;
271
272         typedef [public] struct {
273                 GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */
274                 hyper highest_usn;  /* updated after a full replication cycle */
275                 NTTIME last_sync_success;
276         } drsuapi_DsReplicaCoursor2;
277
278         typedef struct {
279                 uint32 u1;
280                 uint32 u2;
281                 [range(0,0x100000)] uint32 count;
282                 uint32 u3;
283                 [size_is(count)] drsuapi_DsReplicaCoursor2 coursors[];
284         } drsuapi_DsReplicaCoursor2CtrEx;
285
286         /*
287          * In DRSUAPI the objectClasses and attributes
288          * are identified by uint32 values, but in the schema
289          * they are identified by the governsID (objectClasses)
290          * and attributeID (attributes)
291          *
292          * the following table shows the mapping used between the two representations
293          * e.g. - objectClass 'nTDSDSA' has governsID: 1.2.840.113556.1.5.7000.47
294          *        and a UINT32-ID of '0x0017002F'.
295          *      - so the OID 1.2.840.113556.1.5.7000.47 is splitted into a
296          *        OID-prefix: 1.2.840.113556.1.5.7000
297          *        and a value: 47 => 0x2F
298          *      - the mapping table gives a UINT32-prefix: 0x00170000
299          *      - and the UINT32-ID is 0x0017002F = 0x00170000 | 0x2F
300          *
301          * OID-prefix                   => UINT32-Id prefix
302          *
303          * 2.5.4.*                      => 0x00000000 (standard attributes RFC2256 core.schema)
304          * 2.5.6.*                      => 0x00010000 (standard object classes RFC2256 core.schema)
305          * 1.2.840.113556.1.2.*         => 0x00020000
306          * 1.2.840.113556.1.3.*         => 0x00030000
307          * 1.2.840.113556.1.4.*         => 0x00090000
308          * 1.2.840.113556.1.5.*         => 0x000A0000
309          * 2.16.840.1.113730.3.*        => 0x00140000
310          * 0.9.2342.19200300.100.1.*    => 0x00150000
311          * 2.16.840.1.113730.3.1.*      => 0x00160000
312          * 1.2.840.113556.1.5.7000.*    => 0x00170000
313          * 2.5.20.*                     => 0x001A0000
314          * 2.16.840.1.113730.3.2.*      => 0x001C0000
315          * 1.3.6.1.4.1.250.1.*          => 0x001D0000
316          * 0.9.2342.19200300.100.4.*    => 0x001F0000
317          *
318          * 1.2.840.113549.1.9.*         (unstructuredAddress,unstructuredName)
319          * 1.3.6.1.4.1.1466.101.119.2   (dynamicObject)
320          * 1.3.6.1.4.1.1466.101.119.3   (entryTTL)
321          * 2.5.18.*                     (createTimeStamp,modifyTimeStamp, SubSchema)            
322          * 2.5.21.*                     (attrs for SubSchema)
323          *
324          * Here's a list of used 'attributeSyntax' OID's
325          *
326          * 2.5.5.1      => Object(DS-DN) string
327          *                 struct drsuapi_DsObjectIdentifier3
328          *
329          * 2.5.5.2      => OID-string
330          *              => mayContain, mustContain... also have this syntax but have string values
331          *
332          * 2.5.5.4      => String(Teletex) case-insensitive string with teletex charset
333          *
334          * 2.5.5.5      => String(IA5) case-sensitive string
335          *
336          * 2.5.5.6      => String(Numeric)
337          *              => eg. internationalISDNNumber
338          *
339          * 2.5.5.7      => Object(DN-Binary) B:<byte count>:<bytes>:<object DN>
340          *              => e.g. wellKnownObjects
341          *
342          * 2.5.5.8      => BOOL
343          *
344          * 2.5.5.9      => int32
345          *
346          * 2.5.5.10     => DATA_BLOB
347          *              => struct GUID
348          *
349          * 2.5.5.11     => LDAP timestring
350          *              => NTTIME_1sec
351          *
352          * 2.5.5.12     => String(Unicode) case-insensitive string
353          *              => 'standard strings'
354          *
355          * 2.5.5.13     => Object(Presentation-Address) string
356          *              => used in objectClass applicationEntity
357          *
358          * 2.5.5.14     => Object(DN-String) S:<char count>:<string>:<object DN>
359          *              => not used
360          *
361          * 2.5.5.15     => ntSecurityDescriptor
362          *
363          * 2.5.5.16     => int64
364          *
365          * 2.5.5.17     => dom_sid
366          */
367
368         typedef [v1_enum] enum {
369                 DRSUAPI_OBJECTCLASS_top                 = 0x00010000
370         } drsuapi_DsObjectClassId;
371
372         typedef [v1_enum,public] enum {
373                 DRSUAPI_ATTRIBUTE_objectClass           = 0x00000000,
374                 DRSUAPI_ATTRIBUTE_description           = 0x0000000d,
375                 DRSUAPI_ATTRIBUTE_invocationId          = 0x00020073,
376                 DRSUAPI_ATTRIBUTE_ntSecurityDescriptor  = 0x00020119,
377                 DRSUAPI_ATTRIBUTE_objectSid             = 0x00090092,
378                 DRSUAPI_ATTRIBUTE_dBCSPwd               = 0x00090037,/* lmPwdHash */
379                 DRSUAPI_ATTRIBUTE_unicodePwd            = 0x0009005a,/* ntPwdHash */
380                 DRSUAPI_ATTRIBUTE_ntPwdHistory          = 0x0009005e,
381                 DRSUAPI_ATTRIBUTE_lmPwdHistory          = 0x000900a0,
382                 DRSUAPI_ATTRIBUTE_objectCategory        = 0x0009030e
383                 /* DRSUAPI_ATTRIBUTE_ */
384         } drsuapi_DsAttributeId;
385
386         /* Generic DATA_BLOB values */
387         typedef struct {
388                 [range(0,10485760)] uint32 length;
389                 DATA_BLOB *data;
390         } drsuapi_DsAttributeValueDataBlob;
391
392         typedef struct {
393                 [range(0,10485760)] uint32 num_values;
394                 [size_is(num_values)] drsuapi_DsAttributeValueDataBlob *values;
395         } drsuapi_DsAttributeValueCtrDataBlob;
396
397         /* objectClass values */
398         typedef struct {
399                 [range(0,10485760)] uint32 length;
400                 [subcontext(4)] drsuapi_DsObjectClassId *objectClassId;
401         } drsuapi_DsAttributeValueObjectClassId;
402
403         typedef struct {
404                 [range(0,10485760)] uint32 num_values;
405                 [size_is(num_values)] drsuapi_DsAttributeValueObjectClassId *values;
406         } drsuapi_DsAttributeValueCtrObjectClassId;
407
408         /* uint32 values */
409         typedef struct {
410                 [range(0,10485760)] uint32 length;
411                 [subcontext(4)] uint32 *value;
412         } drsuapi_DsAttributeValueUINT32;
413
414         typedef struct {
415                 [range(0,10485760)] uint32 num_values;
416                 [size_is(num_values)] drsuapi_DsAttributeValueUINT32 *values;
417         } drsuapi_DsAttributeValueCtrUINT32;
418
419         /* UnicodeString values */
420         typedef struct {
421                 [range(0,10485760)] uint32 length;
422                 [subcontext(4)] nstring *string;
423         } drsuapi_DsAttributeValueUnicodeString;
424
425         typedef struct {
426                 [range(0,10485760)] uint32 num_values;
427                 [size_is(num_values)] drsuapi_DsAttributeValueUnicodeString *values;
428         } drsuapi_DsAttributeValueCtrUnicodeString;
429
430         /* DN String values */
431         typedef [gensize] struct {
432                 [value(ndr_size_drsuapi_DsReplicaObjectIdentifier3(r, ndr->flags)-4)] uint32 __ndr_size;
433                 [value(ndr_length_dom_sid(&r->sid))]  uint32 __ndr_size_sid;
434                 GUID guid;
435                 dom_sid28 sid;
436                 [flag(STR_SIZE4|STR_CHARLEN)] string dn;
437         } drsuapi_DsReplicaObjectIdentifier3;
438
439         typedef  struct {
440                 [range(0,10485760)] uint32 length;
441                 [subcontext(4)] drsuapi_DsReplicaObjectIdentifier3 *object;
442         } drsuapi_DsAttributeValueDNString;
443
444         typedef struct {
445                 [range(0,10485760)] uint32 num_values;
446                 [size_is(num_values)] drsuapi_DsAttributeValueDNString *values;
447         } drsuapi_DsAttributeValueCtrDNString;
448
449         /* GUID values */
450         typedef struct {
451                 [range(0,10485760)] uint32 length;
452                 [subcontext(4)] GUID *guid;
453         } drsuapi_DsAttributeValueGUID;
454
455         typedef struct {
456                 [range(0,10485760)] uint32 num_values;
457                 [size_is(num_values)] drsuapi_DsAttributeValueGUID *values;
458         } drsuapi_DsAttributeValueCtrGUID;
459
460         /* SID values */
461         typedef struct {
462                 [range(0,10485760)] uint32 length;
463                 [subcontext(4)] dom_sid *sid;
464         } drsuapi_DsAttributeValueSID;
465
466         typedef struct {
467                 [range(0,10485760)] uint32 num_values;
468                 [size_is(num_values)] drsuapi_DsAttributeValueSID *values;
469         } drsuapi_DsAttributeValueCtrSID;
470
471         /* SecurityDescriptor values */
472         typedef struct {
473                 [range(0,10485760)] uint32 length;
474                 [subcontext(4)] security_descriptor *sd;
475         } drsuapi_DsAttributeValueSecurityDescriptor;
476
477         typedef struct {
478                 [range(0,10485760)] uint32 num_values;
479                 [size_is(num_values)] drsuapi_DsAttributeValueSecurityDescriptor *values;
480         } drsuapi_DsAttributeValueCtrSecurityDescriptor;
481
482         /* NTTIME_1sec values */
483         typedef struct {
484                 [range(0,10485760)] uint32 length;
485                 [subcontext(4)] NTTIME_1sec *time;
486         } drsuapi_DsAttributeValueNTTIME_1sec;
487
488         typedef struct {
489                 [range(0,10485760)] uint32 num_values;
490                 [size_is(num_values)] drsuapi_DsAttributeValueNTTIME_1sec *values;
491         } drsuapi_DsAttributeValueCtrNTTIME_1sec;
492
493         typedef [nodiscriminant] union {
494                 [case(DRSUAPI_ATTRIBUTE_objectClass)] drsuapi_DsAttributeValueCtrObjectClassId object_class_id;
495
496                 /* UINT32 */
497                 [case(0x00020001)] drsuapi_DsAttributeValueCtrUINT32 uint32;
498                 [case(0x0002004c)] drsuapi_DsAttributeValueCtrUINT32 uint32;
499                 [case(0x000200a9)] drsuapi_DsAttributeValueCtrUINT32 uint32;
500                 [case(0x00090177)] drsuapi_DsAttributeValueCtrUINT32 uint32;
501                 [case(0x000905b3)] drsuapi_DsAttributeValueCtrUINT32 uint32;
502
503                 /* GUID */
504                 [case(DRSUAPI_ATTRIBUTE_invocationId)] drsuapi_DsAttributeValueCtrGUID guid;
505
506                 /* SID */
507                 [case(DRSUAPI_ATTRIBUTE_objectSid)] drsuapi_DsAttributeValueCtrSID sid;
508
509                 /* SecurityDescriptor */
510                 [case(DRSUAPI_ATTRIBUTE_ntSecurityDescriptor)] drsuapi_DsAttributeValueCtrSecurityDescriptor security_descriptor;
511
512                 /* UnicodeString */
513                 [case(DRSUAPI_ATTRIBUTE_description)]           drsuapi_DsAttributeValueCtrUnicodeString unicode_string;
514                 [case(0x00090001)]                              drsuapi_DsAttributeValueCtrUnicodeString unicode_string;
515                 [case(0x000900dd)]                              drsuapi_DsAttributeValueCtrUnicodeString unicode_string;
516                 [case(0x0009037b)]                              drsuapi_DsAttributeValueCtrUnicodeString unicode_string;
517
518                 /* DN String */
519                 [case(DRSUAPI_ATTRIBUTE_objectCategory)]        drsuapi_DsAttributeValueCtrDNString dn_string;
520                 [case(0x0002000e)]                              drsuapi_DsAttributeValueCtrDNString dn_string;
521                 [case(0x00020024)]                              drsuapi_DsAttributeValueCtrDNString dn_string;
522                 [case(0x00090171)]                              drsuapi_DsAttributeValueCtrDNString dn_string;
523                 [case(0x0009071c)]                              drsuapi_DsAttributeValueCtrDNString dn_string;
524                 [case(0x0009072c)]                              drsuapi_DsAttributeValueCtrDNString dn_string;
525                 [case(0x0009026a)]                              drsuapi_DsAttributeValueCtrDNString dn_string;
526                 [case(0x00090203)]                              drsuapi_DsAttributeValueCtrDNString dn_string;
527
528                 /* NTTIME_1sec */
529                 [case(0x00020002)] drsuapi_DsAttributeValueCtrNTTIME_1sec nttime_1sec;
530
531                 /* the default is the DATA_BLOB */
532                 [default] drsuapi_DsAttributeValueCtrDataBlob data_blob;
533         } drsuapi_DsReplicaAttributeValueCtr;
534
535         typedef [flag(NDR_PAHEX)] struct {
536                 drsuapi_DsAttributeId attid;
537                 [switch_is(attid)] drsuapi_DsReplicaAttributeValueCtr value_ctr;
538         } drsuapi_DsReplicaAttribute;
539
540         typedef struct {
541                 [range(0,1048576)] uint32 num_attributes;
542                 [size_is(num_attributes)]  drsuapi_DsReplicaAttribute *attributes;
543         } drsuapi_DsReplicaAttributeCtr;
544
545         typedef [public] struct {
546                 drsuapi_DsReplicaObjectIdentifier *identifier;
547                 uint32 unknown1;
548                 drsuapi_DsReplicaAttributeCtr attribute_ctr;
549         } drsuapi_DsReplicaObject;
550
551         typedef struct {
552                 uint32 version;
553                 NTTIME_1sec orginating_time;
554                 GUID orginating_invocation_id;
555                 hyper orginating_usn;
556         } drsuapi_DsReplicaMetaData;
557
558         typedef [public] struct {
559                 [range(0,1048576)] uint32 count;
560                 [size_is(count)] drsuapi_DsReplicaMetaData meta_data[];
561         } drsuapi_DsReplicaMetaDataCtr;
562
563         typedef [public,noprint] struct {
564                 drsuapi_DsReplicaObjectListItemEx *next_object;
565                 drsuapi_DsReplicaObject object;
566                 uint32 unknown1;
567                 GUID *parent_object_guid;
568                 drsuapi_DsReplicaMetaDataCtr *meta_data_ctr;
569         } drsuapi_DsReplicaObjectListItemEx;
570
571         typedef [gensize] struct {
572                 GUID guid1;
573                 GUID guid2;
574                 drsuapi_DsReplicaObjectIdentifier *naming_context;
575                 drsuapi_DsReplicaHighWaterMark old_highwatermark;
576                 drsuapi_DsReplicaHighWaterMark new_highwatermark;
577                 drsuapi_DsReplicaCoursorCtrEx *uptodateness_vector;
578                 drsuapi_DsGetNCChangesRequest_Ctr12 ctr12;
579                 uint32 unknown1;
580                 uint32 object_count;
581                 /* this +55 is sometimes +56, so I don't know where this comes from... --metze */
582                 [value(ndr_size_drsuapi_DsGetNCChangesCtr1(r,ndr->flags)+55)] uint32 __ndr_size;
583                 drsuapi_DsReplicaObjectListItemEx *first_object;
584                 uint32 unknown4;
585         } drsuapi_DsGetNCChangesCtr1;
586
587         typedef struct {
588                 uint32 decompressed_length;
589                 uint32 compressed_length;
590                 [subcontext(4),subcontext_size(r->compressed_length),compression(NDR_COMPRESSION_MSZIP,compressed_length,decompressed_length)] drsuapi_DsGetNCChangesCtr1 *ctr1;
591         } drsuapi_DsGetNCChangesCompressedInfo;
592
593         typedef struct {
594                 uint32 decompressed_length;
595                 uint32 compressed_length;
596                 [subcontext(4),subcontext_size(r->compressed_length),flag(NDR_REMAINING)] DATA_BLOB *decompressed;
597         } drsuapi_DsGetNCChangesCompressedInfo_Test;
598
599         typedef struct {
600                 drsuapi_DsGetNCChangesCompressedInfo info;
601         } drsuapi_DsGetNCChangesCtr2;
602
603         typedef struct {
604                 GUID guid1;
605                 GUID guid2;
606                 drsuapi_DsReplicaObjectIdentifier *naming_context;
607                 drsuapi_DsReplicaHighWaterMark old_highwatermark;
608                 drsuapi_DsReplicaHighWaterMark new_highwatermark;
609                 drsuapi_DsReplicaCoursor2CtrEx *uptodateness_vector;
610                 drsuapi_DsGetNCChangesRequest_Ctr12 ctr12;
611                 uint32 unknown1;
612                 uint32 unknown2;
613                 uint32 unknown3;
614                 drsuapi_DsReplicaObjectListItemEx *first_object;
615                 uint32 unknown4;
616                 uint32 unknown5;
617                 uint32 unknown6;
618                 uint32 len1;
619                 uint32 array_ptr1;
620                 uint32 unknown7;
621         } drsuapi_DsGetNCChangesCtr6;
622
623         typedef struct {
624                 uint32 unknown1;
625                 uint16 unknown2; /* enum */
626                 drsuapi_DsGetNCChangesCompressedInfo_Test info;
627         } drsuapi_DsGetNCChangesCtr7;
628
629         typedef [switch_type(int32)] union {
630                 [case(1)] drsuapi_DsGetNCChangesCtr1 ctr1;
631                 [case(2)] drsuapi_DsGetNCChangesCtr2 ctr2;
632                 [case(6)] drsuapi_DsGetNCChangesCtr6 ctr6;
633                 [case(7)] drsuapi_DsGetNCChangesCtr7 ctr7;
634         } drsuapi_DsGetNCChangesCtr;
635
636         WERROR drsuapi_DsGetNCChanges(
637                 [in,ref] policy_handle *bind_handle,
638                 [in,out] int32 level,
639                 [in,switch_is(level)] drsuapi_DsGetNCChangesRequest req,
640                 [out,switch_is(level)] drsuapi_DsGetNCChangesCtr ctr
641                 );
642
643         /*****************/
644         /* Function 0x04 */
645         typedef bitmap {
646                 DRSUAPI_DS_REPLICA_UPDATE_ASYNCHRONOUS_OPERATION        = 0x00000001,
647                 DRSUAPI_DS_REPLICA_UPDATE_WRITEABLE                     = 0x00000002,
648                 DRSUAPI_DS_REPLICA_UPDATE_ADD_REFERENCE                 = 0x00000004,
649                 DRSUAPI_DS_REPLICA_UPDATE_DELETE_REFERENCE              = 0x00000008,
650                 DRSUAPI_DS_REPLICA_UPDATE_0x00000010                    = 0x00000010
651         } drsuapi_DsReplicaUpdateRefsOptions;
652
653         typedef struct {
654                 [ref] drsuapi_DsReplicaObjectIdentifier *naming_context;
655                 [ref] ascstr *dest_dsa_dns_name;
656                 GUID dest_dsa_guid;
657                 drsuapi_DsReplicaUpdateRefsOptions options;
658         } drsuapi_DsReplicaUpdateRefsRequest1;
659
660         typedef [switch_type(int32)] union {
661                 [case(1)] drsuapi_DsReplicaUpdateRefsRequest1 req1;
662         } drsuapi_DsReplicaUpdateRefsRequest;
663
664         WERROR drsuapi_DsReplicaUpdateRefs(
665                 [in,ref] policy_handle *bind_handle,
666                 [in] int32 level,
667                 [in,switch_is(level)] drsuapi_DsReplicaUpdateRefsRequest req
668                 );
669
670         /*****************/
671         /* Function 0x05 */
672         typedef bitmap {
673                 DRSUAPI_DS_REPLICA_ADD_ASYNCHRONOUS_OPERATION   = 0x00000001,
674                 DRSUAPI_DS_REPLICA_ADD_WRITEABLE                = 0x00000002
675                 /* TODO ... */
676         } drsuapi_DsReplicaAddOptions;
677
678         WERROR DRSUAPI_REPLICA_ADD();
679
680         /*****************/
681         /* Function 0x06 */
682         typedef bitmap {
683                 DRSUAPI_DS_REPLICA_DELETE_ASYNCHRONOUS_OPERATION        = 0x00000001,
684                 DRSUAPI_DS_REPLICA_DELETE_WRITEABLE                     = 0x00000002
685                 /* TODO ... */
686         } drsuapi_DsReplicaDeleteOptions;
687
688         WERROR DRSUAPI_REPLICA_DEL();
689
690         /*****************/
691         /* Function 0x07 */
692         typedef bitmap {
693                 DRSUAPI_DS_REPLICA_MODIFY_ASYNCHRONOUS_OPERATION        = 0x00000001,
694                 DRSUAPI_DS_REPLICA_MODIFY_WRITEABLE                     = 0x00000002
695         } drsuapi_DsReplicaModifyOptions;
696
697         WERROR DRSUAPI_REPLICA_MODIFY();
698
699         /*****************/
700         /* Function 0x08 */
701         WERROR DRSUAPI_VERIFY_NAMES();
702
703         /*****************/
704         /* Function 0x09 */
705         WERROR DRSUAPI_GET_MEMBERSHIPS();
706
707         /*****************/
708         /* Function 0x0a */
709         WERROR DRSUAPI_INTER_DOMAIN_MOVE();
710
711         /*****************/
712         /* Function 0x0b */
713         WERROR DRSUAPI_GET_NT4_CHANGELOG();
714
715         /*****************/
716         /* Function 0x0c */
717         typedef [v1_enum] enum {
718                 DRSUAPI_DS_NAME_STATUS_OK                       = 0,
719                 DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR            = 1,
720                 DRSUAPI_DS_NAME_STATUS_NOT_FOUND                = 2,
721                 DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE               = 3,
722                 DRSUAPI_DS_NAME_STATUS_NO_MAPPING               = 4,
723                 DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY              = 5,
724                 DRSUAPI_DS_NAME_STATUS_NO_SYNTACTICAL_MAPPING   = 6,
725                 DRSUAPI_DS_NAME_STATUS_TRUST_REFERRAL           = 7
726         } drsuapi_DsNameStatus;
727
728         typedef [v1_enum] enum {
729                 DRSUAPI_DS_NAME_FLAG_NO_FLAGS                   = 0x0,
730                 DRSUAPI_DS_NAME_FLAG_SYNTACTICAL_ONLY           = 0x1,
731                 DRSUAPI_DS_NAME_FLAG_EVAL_AT_DC                 = 0x2,
732                 DRSUAPI_DS_NAME_FLAG_GCVERIFY                   = 0x4,
733                 DRSUAPI_DS_NAME_FLAG_TRUST_REFERRAL             = 0x8
734         } drsuapi_DsNameFlags;
735
736         typedef [v1_enum] enum {
737                 DRSUAPI_DS_NAME_FORMAT_UKNOWN                   = 0,
738                 DRSUAPI_DS_NAME_FORMAT_FQDN_1779                = 1,
739                 DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT              = 2,
740                 DRSUAPI_DS_NAME_FORMAT_DISPLAY                  = 3,
741                 DRSUAPI_DS_NAME_FORMAT_GUID                     = 6,
742                 DRSUAPI_DS_NAME_FORMAT_CANONICAL                = 7,
743                 DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL           = 8,
744                 DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX             = 9,
745                 DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL        = 10,
746                 DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY       = 11,
747                 DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN               = 12
748         } drsuapi_DsNameFormat;
749
750         typedef struct {
751                 unistr *str;
752         } drsuapi_DsNameString;
753
754         typedef struct {
755                 uint32 unknown1; /* 0x000004e4 */
756                 uint32 unknown2; /* 0x00000407 */
757                 drsuapi_DsNameFlags format_flags;
758                 drsuapi_DsNameFormat format_offered;
759                 drsuapi_DsNameFormat format_desired;
760                 [range(1,10000)] uint32 count;
761                 [size_is(count)] drsuapi_DsNameString *names;
762         } drsuapi_DsNameRequest1;
763
764         typedef [switch_type(int32)] union {
765                 [case(1)] drsuapi_DsNameRequest1 req1;
766         } drsuapi_DsNameRequest;
767
768         typedef struct {
769                 drsuapi_DsNameStatus status;
770                 unistr *dns_domain_name;
771                 unistr *result_name;
772         } drsuapi_DsNameInfo1;
773
774         typedef struct {
775                 uint32 count;
776                 [size_is(count)] drsuapi_DsNameInfo1 *array;
777         } drsuapi_DsNameCtr1;
778
779         typedef [switch_type(int32)] union {
780                 [case(1)] drsuapi_DsNameCtr1 *ctr1;
781         } drsuapi_DsNameCtr;
782
783         WERROR drsuapi_DsCrackNames(
784                 [in,ref] policy_handle *bind_handle,
785                 [in, out] int32 level,
786                 [in,switch_is(level)] drsuapi_DsNameRequest req,
787                 [out,switch_is(level)] drsuapi_DsNameCtr ctr
788                 );
789
790         /*****************/
791         /* Function 0x0d */
792         typedef [v1_enum] enum {
793                 DRSUAPI_DS_SPN_OPERATION_ADD    = 0,
794                 DRSUAPI_DS_SPN_OPERATION_REPLACE= 1,
795                 DRSUAPI_DS_SPN_OPERATION_DELETE = 2
796         } drsuapi_DsSpnOperation;
797
798         typedef struct {
799                 drsuapi_DsSpnOperation operation;
800                 uint32 unknown1;
801                 unistr *object_dn;
802                 [range(0,10000)] uint32 count;
803                 [size_is(count)] drsuapi_DsNameString *spn_names;
804         } drsuapi_DsWriteAccountSpnRequest1;
805
806         typedef [switch_type(int32)] union {
807                 [case(1)] drsuapi_DsWriteAccountSpnRequest1 req1;
808         } drsuapi_DsWriteAccountSpnRequest;
809
810         typedef struct {
811                 WERROR status;
812         } drsuapi_DsWriteAccountSpnResult1;
813
814         typedef [switch_type(int32)] union {
815                 [case(1)] drsuapi_DsWriteAccountSpnResult1 res1;
816         } drsuapi_DsWriteAccountSpnResult;
817
818         WERROR drsuapi_DsWriteAccountSpn(
819                 [in,ref] policy_handle *bind_handle,
820                 [in, out] int32 level,
821                 [in,switch_is(level)] drsuapi_DsWriteAccountSpnRequest req,
822                 [out,switch_is(level)] drsuapi_DsWriteAccountSpnResult res
823                 );
824
825         /*****************/
826         /* Function 0x0e */
827         WERROR DRSUAPI_REMOVE_DS_SERVER();
828
829         /*****************/
830         /* Function 0x0f */
831         WERROR DRSUAPI_REMOVE_DS_DOMAIN();
832
833         /*****************/
834         /* Function 0x10 */
835         typedef struct {
836                 unistr *domain_name; /* netbios or dns */
837                 int32 level; /* specifies the switch level for the request */
838         } drsuapi_DsGetDCInfoRequest1;
839
840         typedef [switch_type(int32)] union {
841                 [case(1)] drsuapi_DsGetDCInfoRequest1 req1;
842         } drsuapi_DsGetDCInfoRequest;
843
844         typedef struct {
845                 unistr *netbios_name;
846                 unistr *dns_name;
847                 unistr *site_name;
848                 unistr *computer_dn;
849                 unistr *server_dn;
850                 uint32 is_pdc;
851                 uint32 is_enabled;
852         } drsuapi_DsGetDCInfo1;
853
854         typedef struct {
855                 [range(0,10000)] uint32 count;
856                 [size_is(count)] drsuapi_DsGetDCInfo1 *array;
857         } drsuapi_DsGetDCInfoCtr1;
858
859         typedef struct {
860                 unistr *netbios_name;
861                 unistr *dns_name;
862                 unistr *site_name;
863                 unistr *site_dn;
864                 unistr *computer_dn;
865                 unistr *server_dn;
866                 unistr *ntds_dn;
867                 uint32 is_pdc;
868                 uint32 is_enabled;
869                 uint32 is_gc;
870                 GUID site_guid;
871                 GUID computer_guid;
872                 GUID server_guid;
873                 GUID ntds_guid;
874         } drsuapi_DsGetDCInfo2;
875
876         typedef struct {
877                 [range(0,10000)] uint32 count;
878                 [size_is(count)] drsuapi_DsGetDCInfo2 *array;
879         } drsuapi_DsGetDCInfoCtr2;
880
881         typedef struct {
882                 uint32 unknown1;
883                 uint32 unknown2;
884                 uint32 unknown3;
885                 uint32 unknown4;
886                 uint32 unknown5;
887                 uint32 unknown6;
888                 unistr *server_nt4_account;
889         } drsuapi_DsGetDCInfo01;
890
891         typedef struct {
892                 [range(0,10000)] uint32 count;
893                 [size_is(count)] drsuapi_DsGetDCInfo01 *array;
894         } drsuapi_DsGetDCInfoCtr01;
895
896         typedef [v1_enum] enum {
897                 DRSUAPI_DC_INFO_CTR_1  = 1,
898                 DRSUAPI_DC_INFO_CTR_2  = 2,
899                 DRSUAPI_DC_INFO_CTR_01 = -1
900         } drsuapi_DsGetDCInfoCtrLevels;
901
902         typedef [switch_type(int32)] union {
903                 [case(DRSUAPI_DC_INFO_CTR_1)]  drsuapi_DsGetDCInfoCtr1  ctr1;
904                 [case(DRSUAPI_DC_INFO_CTR_2)]  drsuapi_DsGetDCInfoCtr2  ctr2;
905                 [case(DRSUAPI_DC_INFO_CTR_01)] drsuapi_DsGetDCInfoCtr01 ctr01;
906         } drsuapi_DsGetDCInfoCtr;
907
908         WERROR drsuapi_DsGetDomainControllerInfo(
909                 [in,ref] policy_handle *bind_handle,
910                 [in, out] int32 level,
911                 [in,switch_is(level)] drsuapi_DsGetDCInfoRequest req,
912                 [out,switch_is(level)] drsuapi_DsGetDCInfoCtr ctr
913                 );
914
915         /*****************/
916         /* Function 0x11 */
917         typedef [public,noprint] struct {
918                 drsuapi_DsReplicaObjectListItem *next_object;
919                 drsuapi_DsReplicaObject object;
920         } drsuapi_DsReplicaObjectListItem;
921
922         /*
923          * please note the the current idl
924          * for DsAddEntry does only parse 
925          * what I saw between 2 w2k3 boxes
926          * in my dssync experiments I got some other replies
927          * so all I want to say is that this is very incomplete yet...
928          * --metze
929          */
930         typedef struct {
931                 drsuapi_DsReplicaObjectListItem first_object;
932         } drsuapi_DsAddEntryRequest2;
933
934         typedef [switch_type(int32)] union {
935                 [case(2)] drsuapi_DsAddEntryRequest2 req2;
936         } drsuapi_DsAddEntryRequest;
937
938         typedef struct {
939                 uint32 unknown1;
940                 uint32 unknown2;
941                 uint32 unknown3;
942         } drsuapi_DsAddEntryCtr3Info1;
943
944         typedef [switch_type(uint32)] union {
945                 [case(1)] drsuapi_DsAddEntryCtr3Info1 info1;
946         } drsuapi_DsAddEntryCtr3Info;
947
948         typedef struct {
949                 GUID guid;
950                 dom_sid28 sid;
951         } drsuapi_DsReplicaObjectIdentifier2;
952
953         typedef struct {
954                 drsuapi_DsReplicaObjectIdentifier *id;
955                 uint32 level;
956                 [switch_is(level)] drsuapi_DsAddEntryCtr3Info *info;
957                 [range(0,10000)] uint32 count;
958                 [size_is(count)] drsuapi_DsReplicaObjectIdentifier2 *objects;
959         } drsuapi_DsAddEntryCtr3;
960
961         typedef [switch_type(int32)] union {
962                 [case(3)] drsuapi_DsAddEntryCtr3 ctr3;
963         } drsuapi_DsAddEntryCtr;
964
965         WERROR drsuapi_DsAddEntry(
966                 [in,ref] policy_handle *bind_handle,
967                 [in,out] int32 level,
968                 [in,switch_is(level)] drsuapi_DsAddEntryRequest req,
969                 [out,switch_is(level)] drsuapi_DsAddEntryCtr ctr
970                 );
971
972         /*****************/
973         /* Function 0x12 */
974         WERROR DRSUAPI_EXECUTE_KCC();
975
976         /*****************/
977         /* Function 0x13 */
978         typedef [v1_enum] enum {
979                 DRSUAPI_DS_REPLICA_GET_INFO                             = 1,
980                 DRSUAPI_DS_REPLICA_GET_INFO2                            = 2
981         } drsuapi_DsReplicaGetInfoLevel;
982
983         typedef [v1_enum] enum {
984                 DRSUAPI_DS_REPLICA_INFO_NEIGHBORS                       = 0,
985                 DRSUAPI_DS_REPLICA_INFO_CURSORS                         = 1,
986                 DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA                    = 2,
987                 DRSUAPI_DS_REPLICA_INFO_KCC_DSA_CONNECT_FAILURES        = 3,
988                 DRSUAPI_DS_REPLICA_INFO_KCC_DSA_LINK_FAILURES           = 4,
989                 DRSUAPI_DS_REPLICA_INFO_PENDING_OPS                     = 5,
990                 DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA        = 6,
991                 DRSUAPI_DS_REPLICA_INFO_CURSORS2                        = 7,
992                 DRSUAPI_DS_REPLICA_INFO_CURSORS3                        = 8,
993                 DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA2                   = 9,
994                 DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA2       = 10,
995                 DRSUAPI_DS_REPLICA_INFO_NEIGHBORS02                     = -2,
996                 DRSUAPI_DS_REPLICA_INFO_CONNECTIONS04                   = -4,
997                 DRSUAPI_DS_REPLICA_INFO_CURSURS05                       = -5,
998                 DRSUAPI_DS_REPLICA_INFO_06                              = -6
999         } drsuapi_DsReplicaInfoType;
1000
1001         typedef struct {
1002                 drsuapi_DsReplicaInfoType info_type;
1003                 unistr *object_dn;
1004                 GUID guid1;
1005         } drsuapi_DsReplicaGetInfoRequest1;
1006
1007         typedef struct {
1008                 drsuapi_DsReplicaInfoType info_type;
1009                 unistr *object_dn;
1010                 GUID guid1;
1011                 uint32 unknown1;
1012                 unistr *string1;
1013                 unistr *string2;
1014                 uint32 unknown2;
1015         } drsuapi_DsReplicaGetInfoRequest2;
1016
1017         typedef [switch_type(drsuapi_DsReplicaGetInfoLevel)] union {
1018                 [case(DRSUAPI_DS_REPLICA_GET_INFO)] drsuapi_DsReplicaGetInfoRequest1 req1;
1019                 [case(DRSUAPI_DS_REPLICA_GET_INFO2)] drsuapi_DsReplicaGetInfoRequest2 req2;
1020         } drsuapi_DsReplicaGetInfoRequest;
1021
1022         typedef struct {
1023                 unistr *naming_context_dn;
1024                 unistr *source_dsa_obj_dn;
1025                 unistr *source_dsa_address;
1026                 unistr *transport_obj_dn;
1027                 drsuapi_DsReplicaNeighbourFlags replica_flags;
1028                 uint32 reserved;
1029                 GUID naming_context_obj_guid;
1030                 GUID source_dsa_obj_guid;
1031                 GUID source_dsa_invocation_id;
1032                 GUID transport_obj_guid;
1033                 hyper tmp_highest_usn;
1034                 hyper highest_usn;
1035                 NTTIME last_success;
1036                 NTTIME last_attempt;
1037                 WERROR result_last_attempt;
1038                 uint32 consecutive_sync_failures;
1039         } drsuapi_DsReplicaNeighbour;
1040
1041         typedef struct {
1042                 uint32 count;
1043                 uint32 reserved;
1044                 [size_is(count)] drsuapi_DsReplicaNeighbour array[];
1045         } drsuapi_DsReplicaNeighbourCtr;
1046
1047         typedef struct {
1048                 uint32 count;
1049                 uint32 reserved;
1050                 [size_is(count)] drsuapi_DsReplicaCoursor array[];
1051         } drsuapi_DsReplicaCoursorCtr;
1052
1053         typedef struct {
1054                 unistr *attribute_name;
1055                 uint32 version;
1056                 NTTIME originating_last_changed;
1057                 GUID originating_dsa_invocation_id;
1058                 hyper originating_usn;
1059                 hyper local_usn;
1060         } drsuapi_DsReplicaObjMetaData;
1061
1062         typedef struct {
1063                 uint32 count;
1064                 uint32 reserved;
1065                 [size_is(count)] drsuapi_DsReplicaObjMetaData array[];
1066         } drsuapi_DsReplicaObjMetaDataCtr;
1067
1068         typedef struct {
1069                 unistr *dsa_obj_dn;
1070                 GUID dsa_obj_guid;
1071                 NTTIME first_failure;
1072                 uint32 num_failures;
1073                 WERROR last_result;
1074         } drsuapi_DsReplicaKccDsaFailure;
1075
1076         typedef struct {
1077                 uint32 count;
1078                 uint32 reserved;
1079                 [size_is(count)] drsuapi_DsReplicaKccDsaFailure array[];
1080         } drsuapi_DsReplicaKccDsaFailuresCtr;
1081
1082         typedef enum {
1083                 DRSUAPI_DS_REPLICA_OP_TYPE_SYNC         = 0,
1084                 DRSUAPI_DS_REPLICA_OP_TYPE_ADD          = 1,
1085                 DRSUAPI_DS_REPLICA_OP_TYPE_DELETE       = 2,
1086                 DRSUAPI_DS_REPLICA_OP_TYPE_MODIFY       = 3,
1087                 DRSUAPI_DS_REPLICA_OP_TYPE_UPDATE_REFS  = 4
1088         } drsuapi_DsReplicaOpType;
1089
1090         typedef [switch_type(drsuapi_DsReplicaOpType)] union {
1091                 [case(DRSUAPI_DS_REPLICA_OP_TYPE_SYNC)]         drsuapi_DsReplicaSyncOptions sync;
1092                 [case(DRSUAPI_DS_REPLICA_OP_TYPE_ADD)]          drsuapi_DsReplicaAddOptions add;
1093                 [case(DRSUAPI_DS_REPLICA_OP_TYPE_DELETE)]       drsuapi_DsReplicaDeleteOptions delete;
1094                 [case(DRSUAPI_DS_REPLICA_OP_TYPE_MODIFY)]       drsuapi_DsReplicaModifyOptions modify;
1095                 [case(DRSUAPI_DS_REPLICA_OP_TYPE_UPDATE_REFS)]  drsuapi_DsReplicaUpdateRefsOptions update_refs;
1096                 [default] uint32 unknown;
1097         } drsuapi_DsRplicaOpOptions;
1098
1099         typedef struct {
1100                 NTTIME operation_start;
1101                 uint32 serial_num; /* unique till reboot */
1102                 uint32 priority;
1103                 drsuapi_DsReplicaOpType operation_type;
1104                 [switch_is(operation_type)] drsuapi_DsRplicaOpOptions options;
1105                 unistr *nc_dn;
1106                 unistr *remote_dsa_obj_dn;
1107                 unistr *remote_dsa_address;
1108                 GUID nc_obj_guid;
1109                 GUID remote_dsa_obj_guid;
1110         } drsuapi_DsReplicaOp;
1111
1112         typedef struct {
1113                 NTTIME time;
1114                 uint32 count;
1115                 [size_is(count)] drsuapi_DsReplicaOp array[];
1116         } drsuapi_DsReplicaOpCtr;
1117
1118         typedef struct {
1119                 unistr *attribute_name;
1120                 unistr *object_dn;
1121                 uint32 value_length;
1122                 [size_is(value_length)] uint8 *value;
1123                 NTTIME deleted;
1124                 NTTIME created;
1125                 uint32 version;
1126                 NTTIME originating_last_changed;
1127                 GUID originating_dsa_invocation_id;
1128                 hyper originating_usn;
1129                 hyper local_usn;
1130         } drsuapi_DsReplicaAttrValMetaData;
1131
1132         typedef struct {
1133                 uint32 count;
1134                 int32 enumeration_context;
1135                 [size_is(count)] drsuapi_DsReplicaAttrValMetaData array[];
1136         } drsuapi_DsReplicaAttrValMetaDataCtr;
1137
1138         typedef struct {
1139                 uint32 count;
1140                 int32 enumeration_context;
1141                 [size_is(count)] drsuapi_DsReplicaCoursor2 array[];
1142         } drsuapi_DsReplicaCoursor2Ctr;
1143
1144         typedef struct {
1145                 GUID source_dsa_invocation_id;
1146                 hyper highest_usn;
1147                 NTTIME last_sync_success;
1148                 unistr *source_dsa_obj_dn;
1149         } drsuapi_DsReplicaCoursor3;
1150
1151         typedef struct {
1152                 uint32 count;
1153                 int32 enumeration_context;
1154                 [size_is(count)] drsuapi_DsReplicaCoursor3 array[];
1155         } drsuapi_DsReplicaCoursor3Ctr;
1156
1157         typedef struct {
1158                 unistr *attribute_name;
1159                 uint32 version;
1160                 NTTIME originating_last_changed;
1161                 GUID originating_dsa_invocation_id;
1162                 hyper originating_usn;
1163                 hyper local_usn;
1164                 unistr *originating_dsa_obj_dn;
1165         } drsuapi_DsReplicaObjMetaData2;
1166
1167         typedef struct {
1168                 uint32 count;
1169                 int32 enumeration_context;
1170                 [size_is(count)] drsuapi_DsReplicaObjMetaData2 array[];
1171         } drsuapi_DsReplicaObjMetaData2Ctr;
1172
1173         typedef struct {
1174                 unistr *attribute_name;
1175                 unistr *object_dn;
1176                 uint32 value_length;
1177                 [size_is(value_length)] uint8 *value;
1178                 NTTIME deleted;
1179                 NTTIME created;
1180                 uint32 version;
1181                 NTTIME originating_last_changed;
1182                 GUID originating_dsa_invocation_id;
1183                 hyper originating_usn;
1184                 hyper local_usn;
1185                 unistr *originating_dsa_obj_dn;
1186         } drsuapi_DsReplicaAttrValMetaData2;
1187
1188         typedef struct {
1189                 uint32 count;
1190                 int32 enumeration_context;
1191                 [size_is(count)] drsuapi_DsReplicaAttrValMetaData2 array[];
1192         } drsuapi_DsReplicaAttrValMetaData2Ctr;
1193
1194         typedef struct {
1195                 hyper u1; /* session number? */
1196                 uint32 u2;
1197                 uint32 u3;
1198                 GUID bind_guid;
1199                 NTTIME_1sec bind_time;
1200                 uint32 u4; /* flags? */
1201                 uint32 u5;
1202         } drsuapi_DsReplicaConnection04;
1203
1204         typedef struct {
1205                 [range(0,10000)] uint32 count;
1206                 uint32 reserved;
1207                 [size_is(count)] drsuapi_DsReplicaConnection04 array[];
1208         } drsuapi_DsReplicaConnection04Ctr;
1209
1210         typedef struct {
1211                 unistr *str1;
1212                 uint32 u1;
1213                 uint32 u2;
1214                 uint32 u3;
1215                 uint32 u4;
1216                 uint32 u5;
1217                 hyper u6;
1218                 uint32 u7;
1219         } drsuapi_DsReplica06;
1220
1221         typedef struct {
1222                 [range(0,256)] uint32 count;
1223                 uint32 reserved;
1224                 [size_is(count)] drsuapi_DsReplica06 array[];
1225         } drsuapi_DsReplica06Ctr;
1226
1227         typedef [switch_type(drsuapi_DsReplicaInfoType)] union {
1228                 [case(DRSUAPI_DS_REPLICA_INFO_NEIGHBORS)] drsuapi_DsReplicaNeighbourCtr *neighbours;
1229                 [case(DRSUAPI_DS_REPLICA_INFO_CURSORS)] drsuapi_DsReplicaCoursorCtr *coursors;
1230                 [case(DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA)] drsuapi_DsReplicaObjMetaDataCtr *objmetadata;
1231                 [case(DRSUAPI_DS_REPLICA_INFO_KCC_DSA_CONNECT_FAILURES)] drsuapi_DsReplicaKccDsaFailuresCtr *connectfailures;
1232                 [case(DRSUAPI_DS_REPLICA_INFO_KCC_DSA_LINK_FAILURES)] drsuapi_DsReplicaKccDsaFailuresCtr *linkfailures;
1233                 [case(DRSUAPI_DS_REPLICA_INFO_PENDING_OPS)] drsuapi_DsReplicaOpCtr *pendingops;
1234                 [case(DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA)] drsuapi_DsReplicaAttrValMetaDataCtr *attrvalmetadata;
1235                 [case(DRSUAPI_DS_REPLICA_INFO_CURSORS2)] drsuapi_DsReplicaCoursor2Ctr *coursors2;
1236                 [case(DRSUAPI_DS_REPLICA_INFO_CURSORS3)] drsuapi_DsReplicaCoursor3Ctr *coursors3;
1237                 [case(DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA2)] drsuapi_DsReplicaObjMetaData2Ctr *objmetadata2;
1238                 [case(DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA2)] drsuapi_DsReplicaAttrValMetaData2Ctr *attrvalmetadata2;
1239                 [case(DRSUAPI_DS_REPLICA_INFO_NEIGHBORS02)] drsuapi_DsReplicaNeighbourCtr *neighbours02;
1240                 [case(DRSUAPI_DS_REPLICA_INFO_CONNECTIONS04)] drsuapi_DsReplicaConnection04Ctr *connections04;
1241                 [case(DRSUAPI_DS_REPLICA_INFO_CURSURS05)] drsuapi_DsReplicaCoursorCtrEx *coursors05;
1242                 [case(DRSUAPI_DS_REPLICA_INFO_06)] drsuapi_DsReplica06Ctr *i06;
1243         } drsuapi_DsReplicaInfo;
1244
1245         WERROR drsuapi_DsReplicaGetInfo(
1246                 [in,ref] policy_handle *bind_handle,
1247                 [in] drsuapi_DsReplicaGetInfoLevel level,
1248                 [in,switch_is(level)] drsuapi_DsReplicaGetInfoRequest req,
1249                 [out] drsuapi_DsReplicaInfoType info_type,
1250                 [out,switch_is(info_type)] drsuapi_DsReplicaInfo info
1251                 );
1252
1253         /*****************/
1254         /* Function 0x14 */
1255         WERROR DRSUAPI_ADD_SID_HISTORY();
1256
1257         /*****************/
1258         /* Function 0x15 */
1259         WERROR DRSUAPI_GET_MEMBERSHIPS2();
1260
1261         /*****************/
1262         /* Function 0x16 */
1263         WERROR DRSUAPI_REPLICA_VERIFY_OBJECTS();
1264
1265         /*****************/
1266         /* Function 0x17 */
1267         WERROR DRSUAPI_GET_OBJECT_EXISTENCE();
1268
1269         /*****************/
1270         /* Function 0x18 */
1271         WERROR DRSUAPI_QUERY_SITES_BY_COST();
1272 }