s4/idl: add DRSUAPI_SUPPORTED_EXTENSION_RECYCLE_BIN ext. flag for DRSUAPI
[ira/wip.git] / librpc / idl / drsuapi.idl
1 #include "idl_types.h"
2
3 import "security.idl", "misc.idl", "samr.idl";
4
5 [
6   uuid("e3514235-4b06-11d1-ab04-00c04fc2dcd2"),
7   version(4.0),
8   endpoint("ncacn_np:[\\pipe\\lsass]","ncacn_np:[\\pipe\\protected_storage]", "ncacn_ip_tcp:", "ncalrpc:"),
9   authservice("ldap"),
10   helpstring("Active Directory Replication"),
11   helper("../librpc/ndr/ndr_drsuapi.h"),
12   pointer_default(unique)
13 ]
14 interface drsuapi
15 {
16         typedef bitmap samr_GroupAttrs samr_GroupAttrs;
17
18         /* see MS-DRSR section 5.39 */
19         typedef [public,bitmap32bit] bitmap {
20                 DRSUAPI_DRS_ASYNC_OP                  = 0x00000001,
21                 DRSUAPI_DRS_GETCHG_CHECK              = 0x00000002,
22                 DRSUAPI_DRS_UPDATE_NOTIFICATION       = 0x00000002,
23                 DRSUAPI_DRS_ADD_REF                   = 0x00000004,
24                 DRSUAPI_DRS_SYNC_ALL                  = 0x00000008,
25                 DRSUAPI_DRS_DEL_REF                   = 0x00000008,
26                 DRSUAPI_DRS_WRIT_REP                  = 0x00000010,
27                 DRSUAPI_DRS_INIT_SYNC                 = 0x00000020,
28                 DRSUAPI_DRS_PER_SYNC                  = 0x00000040,
29                 DRSUAPI_DRS_MAIL_REP                  = 0x00000080,
30                 DRSUAPI_DRS_ASYNC_REP                 = 0x00000100,
31                 DRSUAPI_DRS_IGNORE_ERROR              = 0x00000100,
32                 DRSUAPI_DRS_TWOWAY_SYNC               = 0x00000200,
33                 DRSUAPI_DRS_CRITICAL_ONLY             = 0x00000400,
34                 DRSUAPI_DRS_GET_ANC                   = 0x00000800,
35                 DRSUAPI_DRS_GET_NC_SIZE               = 0x00001000,
36                 DRSUAPI_DRS_LOCAL_ONLY                = 0x00001000,
37                 DRSUAPI_DRS_SYNC_BYNAME               = 0x00004000,
38                 DRSUAPI_DRS_REF_OK                    = 0x00004000,
39                 DRSUAPI_DRS_FULL_SYNC_NOW             = 0x00008000,
40                 DRSUAPI_DRS_NO_SOURCE                 = 0x00008000,
41                 DRSUAPI_DRS_FULL_SYNC_IN_PROGRESS     = 0x00010000,
42                 DRSUAPI_DRS_FULL_SYNC_PACKET          = 0x00020000,
43                 DRSUAPI_DRS_SYNC_REQUEUE              = 0x00040000,
44                 DRSUAPI_DRS_SYNC_URGENT               = 0x00080000,
45                 DRSUAPI_DRS_REF_GCSPN                 = 0x00100000,
46                 DRSUAPI_DRS_NO_DISCARD                = 0x00100000,
47                 DRSUAPI_DRS_NEVER_SYNCED              = 0x00200000,
48                 DRSUAPI_DRS_SPECIAL_SECRET_PROCESSING = 0x00400000,
49                 DRSUAPI_DRS_INIT_SYNC_NOW             = 0x00800000,
50                 DRSUAPI_DRS_PREEMPTED                 = 0x01000000,
51                 DRSUAPI_DRS_SYNC_FORCED               = 0x02000000,
52                 DRSUAPI_DRS_DISABLE_AUTO_SYNC         = 0x04000000,
53                 DRSUAPI_DRS_DISABLE_PERIODIC_SYNC     = 0x08000000,
54                 DRSUAPI_DRS_USE_COMPRESSION           = 0x10000000,
55                 DRSUAPI_DRS_NEVER_NOTIFY              = 0x20000000,
56                 DRSUAPI_DRS_SYNC_PAS                  = 0x40000000,
57                 DRSUAPI_DRS_GET_ALL_GROUP_MEMBERSHIP  = 0x80000000
58         } drsuapi_DrsOptions;
59
60         /*****************/
61         /* Function 0x00 */
62         typedef [bitmap32bit] bitmap {
63                 DRSUAPI_SUPPORTED_EXTENSION_BASE                        = 0x00000001,
64                 DRSUAPI_SUPPORTED_EXTENSION_ASYNC_REPLICATION           = 0x00000002,
65                 DRSUAPI_SUPPORTED_EXTENSION_REMOVEAPI                   = 0x00000004,
66                 DRSUAPI_SUPPORTED_EXTENSION_MOVEREQ_V2                  = 0x00000008,
67                 DRSUAPI_SUPPORTED_EXTENSION_GETCHG_COMPRESS             = 0x00000010,
68                 DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V1                   = 0x00000020,
69                 DRSUAPI_SUPPORTED_EXTENSION_RESTORE_USN_OPTIMIZATION    = 0x00000040,
70                 DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY                    = 0x00000080,
71                 DRSUAPI_SUPPORTED_EXTENSION_KCC_EXECUTE                 = 0x00000100,
72                 DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY_V2                 = 0x00000200,
73                 DRSUAPI_SUPPORTED_EXTENSION_LINKED_VALUE_REPLICATION    = 0x00000400,
74                 DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V2                   = 0x00000800,
75                 DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD= 0x00001000,
76                 DRSUAPI_SUPPORTED_EXTENSION_CRYPTO_BIND                 = 0x00002000,
77                 DRSUAPI_SUPPORTED_EXTENSION_GET_REPL_INFO               = 0x00004000,
78                 DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION           = 0x00008000,
79                 DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V01                  = 0x00010000,
80                 DRSUAPI_SUPPORTED_EXTENSION_TRANSITIVE_MEMBERSHIP       = 0x00020000,
81                 DRSUAPI_SUPPORTED_EXTENSION_ADD_SID_HISTORY             = 0x00040000,
82                 DRSUAPI_SUPPORTED_EXTENSION_POST_BETA3                  = 0x00080000,
83                 DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V5                = 0x00100000,
84                 DRSUAPI_SUPPORTED_EXTENSION_GET_MEMBERSHIPS2            = 0x00200000,
85                 DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V6                = 0x00400000,
86                 DRSUAPI_SUPPORTED_EXTENSION_NONDOMAIN_NCS               = 0x00800000,
87                 DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8                = 0x01000000,
88                 DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V5              = 0x02000000,
89                 DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V6              = 0x04000000,
90                 /*
91                  * the following 3 have the same value
92                  * repadmin.exe /bind says that
93                  */
94                 DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3            = 0x08000000,
95                 DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V7              = 0x08000000,
96                 DRSUAPI_SUPPORTED_EXTENSION_VERIFY_OBJECT               = 0x08000000,
97                 DRSUAPI_SUPPORTED_EXTENSION_XPRESS_COMPRESS             = 0x10000000,
98                 DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V10               = 0x20000000,
99                 DRSUAPI_SUPPORTED_EXTENSION_40000000                    = 0x40000000,
100                 DRSUAPI_SUPPORTED_EXTENSION_80000000                    = 0x80000000
101         } drsuapi_SupportedExtensions;
102
103         typedef [bitmap32bit] bitmap {
104                 DRSUAPI_SUPPORTED_EXTENSION_ADAM                        = 0x00000001,
105                 DRSUAPI_SUPPORTED_EXTENSION_LH_BETA2                    = 0x00000002,
106                 DRSUAPI_SUPPORTED_EXTENSION_RECYCLE_BIN                 = 0x00000004
107         } drsuapi_SupportedExtensionsExt;
108
109         /* this is used by w2k */
110         typedef struct {
111                 drsuapi_SupportedExtensions supported_extensions;
112                 GUID site_guid;
113                 uint32 pid;
114         } drsuapi_DsBindInfo24;
115
116         /* this is used by w2k3 */
117         typedef struct {
118                 drsuapi_SupportedExtensions supported_extensions;
119                 GUID site_guid;
120                 uint32 pid;
121                 uint32 repl_epoch;
122         } drsuapi_DsBindInfo28;
123
124         /* this is used by w2k8 */
125         typedef struct {
126                 drsuapi_SupportedExtensions supported_extensions;
127                 GUID site_guid;
128                 uint32 pid;
129                 uint32 repl_epoch;
130                 drsuapi_SupportedExtensionsExt supported_extensions_ext;
131                 GUID config_dn_guid;
132         } drsuapi_DsBindInfo48;
133
134         typedef struct {
135                 [flag(NDR_REMAINING)] DATA_BLOB info;
136         } drsuapi_DsBindInfoFallBack;
137
138         typedef [nodiscriminant] union {
139                 [case(24)][subcontext(4)] drsuapi_DsBindInfo24 info24;
140                 [case(28)][subcontext(4)] drsuapi_DsBindInfo28 info28;
141                 [case(48)][subcontext(4)] drsuapi_DsBindInfo48 info48;
142                 [default][subcontext(4)] drsuapi_DsBindInfoFallBack FallBack;
143         } drsuapi_DsBindInfo;
144
145         /* the drsuapi_DsBindInfoCtr was this before
146          * typedef [flag(NDR_PAHEX)] struct {
147          *      [range(1,10000)] uint32 length;
148          *      [size_is(length)] uint8 data[];
149          * } drsuapi_DsBindInfo;
150          *
151          * but we don't want the caller to manually decode this blob,
152          * so we're doing it here
153          */
154
155         typedef struct {
156                 [range(1,10000)] uint32 length;
157                 [switch_is(length)] drsuapi_DsBindInfo info;
158         } drsuapi_DsBindInfoCtr;
159
160         /* this is a magic guid you need to pass to DsBind to make drsuapi_DsWriteAccountSpn() work
161          *
162          * maybe the bind_guid could also be the invocation_id see drsuapi_DsReplicaConnection04
163          */
164         const char *DRSUAPI_DS_BIND_GUID = "e24d201a-4fd6-11d1-a3da-0000f875ae0d";
165         /*
166          * this magic guid are needed to fetch the whole tree with drsuapi_DsGetNCChanges()
167          * as administrator and this values are also used in the destination_dsa_guid field
168          * of drsuapi_DsGetNCChangesReq5/8 and the source_dsa_guid is zero.
169          */
170         const char *DRSUAPI_DS_BIND_GUID_W2K    = "6abec3d1-3054-41c8-a362-5a0c5b7d5d71";
171         const char *DRSUAPI_DS_BIND_GUID_W2K3   = "6afab99c-6e26-464a-975f-f58f105218bc";
172
173         [public] WERROR drsuapi_DsBind(
174                 [in,unique]         GUID *bind_guid,
175                 [in,out,unique]    drsuapi_DsBindInfoCtr *bind_info,
176                 [out]   policy_handle *bind_handle
177                 );
178
179         /*****************/
180         /* Function 0x01 */
181         WERROR drsuapi_DsUnbind(
182                 [in,out] policy_handle *bind_handle
183                 );
184
185         /*****************/
186         /* Function 0x02 */
187         typedef [public,gensize] struct {
188                 [value(ndr_size_drsuapi_DsReplicaObjectIdentifier(r, ndr->iconv_convenience, ndr->flags)-4)] uint32 __ndr_size;
189                 [value(ndr_size_dom_sid28(&sid, ndr->flags))]  uint32 __ndr_size_sid;
190                 GUID guid;
191                 dom_sid28 sid;
192                 [value(strlen_m(dn))] uint32 __ndr_size_dn;
193                 [charset(UTF16),size_is(__ndr_size_dn+1)] uint16 dn[];
194         } drsuapi_DsReplicaObjectIdentifier;
195
196         typedef [public] bitmap {
197                 DRSUAPI_DS_REPLICA_SYNC_ASYNCHRONOUS_OPERATION  = 0x00000001,
198                 DRSUAPI_DS_REPLICA_SYNC_WRITEABLE               = 0x00000002,
199                 DRSUAPI_DS_REPLICA_SYNC_PERIODIC                = 0x00000004,
200                 DRSUAPI_DS_REPLICA_SYNC_INTERSITE_MESSAGING     = 0x00000008,
201                 DRSUAPI_DS_REPLICA_SYNC_ALL_SOURCES             = 0x00000010,
202                 DRSUAPI_DS_REPLICA_SYNC_FULL                    = 0x00000020,
203                 DRSUAPI_DS_REPLICA_SYNC_URGENT                  = 0x00000040,
204                 DRSUAPI_DS_REPLICA_SYNC_NO_DISCARD              = 0x00000080,
205                 DRSUAPI_DS_REPLICA_SYNC_FORCE                   = 0x00000100,
206                 DRSUAPI_DS_REPLICA_SYNC_ADD_REFERENCE           = 0x00000200,
207                 DRSUAPI_DS_REPLICA_SYNC_NEVER_COMPLETED         = 0x00000400,
208                 DRSUAPI_DS_REPLICA_SYNC_TWO_WAY                 = 0x00000800,
209                 DRSUAPI_DS_REPLICA_SYNC_NEVER_NOTIFY            = 0x00001000,
210                 DRSUAPI_DS_REPLICA_SYNC_INITIAL                 = 0x00002000,
211                 DRSUAPI_DS_REPLICA_SYNC_USE_COMPRESSION         = 0x00004000,
212                 DRSUAPI_DS_REPLICA_SYNC_ABANDONED               = 0x00008000,
213                 DRSUAPI_DS_REPLICA_SYNC_INITIAL_IN_PROGRESS     = 0x00010000,
214                 DRSUAPI_DS_REPLICA_SYNC_PARTIAL_ATTRIBUTE_SET   = 0x00020000,
215                 DRSUAPI_DS_REPLICA_SYNC_REQUEUE                 = 0x00040000,
216                 DRSUAPI_DS_REPLICA_SYNC_NOTIFICATION            = 0x00080000,
217                 DRSUAPI_DS_REPLICA_SYNC_ASYNCHRONOUS_REPLICA    = 0x00100000,
218                 DRSUAPI_DS_REPLICA_SYNC_CRITICAL                = 0x00200000,
219                 DRSUAPI_DS_REPLICA_SYNC_FULL_IN_PROGRESS        = 0x00400000,
220                 DRSUAPI_DS_REPLICA_SYNC_PREEMPTED               = 0x00800000
221         } drsuapi_DsReplicaSyncOptions;
222
223         typedef struct {
224                 drsuapi_DsReplicaObjectIdentifier *naming_context;
225                 GUID source_dsa_guid;
226                 astring *other_info; /* I assume this is related to the repsFromTo1OtherInfo dns_name */
227                 drsuapi_DrsOptions options;
228         } drsuapi_DsReplicaSyncRequest1;
229
230         typedef [switch_type(int32)] union {
231                 [case(1)] drsuapi_DsReplicaSyncRequest1 req1;
232         } drsuapi_DsReplicaSyncRequest;
233
234         WERROR drsuapi_DsReplicaSync(
235                 [in] policy_handle *bind_handle,
236                 [in] int32 level,
237                 [in,switch_is(level)] drsuapi_DsReplicaSyncRequest req
238                 );
239
240         /*****************/
241         /* Function 0x03 */
242         typedef [public] struct {
243                 hyper tmp_highest_usn; /* updated after each object update */
244                 hyper reserved_usn;
245                 hyper highest_usn; /* updated after a full replication cycle */
246         } drsuapi_DsReplicaHighWaterMark;
247
248         typedef [public] struct {
249                 GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */
250                 hyper highest_usn;  /* updated after a full replication cycle */
251         } drsuapi_DsReplicaCursor;
252
253         typedef struct {
254                 [value(1)] uint32 version;
255                 [value(0)] uint32 reserved1;
256                 [range(0,0x100000)] uint32 count;
257                 [value(0)] uint32 reserved2;
258                 [size_is(count)] drsuapi_DsReplicaCursor cursors[];
259         } drsuapi_DsReplicaCursorCtrEx;
260
261         typedef [flag(NDR_PAHEX),v1_enum] enum {
262                 DRSUAPI_EXOP_NONE                               = 0x00000000,
263                 DRSUAPI_EXOP_FSMO_REQ_ROLE                      = 0x00000001,
264                 DRSUAPI_EXOP_FSMO_RID_ALLOC                     = 0x00000002,
265                 DRSUAPI_EXOP_FSMO_RID_REQ_ROLE                  = 0x00000003,
266                 DRSUAPI_EXOP_FSMO_REQ_PDC                       = 0x00000004,
267                 DRSUAPI_EXOP_FSMO_ABANDON_ROLE                  = 0x00000005,
268                 DRSUAPI_EXOP_REPL_OBJ                           = 0x00000006,
269                 DRSUAPI_EXOP_REPL_SECRET                        = 0x00000007
270         } drsuapi_DsExtendedOperation;
271
272         typedef [flag(NDR_PAHEX),v1_enum] enum {
273                 DRSUAPI_EXOP_ERR_NONE                           = 0x00000000,
274                 DRSUAPI_EXOP_ERR_SUCCESS                        = 0x00000001,
275                 DRSUAPI_EXOP_ERR_UNKNOWN_OP                     = 0x00000002,
276                 DRSUAPI_EXOP_ERR_FSMO_NOT_OWNER                 = 0x00000003,
277                 DRSUAPI_EXOP_ERR_UPDATE_ERR                     = 0x00000004,
278                 DRSUAPI_EXOP_ERR_EXCEPTION                      = 0x00000005,
279                 DRSUAPI_EXOP_ERR_UNKNOWN_CALLER                 = 0x00000006,
280                 DRSUAPI_EXOP_ERR_RID_ALLOC                      = 0x00000007,
281                 DRSUAPI_EXOP_ERR_FSMO_OWNER_DELETED             = 0x00000008,
282                 DRSUAPI_EXOP_ERR_FMSO_PENDING_OP                = 0x00000009,
283                 DRSUAPI_EXOP_ERR_MISMATCH                       = 0x0000000A,
284                 DRSUAPI_EXOP_ERR_COULDNT_CONTACT                = 0x0000000B,
285                 DRSUAPI_EXOP_ERR_FSMO_REFUSING_ROLES            = 0x0000000C,
286                 DRSUAPI_EXOP_ERR_DIR_ERROR                      = 0x0000000D,
287                 DRSUAPI_EXOP_ERR_FSMO_MISSING_SETTINGS          = 0x0000000E,
288                 DRSUAPI_EXOP_ERR_ACCESS_DENIED                  = 0x0000000F,
289                 DRSUAPI_EXOP_ERR_PARAM_ERROR                    = 0x00000010
290         } drsuapi_DsExtendedError;
291
292         typedef struct {
293                 GUID destination_dsa_guid;
294                 GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */
295                 [ref] drsuapi_DsReplicaObjectIdentifier *naming_context;
296                 drsuapi_DsReplicaHighWaterMark highwatermark;
297                 drsuapi_DsReplicaCursorCtrEx *uptodateness_vector;
298                 drsuapi_DrsOptions replica_flags;
299                 uint32 max_object_count; /* w2k3 uses min(133,max(100,max_object_count)) */
300                 uint32 max_ndr_size; /* w2k3 seems to ignore this */
301                 drsuapi_DsExtendedOperation extended_op;
302                 hyper fsmo_info;
303         } drsuapi_DsGetNCChangesRequest5;
304
305         /*
306          * In DRSUAPI all attributes with syntax 2.5.5.2
307          * are identified by uint32 values
308          *
309          * the following table shows the mapping used between the two representations
310          * e.g. - objectClass 'nTDSDSA' has governsID: 1.2.840.113556.1.5.7000.47
311          *        and a UINT32-ID of '0x0017002F'.
312          *      - so the OID 1.2.840.113556.1.5.7000.47 is splitted into a
313          *        OID-prefix: 1.2.840.113556.1.5.7000
314          *        and a value: 47 => 0x2F
315          *      - the mapping table gives a UINT32-prefix: 0x00170000
316          *      - and the UINT32-ID is 0x0017002F = 0x00170000 | 0x2F
317          *
318          * This prefix mapping table is replied in the drsuapi_DsReplicaOIDMapping_Ctr
319          * array. The following are the default mappings of w2k3
320          *
321          * OID-prefix                   => UINT32-Id prefix
322          *
323          * 2.5.4.*                      => 0x00000000 (standard attributes RFC2256 core.schema)
324          * 2.5.6.*                      => 0x00010000 (standard object classes RFC2256 core.schema)
325          * 1.2.840.113556.1.2.*         => 0x00020000
326          * 1.2.840.113556.1.3.*         => 0x00030000
327          * 2.5.5.*                      => 0x00080000 (attributeSyntax OID's)
328          * 1.2.840.113556.1.4.*         => 0x00090000
329          * 1.2.840.113556.1.5.*         => 0x000A0000
330          * 2.16.840.1.113730.3.*        => 0x00140000
331          * 0.9.2342.19200300.100.1.*    => 0x00150000
332          * 2.16.840.1.113730.3.1.*      => 0x00160000
333          * 1.2.840.113556.1.5.7000.*    => 0x00170000
334          * 2.5.21.*                     => 0x00180000 (attrs for SubSchema)
335          * 2.5.18.*                     => 0x00190000 (createTimeStamp,modifyTimeStamp, SubSchema)
336          * 2.5.20.*                     => 0x001A0000
337          * 1.3.6.1.4.1.1466.101.119.*   => 0x001B0000 (dynamicObject, entryTTL)
338          * 2.16.840.1.113730.3.2.*      => 0x001C0000
339          * 1.3.6.1.4.1.250.1.*          => 0x001D0000
340          * 1.2.840.113549.1.9.*         => 0x001E0000 (unstructuredAddress,unstructuredName)
341          * 0.9.2342.19200300.100.4.*    => 0x001F0000
342          *
343          * Here's a list of used 'attributeSyntax' OID's
344          *
345          * 2.5.5.1      => Object(DS-DN) string
346          *                 struct drsuapi_DsObjectIdentifier3
347          *
348          * 2.5.5.2      => OID-string
349          *              => all values are represented as uint32 values in drsuapi
350          *              => governsID, attributeID and attributeSyntax returned as OID-Strings in LDAP
351          *              => mayContain, mustContain and all other attributes with 2.5.5.2 syntax
352          *                 are returned as attribute names
353          *
354          * 2.5.5.4      => String(Teletex) case-insensitive string with teletex charset
355          *
356          * 2.5.5.5      => String(IA5) case-sensitive string
357          *
358          * 2.5.5.6      => String(Numeric)
359          *              => eg. internationalISDNNumber
360          *
361          * 2.5.5.7      => Object(DN-Binary) B:<byte count>:<bytes>:<object DN>
362          *              => e.g. wellKnownObjects
363          *
364          * 2.5.5.8      => BOOL
365          *
366          * 2.5.5.9      => int32
367          *
368          * 2.5.5.10     => DATA_BLOB
369          *              => struct GUID
370          *
371          * 2.5.5.11     => LDAP timestring
372          *              => NTTIME_1sec
373          *
374          * 2.5.5.12     => String(Unicode) case-insensitive string
375          *              => 'standard strings'
376          *
377          * 2.5.5.13     => Object(Presentation-Address) string
378          *              => used in objectClass applicationEntity
379          *
380          * 2.5.5.14     => Object(DN-String) S:<char count>:<string>:<object DN>
381          *              => not used
382          *
383          * 2.5.5.15     => ntSecurityDescriptor
384          *
385          * 2.5.5.16     => int64
386          *
387          * 2.5.5.17     => dom_sid
388          */
389         typedef [noprint] struct {
390                 [range(0,10000)] uint32 length;
391                 [size_is(length)] uint8 *binary_oid; /* partial-binary-OID encoded with asn1_write_partial_OID_String() */
392         } drsuapi_DsReplicaOID;
393
394         typedef struct {
395                 uint32 id_prefix;
396                 drsuapi_DsReplicaOID oid;
397         } drsuapi_DsReplicaOIDMapping;
398
399         typedef [public] struct {
400                 [range(0,0x100000)] uint32 num_mappings;
401                 [size_is(num_mappings)] drsuapi_DsReplicaOIDMapping *mappings;
402         } drsuapi_DsReplicaOIDMapping_Ctr;
403
404         typedef [flag(NDR_PAHEX),v1_enum] enum {
405                 DRSUAPI_OBJECTCLASS_top                 = 0x00010000,
406                 DRSUAPI_OBJECTCLASS_classSchema         = 0x0003000d,
407                 DRSUAPI_OBJECTCLASS_attributeSchema     = 0x0003000e
408         } drsuapi_DsObjectClassId;
409
410         typedef [flag(NDR_PAHEX),v1_enum,public] enum {
411                 DRSUAPI_ATTRIBUTE_objectClass                   = 0x00000000,
412                 DRSUAPI_ATTRIBUTE_cn                            = 0x00000003,
413                 DRSUAPI_ATTRIBUTE_description                   = 0x0000000d,
414                 DRSUAPI_ATTRIBUTE_member                        = 0x0000001f,
415                 DRSUAPI_ATTRIBUTE_instanceType                  = 0x00020001,
416                 DRSUAPI_ATTRIBUTE_whenCreated                   = 0x00020002,
417                 DRSUAPI_ATTRIBUTE_possSuperiors                 = 0x00020008,
418                 DRSUAPI_ATTRIBUTE_hasMasterNCs                  = 0x0002000e,
419                 DRSUAPI_ATTRIBUTE_subClassOf                    = 0x00020015,
420                 DRSUAPI_ATTRIBUTE_governsID                     = 0x00020016,
421                 DRSUAPI_ATTRIBUTE_mustContain                   = 0x00020018,
422                 DRSUAPI_ATTRIBUTE_mayContain                    = 0x00020019,
423                 DRSUAPI_ATTRIBUTE_rDNAttId                      = 0x0002001A,
424                 DRSUAPI_ATTRIBUTE_attributeID                   = 0x0002001e,
425                 DRSUAPI_ATTRIBUTE_attributeSyntax               = 0x00020020,
426                 DRSUAPI_ATTRIBUTE_isSingleValued                = 0x00020021,
427                 DRSUAPI_ATTRIBUTE_rangeLower                    = 0x00020022,
428                 DRSUAPI_ATTRIBUTE_rangeUpper                    = 0x00020023,
429                 DRSUAPI_ATTRIBUTE_dMDLocation                   = 0x00020024,
430                 DRSUAPI_ATTRIBUTE_objectVersion                 = 0x0002004c,
431                 DRSUAPI_ATTRIBUTE_invocationId                  = 0x00020073,
432                 DRSUAPI_ATTRIBUTE_showInAdvancedViewOnly        = 0x000200a9,
433                 DRSUAPI_ATTRIBUTE_adminDisplayName              = 0x000200c2,
434                 DRSUAPI_ATTRIBUTE_adminDescription              = 0x000200e2,
435                 DRSUAPI_ATTRIBUTE_oMSyntax                      = 0x000200e7,
436                 DRSUAPI_ATTRIBUTE_ntSecurityDescriptor          = 0x00020119,
437                 DRSUAPI_ATTRIBUTE_searchFlags                   = 0x0002014e,
438                 DRSUAPI_ATTRIBUTE_auxiliaryClass                = 0x0002015f,
439                 DRSUAPI_ATTRIBUTE_lDAPDisplayName               = 0x000201cc,
440                 DRSUAPI_ATTRIBUTE_name                          = 0x00090001,
441                 DRSUAPI_ATTRIBUTE_userAccountControl            = 0x00090008,
442                 DRSUAPI_ATTRIBUTE_currentValue                  = 0x0009001b,
443                 DRSUAPI_ATTRIBUTE_homeDirectory                 = 0x0009002c,
444                 DRSUAPI_ATTRIBUTE_homeDrive                     = 0x0009002d,
445                 DRSUAPI_ATTRIBUTE_scriptPath                    = 0x0009003e,
446                 DRSUAPI_ATTRIBUTE_profilePath                   = 0x0009008b,
447                 DRSUAPI_ATTRIBUTE_objectSid                     = 0x00090092,
448                 DRSUAPI_ATTRIBUTE_schemaIDGUID                  = 0x00090094,
449                 DRSUAPI_ATTRIBUTE_dBCSPwd                       = 0x00090037,/* lmPwdHash */
450                 DRSUAPI_ATTRIBUTE_logonHours                    = 0x00090040,
451                 DRSUAPI_ATTRIBUTE_userWorkstations              = 0x00090056,
452                 DRSUAPI_ATTRIBUTE_unicodePwd                    = 0x0009005a,/* ntPwdHash */
453                 DRSUAPI_ATTRIBUTE_ntPwdHistory                  = 0x0009005e,
454                 DRSUAPI_ATTRIBUTE_priorValue                    = 0x00090064,
455                 DRSUAPI_ATTRIBUTE_supplementalCredentials       = 0x0009007d,
456                 DRSUAPI_ATTRIBUTE_trustAuthIncoming             = 0x00090081,
457                 DRSUAPI_ATTRIBUTE_trustAuthOutgoing             = 0x00090087,
458                 DRSUAPI_ATTRIBUTE_lmPwdHistory                  = 0x000900a0,
459                 DRSUAPI_ATTRIBUTE_systemPossSuperiors           = 0x000900c3,
460                 DRSUAPI_ATTRIBUTE_systemMayContain              = 0x000900c4,
461                 DRSUAPI_ATTRIBUTE_systemMustContain             = 0x000900c5,
462                 DRSUAPI_ATTRIBUTE_systemAuxiliaryClass          = 0x000900c6,
463                 DRSUAPI_ATTRIBUTE_sAMAccountName                = 0x000900dd,
464                 DRSUAPI_ATTRIBUTE_sAMAccountType                = 0x0009012e,
465                 DRSUAPI_ATTRIBUTE_fSMORoleOwner                 = 0x00090171,
466                 DRSUAPI_ATTRIBUTE_systemFlags                   = 0x00090177,
467                 DRSUAPI_ATTRIBUTE_serverReference               = 0x00090203,
468                 DRSUAPI_ATTRIBUTE_serverReferenceBL             = 0x00090204,
469                 DRSUAPI_ATTRIBUTE_initialAuthIncoming           = 0x0009021b,
470                 DRSUAPI_ATTRIBUTE_initialAuthOutgoing           = 0x0009021c,
471                 DRSUAPI_ATTRIBUTE_wellKnownObjects              = 0x0009026a,
472                 DRSUAPI_ATTRIBUTE_dNSHostName                   = 0x0009026b,
473                 DRSUAPI_ATTRIBUTE_isMemberOfPartialAttributeSet = 0x0009027f,
474                 DRSUAPI_ATTRIBUTE_userPrincipalName             = 0x00090290,
475                 DRSUAPI_ATTRIBUTE_groupType                     = 0x000902ee,
476                 DRSUAPI_ATTRIBUTE_servicePrincipalName          = 0x00090303,
477                 DRSUAPI_ATTRIBUTE_objectCategory                = 0x0009030e,
478                 DRSUAPI_ATTRIBUTE_gPLink                        = 0x0009037b,
479                 DRSUAPI_ATTRIBUTE_transportAddressAttribute     = 0x0009037f,
480                 DRSUAPI_ATTRIBUTE_msDS_Behavior_Version         = 0x000905b3,
481                 DRSUAPI_ATTRIBUTE_msDS_KeyVersionNumber         = 0x000906f6,
482                 DRSUAPI_ATTRIBUTE_msDS_HasDomainNCs             = 0x0009071c,
483                 DRSUAPI_ATTRIBUTE_msDS_hasMasterNCs             = 0x0009072c,           
484                 DRSUAPI_ATTRIBUTE_NONE                          = 0xFFFFFFFF
485         } drsuapi_DsAttributeId;
486
487         typedef struct {
488                 [value(1)] uint32 version;
489                 [value(0)] uint32 reserved1;
490                 [range(1,0x100000)] uint32 num_attids;
491                 [size_is(num_attids)] drsuapi_DsAttributeId attids[];
492         } drsuapi_DsPartialAttributeSet;
493
494         typedef struct {
495                 GUID destination_dsa_guid;
496                 GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */
497                 [ref] drsuapi_DsReplicaObjectIdentifier *naming_context;
498                 drsuapi_DsReplicaHighWaterMark highwatermark;
499                 drsuapi_DsReplicaCursorCtrEx *uptodateness_vector;
500                 drsuapi_DrsOptions replica_flags;
501                 uint32 max_object_count; /* w2k3 uses min(133,max(100,max_object_count)) */
502                 uint32 max_ndr_size; /* w2k3 seems to ignore this */
503                 drsuapi_DsExtendedOperation extended_op;
504                 hyper fsmo_info;
505                 drsuapi_DsPartialAttributeSet *partial_attribute_set;
506                 drsuapi_DsPartialAttributeSet *partial_attribute_set_ex;
507                 drsuapi_DsReplicaOIDMapping_Ctr mapping_ctr;
508         } drsuapi_DsGetNCChangesRequest8;
509
510         typedef struct {
511                 GUID destination_dsa_guid;
512                 GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */
513                 [ref] drsuapi_DsReplicaObjectIdentifier *naming_context;
514                 drsuapi_DsReplicaHighWaterMark highwatermark;
515                 drsuapi_DsReplicaCursorCtrEx *uptodateness_vector;
516                 drsuapi_DrsOptions replica_flags;
517                 uint32 max_object_count; /* w2k3 uses min(133,max(100,max_object_count)) */
518                 uint32 max_ndr_size; /* w2k3 seems to ignore this */
519                 drsuapi_DsExtendedOperation extended_op;
520                 hyper fsmo_info;
521                 drsuapi_DsPartialAttributeSet *partial_attribute_set;
522                 drsuapi_DsPartialAttributeSet *partial_attribute_set_ex;
523                 drsuapi_DsReplicaOIDMapping_Ctr mapping_ctr;
524                 uint32 more_flags;
525         } drsuapi_DsGetNCChangesRequest10;
526
527         typedef [switch_type(int32)] union {
528                 [case(5)] drsuapi_DsGetNCChangesRequest5 req5;
529                 [case(8)] drsuapi_DsGetNCChangesRequest8 req8;
530                 [case(10)] drsuapi_DsGetNCChangesRequest10 req10;
531         } drsuapi_DsGetNCChangesRequest;
532
533         typedef [public] struct {
534                 GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */
535                 hyper highest_usn;  /* updated after a full replication cycle */
536                 NTTIME last_sync_success;
537         } drsuapi_DsReplicaCursor2;
538
539         typedef struct {
540                 [value(2)] uint32 version;
541                 [value(0)] uint32 reserved1;
542                 [range(0,0x100000)] uint32 count;
543                 [value(0)] uint32 reserved2;
544                 [size_is(count)] drsuapi_DsReplicaCursor2 cursors[];
545         } drsuapi_DsReplicaCursor2CtrEx;
546
547         /* Generic DATA_BLOB values */
548         typedef struct {
549                 [range(0,10485760),value(ndr_size_DATA_BLOB(0,blob,0))] uint32 __ndr_size;
550                 DATA_BLOB *blob;
551         } drsuapi_DsAttributeValue;
552
553         typedef struct {
554                 [range(0,10485760)] uint32 num_values;
555                 [size_is(num_values)] drsuapi_DsAttributeValue *values;
556         } drsuapi_DsAttributeValueCtr;
557
558         /* DN String values */
559         typedef [public,gensize] struct {
560                 [value(ndr_size_drsuapi_DsReplicaObjectIdentifier3(r, ndr->iconv_convenience, ndr->flags))] uint32 __ndr_size;
561                 [value(ndr_size_dom_sid28(&sid,ndr->flags))]  uint32 __ndr_size_sid;
562                 GUID guid;
563                 dom_sid28 sid;
564                 [value(strlen_m(dn))] uint32 __ndr_size_dn;
565                 [charset(UTF16)] uint16 dn[__ndr_size_dn+1];
566         } drsuapi_DsReplicaObjectIdentifier3;
567
568         typedef [public] struct {
569                 [value(ndr_size_drsuapi_DsReplicaObjectIdentifier3Binary_without_Binary(r, ndr->iconv_convenience, ndr->flags))] uint32 __ndr_size;
570                 [value(ndr_size_dom_sid28(&sid,ndr->flags))]  uint32 __ndr_size_sid;
571                 GUID guid;
572                 dom_sid28 sid;
573                 [value(strlen_m(dn))] uint32 __ndr_size_dn;
574                 [charset(UTF16)] uint16 dn[__ndr_size_dn+1];
575                 [value(binary.length + 4)] uint32 __ndr_size_binary;
576                 [flag(NDR_REMAINING)] DATA_BLOB binary;
577         } drsuapi_DsReplicaObjectIdentifier3Binary;
578
579         typedef [public] struct {
580                 drsuapi_DsAttributeId attid;
581                 drsuapi_DsAttributeValueCtr value_ctr;
582         } drsuapi_DsReplicaAttribute;
583
584         typedef struct {
585                 [range(0,1048576)] uint32 num_attributes;
586                 [size_is(num_attributes)]  drsuapi_DsReplicaAttribute *attributes;
587         } drsuapi_DsReplicaAttributeCtr;
588
589         typedef [public] bitmap {
590                 DRSUAPI_DS_REPLICA_OBJECT_FROM_MASTER   = 0x00000001,
591                 DRSUAPI_DS_REPLICA_OBJECT_DYNAMIC       = 0x00000002,
592                 DRSUAPI_DS_REPLICA_OBJECT_REMOTE_MODIFY = 0x00010000
593         } drsuapi_DsReplicaObjectFlags;
594
595         typedef [public] struct {
596                 drsuapi_DsReplicaObjectIdentifier *identifier;
597                 drsuapi_DsReplicaObjectFlags flags;
598                 drsuapi_DsReplicaAttributeCtr attribute_ctr;
599         } drsuapi_DsReplicaObject;
600
601         typedef struct {
602                 uint32 version;
603                 NTTIME_1sec originating_change_time;
604                 GUID originating_invocation_id;
605                 hyper originating_usn;
606         } drsuapi_DsReplicaMetaData;
607
608         typedef [public] struct {
609                 [range(0,1048576)] uint32 count;
610                 [size_is(count)] drsuapi_DsReplicaMetaData meta_data[];
611         } drsuapi_DsReplicaMetaDataCtr;
612
613         typedef [public,noprint] struct {
614                 drsuapi_DsReplicaObjectListItemEx *next_object;
615                 drsuapi_DsReplicaObject object;
616                 boolean32 is_nc_prefix;
617                 GUID *parent_object_guid;
618                 drsuapi_DsReplicaMetaDataCtr *meta_data_ctr;
619         } drsuapi_DsReplicaObjectListItemEx;
620
621         typedef [public,gensize] struct {
622                 GUID source_dsa_guid; /* the 'objectGUID' field of the CN=NTDS Settings object */
623                 GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */
624                 drsuapi_DsReplicaObjectIdentifier *naming_context;
625                 drsuapi_DsReplicaHighWaterMark old_highwatermark;
626                 drsuapi_DsReplicaHighWaterMark new_highwatermark;
627                 drsuapi_DsReplicaCursorCtrEx *uptodateness_vector;
628                 drsuapi_DsReplicaOIDMapping_Ctr mapping_ctr;
629                 drsuapi_DsExtendedError extended_ret; /* w2k sends the nc_object_count value here */
630                 uint32 object_count;
631                 /* this +55 is sometimes +56, so I don't know where this comes from... --metze */
632                 [value(ndr_size_drsuapi_DsGetNCChangesCtr1(r,ndr->iconv_convenience,ndr->flags)+55)] uint32 __ndr_size;
633                 drsuapi_DsReplicaObjectListItemEx *first_object;
634                 boolean32 more_data;
635         } drsuapi_DsGetNCChangesCtr1;
636
637         /*
638          * if the DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE flag
639          * isn't there it means the value is deleted
640          */
641         typedef [public] bitmap {
642                 DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE = 0x00000001
643         } drsuapi_DsLinkedAttributeFlags;
644
645         typedef [public] struct {
646                 drsuapi_DsReplicaObjectIdentifier *identifier;
647                 drsuapi_DsAttributeId attid;
648                 drsuapi_DsAttributeValue value;
649                 drsuapi_DsLinkedAttributeFlags flags;
650                 NTTIME_1sec originating_add_time;
651                 drsuapi_DsReplicaMetaData meta_data;
652         } drsuapi_DsReplicaLinkedAttribute;
653
654         /* [MS-DRSR] section 4.1.10.2.11 DRS_MSG_GETCHGREPLY_V6 */
655         typedef [public,gensize] struct {
656                 GUID source_dsa_guid; /* the 'objectGUID' field of the CN=NTDS Settings object */
657                 GUID source_dsa_invocation_id; /* the 'invocationId' field of the CN=NTDS Settings object */
658                 drsuapi_DsReplicaObjectIdentifier *naming_context;
659                 drsuapi_DsReplicaHighWaterMark old_highwatermark;
660                 drsuapi_DsReplicaHighWaterMark new_highwatermark;
661                 drsuapi_DsReplicaCursor2CtrEx *uptodateness_vector;
662                 drsuapi_DsReplicaOIDMapping_Ctr mapping_ctr;
663                 drsuapi_DsExtendedError extended_ret;
664                 uint32 object_count;
665                 /* this +55 is sometimes +56, so I don't know where this comes from... --metze */
666                 [value(ndr_size_drsuapi_DsGetNCChangesCtr6(r,ndr->iconv_convenience,ndr->flags)+55)] uint32 __ndr_size;
667                 drsuapi_DsReplicaObjectListItemEx *first_object;
668                 boolean32 more_data;
669                 uint32 nc_object_count; /* estimated amount of objects in the whole NC */
670                 uint32 nc_linked_attributes_count;  /* estimated amount of linked values in the whole NC */
671                 [range(0,1048576)] uint32 linked_attributes_count;
672                 [size_is(linked_attributes_count)] drsuapi_DsReplicaLinkedAttribute *linked_attributes;
673                 WERROR drs_error;
674         } drsuapi_DsGetNCChangesCtr6;
675
676         typedef [public] struct {
677                 [subcontext(0xFFFFFC01)] drsuapi_DsGetNCChangesCtr1 ctr1;
678         } drsuapi_DsGetNCChangesCtr1TS;
679
680         typedef [public] struct {
681                 [subcontext(0xFFFFFC01)] drsuapi_DsGetNCChangesCtr6 ctr6;
682         } drsuapi_DsGetNCChangesCtr6TS;
683
684         typedef [nopush] struct {
685                 uint32 decompressed_length;
686                 uint32 compressed_length;
687                 [subcontext(4),subcontext_size(compressed_length),
688                  compression(NDR_COMPRESSION_MSZIP,compressed_length,decompressed_length)]
689                  drsuapi_DsGetNCChangesCtr1TS *ts;
690         } drsuapi_DsGetNCChangesMSZIPCtr1;
691
692         typedef [nopush] struct {
693                 uint32 decompressed_length;
694                 uint32 compressed_length;
695                 [subcontext(4),subcontext_size(compressed_length),
696                  compression(NDR_COMPRESSION_MSZIP,compressed_length,decompressed_length)]
697                  drsuapi_DsGetNCChangesCtr6TS *ts;
698         } drsuapi_DsGetNCChangesMSZIPCtr6;
699
700         typedef [nopush] struct {
701                 uint32 decompressed_length;
702                 uint32 compressed_length;
703                 [subcontext(4),subcontext_size(compressed_length),
704                  compression(NDR_COMPRESSION_XPRESS,compressed_length,decompressed_length)]
705                  drsuapi_DsGetNCChangesCtr1TS *ts;
706         } drsuapi_DsGetNCChangesXPRESSCtr1;
707
708         typedef [nopush] struct {
709                 uint32 decompressed_length;
710                 uint32 compressed_length;
711                 [subcontext(4),subcontext_size(compressed_length),
712                  compression(NDR_COMPRESSION_XPRESS,compressed_length,decompressed_length)]
713                  drsuapi_DsGetNCChangesCtr6TS *ts;
714         } drsuapi_DsGetNCChangesXPRESSCtr6;
715
716         typedef [enum16bit] enum {
717                 DRSUAPI_COMPRESSION_TYPE_MSZIP  = 2,
718                 DRSUAPI_COMPRESSION_TYPE_XPRESS = 3
719         } drsuapi_DsGetNCChangesCompressionType;
720
721         typedef [nodiscriminant,flag(NDR_PAHEX)] union {
722                 [case(1|(DRSUAPI_COMPRESSION_TYPE_MSZIP<<16))]  drsuapi_DsGetNCChangesMSZIPCtr1 mszip1;
723                 [case(6|(DRSUAPI_COMPRESSION_TYPE_MSZIP<<16))]  drsuapi_DsGetNCChangesMSZIPCtr6 mszip6;
724                 [case(1|(DRSUAPI_COMPRESSION_TYPE_XPRESS<<16))] drsuapi_DsGetNCChangesXPRESSCtr1 xpress1;
725                 [case(6|(DRSUAPI_COMPRESSION_TYPE_XPRESS<<16))] drsuapi_DsGetNCChangesXPRESSCtr6 xpress6;
726         } drsuapi_DsGetNCChangesCompressedCtr;
727
728         typedef struct {
729                 drsuapi_DsGetNCChangesMSZIPCtr1 mszip1;
730         } drsuapi_DsGetNCChangesCtr2;
731
732         typedef struct {
733                 [range(0,6)] int32 level;
734                 [range(2,3)] drsuapi_DsGetNCChangesCompressionType type;
735                 [switch_is(level | (type<<16))] drsuapi_DsGetNCChangesCompressedCtr ctr;
736         } drsuapi_DsGetNCChangesCtr7;
737
738         typedef [switch_type(int32)] union {
739                 [case(1)] drsuapi_DsGetNCChangesCtr1 ctr1;
740                 [case(2)] drsuapi_DsGetNCChangesCtr2 ctr2;
741                 [case(6)] drsuapi_DsGetNCChangesCtr6 ctr6;
742                 [case(7)] drsuapi_DsGetNCChangesCtr7 ctr7;
743         } drsuapi_DsGetNCChangesCtr;
744
745         WERROR drsuapi_DsGetNCChanges(
746                 [in] policy_handle *bind_handle,
747                 [in] int32 level,
748                 [in,ref,switch_is(level)] drsuapi_DsGetNCChangesRequest *req,
749                 [out,ref] int32 *level_out,
750                 [out,ref,switch_is(*level_out)] drsuapi_DsGetNCChangesCtr *ctr
751                 );
752
753         /*****************/
754         /* Function 0x04 */
755         /* [MS-DRSR] 4.1.26 */
756
757         typedef struct {
758                 [ref] drsuapi_DsReplicaObjectIdentifier *naming_context;
759                 [ref,charset(DOS),string] uint8 *dest_dsa_dns_name;
760                 GUID dest_dsa_guid;
761                 drsuapi_DrsOptions options;
762         } drsuapi_DsReplicaUpdateRefsRequest1;
763
764         typedef [switch_type(int32)] union {
765                 [case(1)] drsuapi_DsReplicaUpdateRefsRequest1 req1;
766         } drsuapi_DsReplicaUpdateRefsRequest;
767
768         WERROR drsuapi_DsReplicaUpdateRefs(
769                 [in] policy_handle *bind_handle,
770                 [in] int32 level,
771                 [in,switch_is(level)] drsuapi_DsReplicaUpdateRefsRequest req
772                 );
773
774         /*****************/
775         /* Function 0x05 */
776
777         typedef struct {
778                 [ref] drsuapi_DsReplicaObjectIdentifier *naming_context;
779                 [charset(UTF16),string] uint16 *source_dsa_address;
780                 uint8 schedule[84];
781                 drsuapi_DrsOptions options;
782         } drsuapi_DsReplicaAddRequest1;
783
784         typedef struct {
785                 [ref] drsuapi_DsReplicaObjectIdentifier *naming_context;
786                 drsuapi_DsReplicaObjectIdentifier *source_dsa_dn;
787                 drsuapi_DsReplicaObjectIdentifier *transport_dn;
788                 [charset(UTF16),string] uint16 *source_dsa_address;
789                 uint8 schedule[84];
790                 drsuapi_DrsOptions options;
791         } drsuapi_DsReplicaAddRequest2;
792
793         typedef [switch_type(int32)] union {
794                 [case(1)] drsuapi_DsReplicaAddRequest1 req1;
795                 [case(2)] drsuapi_DsReplicaAddRequest2 req2;
796         } drsuapi_DsReplicaAddRequest;
797
798         WERROR drsuapi_DsReplicaAdd(
799                 [in] policy_handle *bind_handle,
800                 [in] int32 level,
801                 [in,switch_is(level)] drsuapi_DsReplicaAddRequest req
802                 );
803                 
804
805         /*****************/
806         /* Function 0x06 */
807         typedef struct {
808                 [ref] drsuapi_DsReplicaObjectIdentifier *naming_context;
809                 [charset(UTF16),string] uint16 *source_dsa_address;
810                 drsuapi_DrsOptions options;
811         } drsuapi_DsReplicaDelRequest1;
812
813         typedef [switch_type(int32)] union {
814                 [case(1)] drsuapi_DsReplicaDelRequest1 req1;
815         } drsuapi_DsReplicaDelRequest;
816
817         WERROR drsuapi_DsReplicaDel(
818                 [in] policy_handle *bind_handle,
819                 [in] int32 level,
820                 [in,switch_is(level)] drsuapi_DsReplicaDelRequest req
821                 );
822
823         /*****************/
824         /* Function 0x07 */
825
826         typedef struct {
827                 [ref] drsuapi_DsReplicaObjectIdentifier *naming_context;
828                 GUID source_dra;
829                 [charset(UTF16),string] uint16 *source_dra_address;
830                 uint8 schedule[84];
831                 uint32 replica_flags;
832                 uint32 modify_fields;
833                 drsuapi_DrsOptions options;
834         } drsuapi_DsReplicaModRequest1;
835
836         typedef [switch_type(int32)] union {
837                 [case(1)] drsuapi_DsReplicaModRequest1 req1;
838         } drsuapi_DsReplicaModRequest;
839
840         WERROR drsuapi_DsReplicaMod(
841                 [in] policy_handle *bind_handle,
842                 [in] int32 level,
843                 [in,switch_is(level)] drsuapi_DsReplicaModRequest req
844                 );
845
846         /*****************/
847         /* Function 0x08 */
848         [todo] WERROR DRSUAPI_VERIFY_NAMES();
849
850         /*****************/
851         /* Function 0x09 */
852
853         /* how are type 4 and 7 different from 2 and 3 ? */
854         typedef [v1_enum] enum {
855                 DRSUAPI_DS_MEMBERSHIP_TYPE_UNIVERSAL_AND_DOMAIN_GROUPS = 1,
856                 DRSUAPI_DS_MEMBERSHIP_TYPE_DOMAIN_LOCAL_GROUPS  = 2,
857                 DRSUAPI_DS_MEMBERSHIP_TYPE_DOMAIN_GROUPS        = 3,
858                 DRSUAPI_DS_MEMBERSHIP_TYPE_DOMAIN_LOCAL_GROUPS2 = 4,
859                 DRSUAPI_DS_MEMBERSHIP_TYPE_UNIVERSAL_GROUPS     = 5,
860                 DRSUAPI_DS_MEMBERSHIP_TYPE_GROUPMEMBERS         = 6,
861                 DRSUAPI_DS_MEMBERSHIP_TYPE_DOMAIN_GROUPS2       = 7
862         } drsuapi_DsMembershipType;
863
864         typedef struct {
865                 NTSTATUS status;
866                 [range(0,10000)] uint32 num_memberships;
867                 [range(0,10000)] uint32 num_sids;
868                 [size_is(num_memberships)] drsuapi_DsReplicaObjectIdentifier **info_array;
869                 [size_is(num_memberships)] samr_GroupAttrs *group_attrs;
870                 [size_is(num_sids)] dom_sid28 **sids;
871         } drsuapi_DsGetMembershipsCtr1;
872
873         typedef [switch_type(int32)] union {
874                 [case(1)] drsuapi_DsGetMembershipsCtr1 ctr1;
875         } drsuapi_DsGetMembershipsCtr;
876
877         const int DRSUAPI_DS_MEMBERSHIP_FLAG_GROUP_ATTR = 0x1;
878
879         typedef struct {
880                 [range(1,10000)] uint32 count;
881                 [size_is(count)] drsuapi_DsReplicaObjectIdentifier **info_array;
882                 uint32 flags;
883                 drsuapi_DsMembershipType type;
884                 drsuapi_DsReplicaObjectIdentifier *domain;
885         } drsuapi_DsGetMembershipsRequest1;
886
887         typedef [switch_type(int32)] union {
888                 [case(1)] drsuapi_DsGetMembershipsRequest1 req1;
889         } drsuapi_DsGetMembershipsRequest;
890
891         [todo] WERROR drsuapi_DsGetMemberships(
892                 [in] policy_handle *bind_handle,
893                 [in] int32 level,
894                 [in,ref] [switch_is(level)] drsuapi_DsGetMembershipsRequest *req,
895                 [out,ref] int32 *level_out,
896                 [out,ref] [switch_is(*level_out)] drsuapi_DsGetMembershipsCtr *ctr
897                 );
898
899         /*****************/
900         /* Function 0x0a */
901         [todo] WERROR DRSUAPI_INTER_DOMAIN_MOVE();
902
903         /*****************/
904         /* Function 0x0b */
905         typedef struct {
906                 uint32 unknown1;
907                 uint32 unknown2;
908                 [range(0,0x00A00000)] uint32 length;
909                 [size_is(length)] uint8 *data;
910         } drsuapi_DsGetNT4ChangeLogRequest1;
911
912         typedef [switch_type(uint32)] union {
913                 [case(1)] drsuapi_DsGetNT4ChangeLogRequest1 req1;
914         } drsuapi_DsGetNT4ChangeLogRequest;
915
916         typedef struct {
917                 [range(0,0x00A00000)] uint32 length1;
918                 [range(0,0x00A00000)] uint32 length2;
919                 hyper unknown1;
920                 NTTIME time2;
921                 hyper unknown3;
922                 NTTIME time4;
923                 hyper unknown5;
924                 NTTIME time6;
925                 NTSTATUS status;
926                 [size_is(length1)] uint8 *data1;
927                 [size_is(length2)] uint8 *data2;
928         } drsuapi_DsGetNT4ChangeLogInfo1;
929
930         typedef [switch_type(uint32)] union {
931                 [case(1)] drsuapi_DsGetNT4ChangeLogInfo1 info1;
932         } drsuapi_DsGetNT4ChangeLogInfo;
933
934         [todo] WERROR drsuapi_DsGetNT4ChangeLog(
935                 [in] policy_handle *bind_handle,
936                 [in] uint32 level,
937                 [in,ref] [switch_is(level)] drsuapi_DsGetNT4ChangeLogRequest *req,
938                 [out,ref] uint32 *level_out,
939                 [out,ref] [switch_is(*level_out)] drsuapi_DsGetNT4ChangeLogInfo *info
940                 );
941
942         /*****************/
943         /* Function 0x0c */
944         typedef [v1_enum] enum {
945                 DRSUAPI_DS_NAME_STATUS_OK                       = 0,
946                 DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR            = 1,
947                 DRSUAPI_DS_NAME_STATUS_NOT_FOUND                = 2,
948                 DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE               = 3,
949                 DRSUAPI_DS_NAME_STATUS_NO_MAPPING               = 4,
950                 DRSUAPI_DS_NAME_STATUS_DOMAIN_ONLY              = 5,
951                 DRSUAPI_DS_NAME_STATUS_NO_SYNTACTICAL_MAPPING   = 6,
952                 DRSUAPI_DS_NAME_STATUS_TRUST_REFERRAL           = 7
953         } drsuapi_DsNameStatus;
954
955         typedef [v1_enum] enum {
956                 DRSUAPI_DS_NAME_FLAG_NO_FLAGS                   = 0x0,
957                 DRSUAPI_DS_NAME_FLAG_SYNTACTICAL_ONLY           = 0x1,
958                 DRSUAPI_DS_NAME_FLAG_EVAL_AT_DC                 = 0x2,
959                 DRSUAPI_DS_NAME_FLAG_GCVERIFY                   = 0x4,
960                 DRSUAPI_DS_NAME_FLAG_TRUST_REFERRAL             = 0x8
961         } drsuapi_DsNameFlags;
962
963         typedef [v1_enum] enum {
964                 DRSUAPI_DS_NAME_FORMAT_UNKNOWN                  = 0,
965                 DRSUAPI_DS_NAME_FORMAT_FQDN_1779                = 1,
966                 DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT              = 2,
967                 DRSUAPI_DS_NAME_FORMAT_DISPLAY                  = 3,
968                 DRSUAPI_DS_NAME_FORMAT_GUID                     = 6,
969                 DRSUAPI_DS_NAME_FORMAT_CANONICAL                = 7,
970                 DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL           = 8,
971                 DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX             = 9,
972                 DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL        = 10,
973                 DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY       = 11,
974                 DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN               = 12
975         } drsuapi_DsNameFormat;
976
977         typedef struct {
978                 [string,charset(UTF16)] uint16 *str;
979         } drsuapi_DsNameString;
980
981         typedef struct {
982                 uint32 codepage; /* 0x000004e4 - 1252 is german codepage*/
983                 uint32 language; /* 0x00000407 - german language ID*/
984                 drsuapi_DsNameFlags format_flags;
985                 drsuapi_DsNameFormat format_offered;
986                 drsuapi_DsNameFormat format_desired;
987                 [range(1,10000)] uint32 count;
988                 [size_is(count)] drsuapi_DsNameString *names;
989         } drsuapi_DsNameRequest1;
990
991         typedef [switch_type(int32)] union {
992                 [case(1)] drsuapi_DsNameRequest1 req1;
993         } drsuapi_DsNameRequest;
994
995         typedef struct {
996                 drsuapi_DsNameStatus status;
997                 [charset(UTF16),string] uint16 *dns_domain_name;
998                 [charset(UTF16),string] uint16 *result_name;
999         } drsuapi_DsNameInfo1;
1000
1001         typedef struct {
1002                 uint32 count;
1003                 [size_is(count)] drsuapi_DsNameInfo1 *array;
1004         } drsuapi_DsNameCtr1;
1005
1006         typedef [switch_type(int32)] union {
1007                 [case(1)] drsuapi_DsNameCtr1 *ctr1;
1008         } drsuapi_DsNameCtr;
1009
1010         WERROR drsuapi_DsCrackNames(
1011                 [in] policy_handle *bind_handle,
1012                 [in] int32 level,
1013                 [in,ref,switch_is(level)] drsuapi_DsNameRequest *req,
1014                 [out,ref] int32 *level_out,
1015                 [out,ref,switch_is(*level_out)] drsuapi_DsNameCtr *ctr
1016                 );
1017
1018         /*****************/
1019         /* Function 0x0d */
1020         typedef [v1_enum] enum {
1021                 DRSUAPI_DS_SPN_OPERATION_ADD    = 0,
1022                 DRSUAPI_DS_SPN_OPERATION_REPLACE= 1,
1023                 DRSUAPI_DS_SPN_OPERATION_DELETE = 2
1024         } drsuapi_DsSpnOperation;
1025
1026         typedef struct {
1027                 drsuapi_DsSpnOperation operation;
1028                 uint32 unknown1;
1029                 [charset(UTF16),string] uint16 *object_dn;
1030                 [range(0,10000)] uint32 count;
1031                 [size_is(count)] drsuapi_DsNameString *spn_names;
1032         } drsuapi_DsWriteAccountSpnRequest1;
1033
1034         typedef [switch_type(int32)] union {
1035                 [case(1)] drsuapi_DsWriteAccountSpnRequest1 req1;
1036         } drsuapi_DsWriteAccountSpnRequest;
1037
1038         typedef struct {
1039                 WERROR status;
1040         } drsuapi_DsWriteAccountSpnResult1;
1041
1042         typedef [switch_type(int32)] union {
1043                 [case(1)] drsuapi_DsWriteAccountSpnResult1 res1;
1044         } drsuapi_DsWriteAccountSpnResult;
1045
1046         WERROR drsuapi_DsWriteAccountSpn(
1047                 [in] policy_handle *bind_handle,
1048                 [in] int32 level,
1049                 [in,ref,switch_is(level)] drsuapi_DsWriteAccountSpnRequest *req,
1050                 [out,ref] int32 *level_out,
1051                 [out,ref,switch_is(*level_out)] drsuapi_DsWriteAccountSpnResult *res
1052                 );
1053
1054         /*****************/
1055         /* Function 0x0e */
1056         typedef struct {
1057                 [charset(UTF16),string] uint16 *server_dn;
1058                 [charset(UTF16),string] uint16 *domain_dn;
1059                 boolean32 commit;
1060         } drsuapi_DsRemoveDSServerRequest1;
1061
1062         typedef [switch_type(int32)] union {
1063                 [case(1)] drsuapi_DsRemoveDSServerRequest1 req1;
1064         } drsuapi_DsRemoveDSServerRequest;
1065
1066         typedef struct {
1067                 boolean32 last_dc_in_domain;
1068         } drsuapi_DsRemoveDSServerResult1;
1069
1070         typedef [switch_type(int32)] union {
1071                 [case(1)] drsuapi_DsRemoveDSServerResult1 res1;
1072         } drsuapi_DsRemoveDSServerResult;
1073
1074         WERROR drsuapi_DsRemoveDSServer(
1075                 [in] policy_handle *bind_handle,
1076                 [in] int32 level,
1077                 [in,ref,switch_is(level)] drsuapi_DsRemoveDSServerRequest *req,
1078                 [out,ref] int32 *level_out,
1079                 [out,ref,switch_is(*level_out)] drsuapi_DsRemoveDSServerResult *res
1080                 );
1081
1082         /*****************/
1083         /* Function 0x0f */
1084         [todo] WERROR DRSUAPI_REMOVE_DS_DOMAIN();
1085
1086         /*****************/
1087         /* Function 0x10 */
1088         typedef struct {
1089                 [charset(UTF16),string] uint16 *domain_name; /* netbios or dns */
1090                 int32 level; /* specifies the switch level for the request */
1091         } drsuapi_DsGetDCInfoRequest1;
1092
1093         typedef [switch_type(int32)] union {
1094                 [case(1)] drsuapi_DsGetDCInfoRequest1 req1;
1095         } drsuapi_DsGetDCInfoRequest;
1096
1097         typedef struct {
1098                 [charset(UTF16),string] uint16 *netbios_name;
1099                 [charset(UTF16),string] uint16 *dns_name;
1100                 [charset(UTF16),string] uint16 *site_name;
1101                 [charset(UTF16),string] uint16 *computer_dn;
1102                 [charset(UTF16),string] uint16 *server_dn;
1103                 uint32 is_pdc;
1104                 uint32 is_enabled;
1105         } drsuapi_DsGetDCInfo1;
1106
1107         typedef struct {
1108                 [range(0,10000)] uint32 count;
1109                 [size_is(count)] drsuapi_DsGetDCInfo1 *array;
1110         } drsuapi_DsGetDCInfoCtr1;
1111
1112         typedef struct {
1113                 [charset(UTF16),string] uint16 *netbios_name;
1114                 [charset(UTF16),string] uint16 *dns_name;
1115                 [charset(UTF16),string] uint16 *site_name;
1116                 [charset(UTF16),string] uint16 *site_dn;
1117                 [charset(UTF16),string] uint16 *computer_dn;
1118                 [charset(UTF16),string] uint16 *server_dn;
1119                 [charset(UTF16),string] uint16 *ntds_dn;
1120                 uint32 is_pdc;
1121                 uint32 is_enabled;
1122                 uint32 is_gc;
1123                 GUID site_guid;
1124                 GUID computer_guid;
1125                 GUID server_guid;
1126                 GUID ntds_guid;
1127         } drsuapi_DsGetDCInfo2;
1128
1129         typedef struct {
1130                 [range(0,10000)] uint32 count;
1131                 [size_is(count)] drsuapi_DsGetDCInfo2 *array;
1132         } drsuapi_DsGetDCInfoCtr2;
1133
1134         typedef struct {
1135                 [charset(UTF16),string] uint16 *netbios_name;
1136                 [charset(UTF16),string] uint16 *dns_name;
1137                 [charset(UTF16),string] uint16 *site_name;
1138                 [charset(UTF16),string] uint16 *site_dn;
1139                 [charset(UTF16),string] uint16 *computer_dn;
1140                 [charset(UTF16),string] uint16 *server_dn;
1141                 [charset(UTF16),string] uint16 *ntds_dn;
1142                 uint32 is_pdc;
1143                 uint32 is_enabled;
1144                 uint32 is_gc;
1145                 uint32 is_rodc;
1146                 GUID site_guid;
1147                 GUID computer_guid;
1148                 GUID server_guid;
1149                 GUID ntds_guid;
1150         } drsuapi_DsGetDCInfo3;
1151
1152         typedef struct {
1153                 [range(0,10000)] uint32 count;
1154                 [size_is(count)] drsuapi_DsGetDCInfo3 *array;
1155         } drsuapi_DsGetDCInfoCtr3;
1156
1157         /*
1158          * this represents an active connection to the
1159          * Directory System Agent (DSA)
1160          * this can be via LDAP or DRSUAPI
1161          */
1162         typedef struct {
1163                 [flag(NDR_BIG_ENDIAN)] ipv4address client_ip_address;
1164                 uint32 unknown2;
1165                 uint32 connection_time; /* in seconds */
1166                 uint32 unknown4;
1167                 uint32 unknown5;
1168                 uint32 unknown6;
1169                 /*
1170                  * client_account can be the following:
1171                  * "W2K3\Administrator"
1172                  * "Administrator@W2K3"
1173                  * "cn=Administrator,cn=Users,DC=w2k3,DC=vmnet1,DC=vm,DC=base"
1174                  * ""
1175                  * or NULL
1176                  */
1177                 [charset(UTF16),string] uint16 *client_account;
1178         } drsuapi_DsGetDCConnection01;
1179
1180         typedef struct {
1181                 [range(0,10000)] uint32 count;
1182                 [size_is(count)] drsuapi_DsGetDCConnection01 *array;
1183         } drsuapi_DsGetDCConnectionCtr01;
1184
1185         typedef [v1_enum] enum {
1186                 DRSUAPI_DC_INFO_CTR_1  = 1,
1187                 DRSUAPI_DC_INFO_CTR_2  = 2,
1188                 DRSUAPI_DC_INFO_CTR_3  = 3,
1189                 DRSUAPI_DC_CONNECTION_CTR_01 = -1
1190         } drsuapi_DsGetDCInfoCtrLevels;
1191
1192         typedef [switch_type(int32)] union {
1193                 [case(DRSUAPI_DC_INFO_CTR_1)]  drsuapi_DsGetDCInfoCtr1  ctr1;
1194                 [case(DRSUAPI_DC_INFO_CTR_2)]  drsuapi_DsGetDCInfoCtr2  ctr2;
1195                 [case(DRSUAPI_DC_INFO_CTR_3)]  drsuapi_DsGetDCInfoCtr3  ctr3;
1196                 [case(DRSUAPI_DC_CONNECTION_CTR_01)] drsuapi_DsGetDCConnectionCtr01 ctr01;
1197         } drsuapi_DsGetDCInfoCtr;
1198
1199         WERROR drsuapi_DsGetDomainControllerInfo(
1200                 [in] policy_handle *bind_handle,
1201                 [in] int32 level,
1202                 [in,ref,switch_is(level)] drsuapi_DsGetDCInfoRequest *req,
1203                 [out,ref] int32 *level_out,
1204                 [out,ref,switch_is(*level_out)] drsuapi_DsGetDCInfoCtr *ctr
1205                 );
1206
1207         /*****************/
1208         /* Function 0x11 */
1209         typedef [public,noprint] struct {
1210                 drsuapi_DsReplicaObjectListItem *next_object;
1211                 drsuapi_DsReplicaObject object;
1212         } drsuapi_DsReplicaObjectListItem;
1213
1214         /*
1215          * The DsAddEntry() call which creates a nTDSDSA object,
1216          * also adds a servicePrincipalName in the following form
1217          * to the computer account of the new domain controller
1218          * referenced by the "serverReferenece" attribute.
1219          *
1220          * E3514235-4B06-11D1-AB04-00C04FC2DCD2/<new-ntdsdsa-object-guid-as-string>/<domain-dns-name>
1221          *
1222          * also note that the "serverReference" isn't added to the new object!
1223          */
1224         const char *DRSUAPI_NTDSDSA_KRB5_SERVICE_GUID = "E3514235-4B06-11D1-AB04-00C04FC2DCD2";
1225
1226         /*
1227          * please note the the current idl
1228          * for DsAddEntry does only parse
1229          * what I saw between 2 w2k3 boxes
1230          * in my dssync experiments I got some other replies
1231          * so all I want to say is that this is very incomplete yet...
1232          * --metze
1233          */
1234         typedef struct {
1235                 drsuapi_DsReplicaObjectListItem first_object;
1236         } drsuapi_DsAddEntryRequest2;
1237
1238         typedef [switch_type(int32)] union {
1239                 [case(2)] drsuapi_DsAddEntryRequest2 req2;
1240         } drsuapi_DsAddEntryRequest;
1241
1242         typedef struct {
1243                 uint32 unknown1;
1244                 WERROR status;
1245                 uint32 unknown2;
1246                 uint16 unknown3;
1247         } drsuapi_DsAddEntryErrorInfoX;
1248
1249         typedef struct {
1250                 [range(0,10485760)] uint32 size;
1251                 [size_is(size)] uint8 *data;
1252         } drsuapi_DsAddEntryExtraErrorBuffer;
1253
1254         typedef struct {
1255                 drsuapi_DsAddEntryErrorInfoX error;
1256                 drsuapi_DsAttributeId attid;
1257                 uint32 unknown2;
1258                 drsuapi_DsAddEntryExtraErrorBuffer buffer;
1259         } drsuapi_DsAddEntryExtraError1;
1260
1261         typedef /*[noprint]*/ struct {
1262                 drsuapi_DsAddEntryErrorListItem1 *next;
1263                 drsuapi_DsAddEntryExtraError1 error;
1264         } drsuapi_DsAddEntryErrorListItem1;
1265
1266         typedef struct {
1267                 drsuapi_DsReplicaObjectIdentifier *id;
1268                 WERROR status;
1269                 drsuapi_DsAddEntryErrorListItem1 first;
1270         } drsuapi_DsAddEntryErrorInfo1;
1271
1272         typedef [switch_type(uint32)] union {
1273                 [case(1)] drsuapi_DsAddEntryErrorInfo1 error1;
1274 /*              [case(2)] drsuapi_DsAddEntryErrorInfo2 error2;
1275                 [case(3)] drsuapi_DsAddEntryErrorInfo3 error3;
1276 */              [case(4)] drsuapi_DsAddEntryErrorInfoX errorX;
1277                 [case(5)] drsuapi_DsAddEntryErrorInfoX errorX;
1278                 [case(6)] drsuapi_DsAddEntryErrorInfoX errorX;
1279                 [case(7)] drsuapi_DsAddEntryErrorInfoX errorX;
1280         } drsuapi_DsAddEntryErrorInfo;
1281
1282         typedef struct {
1283                 WERROR status;
1284                 uint32 level;
1285                 [switch_is(level)] drsuapi_DsAddEntryErrorInfo *info;
1286         } drsuapi_DsAddEntryError1;
1287
1288         typedef [switch_type(uint32)] union {
1289                 [case(1)] drsuapi_DsAddEntryError1 info1;
1290         } drsuapi_DsAddEntryError;
1291
1292         typedef struct {
1293                 GUID guid;
1294                 dom_sid28 sid;
1295         } drsuapi_DsReplicaObjectIdentifier2;
1296
1297         typedef struct {
1298                 drsuapi_DsReplicaObjectIdentifier *id;
1299                 uint32 unknown1;
1300                 drsuapi_DsAddEntryErrorInfoX error;
1301                 [range(0,10000)] uint32 count;
1302                 [size_is(count)] drsuapi_DsReplicaObjectIdentifier2 *objects;
1303         } drsuapi_DsAddEntryCtr2;
1304
1305         typedef struct {
1306                 drsuapi_DsReplicaObjectIdentifier *id;
1307                 uint32 level;
1308                 [switch_is(level)] drsuapi_DsAddEntryError *error;
1309                 [range(0,10000)] uint32 count;
1310                 [size_is(count)] drsuapi_DsReplicaObjectIdentifier2 *objects;
1311         } drsuapi_DsAddEntryCtr3;
1312
1313         typedef [switch_type(int32)] union {
1314                 [case(2)] drsuapi_DsAddEntryCtr2 ctr2;
1315                 [case(3)] drsuapi_DsAddEntryCtr3 ctr3;
1316         } drsuapi_DsAddEntryCtr;
1317
1318         [public] WERROR drsuapi_DsAddEntry(
1319                 [in] policy_handle *bind_handle,
1320                 [in] int32 level,
1321                 [in,ref,switch_is(level)] drsuapi_DsAddEntryRequest *req,
1322                 [out,ref] int32 *level_out,
1323                 [out,ref,switch_is(*level_out)] drsuapi_DsAddEntryCtr *ctr
1324                 );
1325
1326         /*****************/
1327         /* Function 0x12 */
1328         typedef bitmap {
1329                 DRSUAPI_DS_EXECUTE_KCC_ASYNCHRONOUS_OPERATION   = 0x00000001,
1330                 DRSUAPI_DS_EXECUTE_KCC_DAMPED                   = 0x00000002
1331         } drsuapi_DsExecuteKCCFlags;
1332
1333         typedef struct {
1334                 uint32 taskID;
1335                 drsuapi_DsExecuteKCCFlags flags;
1336         } drsuapi_DsExecuteKCC1;
1337
1338         typedef [switch_type(uint32)] union {
1339                 [case(1)] drsuapi_DsExecuteKCC1 ctr1;
1340         } drsuapi_DsExecuteKCCRequest;
1341
1342         WERROR drsuapi_DsExecuteKCC(
1343                 [in] policy_handle *bind_handle,
1344                 [in] uint32 level,
1345                 [in, ref, switch_is(level)] drsuapi_DsExecuteKCCRequest *req
1346                 );
1347
1348         /*****************/
1349         /* Function 0x13 */
1350         typedef [v1_enum] enum {
1351                 DRSUAPI_DS_REPLICA_GET_INFO                             = 1,
1352                 DRSUAPI_DS_REPLICA_GET_INFO2                            = 2
1353         } drsuapi_DsReplicaGetInfoLevel;
1354
1355         typedef [v1_enum] enum {
1356                 DRSUAPI_DS_REPLICA_INFO_NEIGHBORS                       = 0,
1357                 DRSUAPI_DS_REPLICA_INFO_CURSORS                         = 1,
1358                 DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA                    = 2,
1359                 DRSUAPI_DS_REPLICA_INFO_KCC_DSA_CONNECT_FAILURES        = 3,
1360                 DRSUAPI_DS_REPLICA_INFO_KCC_DSA_LINK_FAILURES           = 4,
1361                 DRSUAPI_DS_REPLICA_INFO_PENDING_OPS                     = 5,
1362                 DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA        = 6,
1363                 DRSUAPI_DS_REPLICA_INFO_CURSORS2                        = 7,
1364                 DRSUAPI_DS_REPLICA_INFO_CURSORS3                        = 8,
1365                 DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA2                   = 9,
1366                 DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA2       = 10,
1367                 DRSUAPI_DS_REPLICA_INFO_NEIGHBORS02                     = -2,
1368                 DRSUAPI_DS_REPLICA_INFO_CONNECTIONS04                   = -4,
1369                 DRSUAPI_DS_REPLICA_INFO_CURSORS05                       = -5,
1370                 DRSUAPI_DS_REPLICA_INFO_06                              = -6
1371         } drsuapi_DsReplicaInfoType;
1372
1373         typedef struct {
1374                 drsuapi_DsReplicaInfoType info_type;
1375                 [charset(UTF16),string] uint16 *object_dn;
1376                 GUID guid1;
1377         } drsuapi_DsReplicaGetInfoRequest1;
1378
1379         typedef struct {
1380                 drsuapi_DsReplicaInfoType info_type;
1381                 [charset(UTF16),string] uint16 *object_dn;
1382                 GUID guid1;
1383                 uint32 flags;
1384                 [charset(UTF16),string] uint16 *string1;
1385                 [charset(UTF16),string] uint16 *string2;
1386                 uint32 enumeration_context;
1387         } drsuapi_DsReplicaGetInfoRequest2;
1388
1389         typedef [switch_type(drsuapi_DsReplicaGetInfoLevel)] union {
1390                 [case(DRSUAPI_DS_REPLICA_GET_INFO)] drsuapi_DsReplicaGetInfoRequest1 req1;
1391                 [case(DRSUAPI_DS_REPLICA_GET_INFO2)] drsuapi_DsReplicaGetInfoRequest2 req2;
1392         } drsuapi_DsReplicaGetInfoRequest;
1393
1394         typedef struct {
1395                 [charset(UTF16),string] uint16 *naming_context_dn;
1396                 [charset(UTF16),string] uint16 *source_dsa_obj_dn;
1397                 [charset(UTF16),string] uint16 *source_dsa_address;
1398                 [charset(UTF16),string] uint16 *transport_obj_dn;
1399                 drsuapi_DrsOptions replica_flags;
1400                 uint32 reserved;
1401                 GUID naming_context_obj_guid;
1402                 GUID source_dsa_obj_guid;
1403                 GUID source_dsa_invocation_id;
1404                 GUID transport_obj_guid;
1405                 hyper tmp_highest_usn;
1406                 hyper highest_usn;
1407                 NTTIME last_success;
1408                 NTTIME last_attempt;
1409                 WERROR result_last_attempt;
1410                 uint32 consecutive_sync_failures;
1411         } drsuapi_DsReplicaNeighbour;
1412
1413         typedef struct {
1414                 uint32 count;
1415                 uint32 reserved;
1416                 [size_is(count)] drsuapi_DsReplicaNeighbour array[];
1417         } drsuapi_DsReplicaNeighbourCtr;
1418
1419         typedef struct {
1420                 uint32 count;
1421                 uint32 reserved;
1422                 [size_is(count)] drsuapi_DsReplicaCursor array[];
1423         } drsuapi_DsReplicaCursorCtr;
1424
1425         typedef struct {
1426                 [charset(UTF16),string] uint16 *attribute_name;
1427                 uint32 version;
1428                 NTTIME originating_change_time;
1429                 GUID originating_invocation_id;
1430                 hyper originating_usn;
1431                 hyper local_usn;
1432         } drsuapi_DsReplicaObjMetaData;
1433
1434         typedef struct {
1435                 uint32 count;
1436                 uint32 reserved;
1437                 [size_is(count)] drsuapi_DsReplicaObjMetaData array[];
1438         } drsuapi_DsReplicaObjMetaDataCtr;
1439
1440         typedef struct {
1441                 [charset(UTF16),string] uint16 *dsa_obj_dn;
1442                 GUID dsa_obj_guid;
1443                 NTTIME first_failure;
1444                 uint32 num_failures;
1445                 WERROR last_result;
1446         } drsuapi_DsReplicaKccDsaFailure;
1447
1448         typedef struct {
1449                 uint32 count;
1450                 uint32 reserved;
1451                 [size_is(count)] drsuapi_DsReplicaKccDsaFailure array[];
1452         } drsuapi_DsReplicaKccDsaFailuresCtr;
1453
1454         typedef enum {
1455                 DRSUAPI_DS_REPLICA_OP_TYPE_SYNC         = 0,
1456                 DRSUAPI_DS_REPLICA_OP_TYPE_ADD          = 1,
1457                 DRSUAPI_DS_REPLICA_OP_TYPE_DELETE       = 2,
1458                 DRSUAPI_DS_REPLICA_OP_TYPE_MODIFY       = 3,
1459                 DRSUAPI_DS_REPLICA_OP_TYPE_UPDATE_REFS  = 4
1460         } drsuapi_DsReplicaOpType;
1461
1462         typedef struct {
1463                 NTTIME operation_start;
1464                 uint32 serial_num; /* unique till reboot */
1465                 uint32 priority;
1466                 drsuapi_DsReplicaOpType operation_type;
1467                 drsuapi_DrsOptions options;
1468                 [charset(UTF16),string] uint16 *nc_dn;
1469                 [charset(UTF16),string] uint16 *remote_dsa_obj_dn;
1470                 [charset(UTF16),string] uint16 *remote_dsa_address;
1471                 GUID nc_obj_guid;
1472                 GUID remote_dsa_obj_guid;
1473         } drsuapi_DsReplicaOp;
1474
1475         typedef struct {
1476                 NTTIME time;
1477                 uint32 count;
1478                 [size_is(count)] drsuapi_DsReplicaOp array[];
1479         } drsuapi_DsReplicaOpCtr;
1480
1481         typedef struct {
1482                 [charset(UTF16),string] uint16 *attribute_name;
1483                 [charset(UTF16),string] uint16 *object_dn;
1484                 [value(ndr_size_DATA_BLOB(0,binary,0))] uint32 __ndr_size_binary;
1485                 DATA_BLOB *binary;
1486                 NTTIME deleted;
1487                 NTTIME created;
1488                 uint32 version;
1489                 NTTIME originating_change_time;
1490                 GUID originating_invocation_id;
1491                 hyper originating_usn;
1492                 hyper local_usn;
1493         } drsuapi_DsReplicaAttrValMetaData;
1494
1495         typedef struct {
1496                 uint32 count;
1497                 uint32 enumeration_context;
1498                 [size_is(count)] drsuapi_DsReplicaAttrValMetaData array[];
1499         } drsuapi_DsReplicaAttrValMetaDataCtr;
1500
1501         typedef struct {
1502                 uint32 count;
1503                 uint32 enumeration_context;
1504                 [size_is(count)] drsuapi_DsReplicaCursor2 array[];
1505         } drsuapi_DsReplicaCursor2Ctr;
1506
1507         typedef struct {
1508                 GUID source_dsa_invocation_id;
1509                 hyper highest_usn;
1510                 NTTIME last_sync_success;
1511                 [charset(UTF16),string] uint16 *source_dsa_obj_dn;
1512         } drsuapi_DsReplicaCursor3;
1513
1514         typedef struct {
1515                 uint32 count;
1516                 uint32 enumeration_context;
1517                 [size_is(count)] drsuapi_DsReplicaCursor3 array[];
1518         } drsuapi_DsReplicaCursor3Ctr;
1519
1520         typedef struct {
1521                 [charset(UTF16),string] uint16 *attribute_name;
1522                 uint32 version;
1523                 NTTIME originating_change_time;
1524                 GUID originating_invocation_id;
1525                 hyper originating_usn;
1526                 hyper local_usn;
1527                 [charset(UTF16),string] uint16 *originating_dsa_dn;
1528         } drsuapi_DsReplicaObjMetaData2;
1529
1530         typedef struct {
1531                 uint32 count;
1532                 uint32 enumeration_context;
1533                 [size_is(count)] drsuapi_DsReplicaObjMetaData2 array[];
1534         } drsuapi_DsReplicaObjMetaData2Ctr;
1535
1536         typedef struct {
1537                 [charset(UTF16),string] uint16 *attribute_name;
1538                 [charset(UTF16),string] uint16 *object_dn;
1539                 [value(ndr_size_DATA_BLOB(0,binary,0))] uint32 __ndr_size_binary;
1540                 DATA_BLOB *binary;
1541                 NTTIME deleted;
1542                 NTTIME created;
1543                 uint32 version;
1544                 NTTIME originating_change_time;
1545                 GUID originating_invocation_id;
1546                 hyper originating_usn;
1547                 hyper local_usn;
1548                 [charset(UTF16),string] uint16 *originating_dsa_dn;
1549         } drsuapi_DsReplicaAttrValMetaData2;
1550
1551         typedef struct {
1552                 uint32 count;
1553                 uint32 enumeration_context;
1554                 [size_is(count)] drsuapi_DsReplicaAttrValMetaData2 array[];
1555         } drsuapi_DsReplicaAttrValMetaData2Ctr;
1556
1557         typedef struct {
1558                 hyper u1; /* session number? */
1559                 uint32 u2;
1560                 uint32 u3;
1561                 GUID bind_guid;
1562                 NTTIME_1sec bind_time;
1563                 [flag(NDR_BIG_ENDIAN)] ipv4address client_ip_address;
1564                 uint32 u5; /* this is the same value the client used as pid in the DsBindInfoX struct */
1565         } drsuapi_DsReplicaConnection04;
1566
1567         typedef struct {
1568                 [range(0,10000)] uint32 count;
1569                 uint32 reserved;
1570                 [size_is(count)] drsuapi_DsReplicaConnection04 array[];
1571         } drsuapi_DsReplicaConnection04Ctr;
1572
1573         typedef struct {
1574                 [charset(UTF16),string] uint16 *str1;
1575                 uint32 u1;
1576                 uint32 u2;
1577                 uint32 u3;
1578                 uint32 u4;
1579                 uint32 u5;
1580                 hyper u6;
1581                 uint32 u7;
1582         } drsuapi_DsReplica06;
1583
1584         typedef struct {
1585                 [range(0,256)] uint32 count;
1586                 uint32 reserved;
1587                 [size_is(count)] drsuapi_DsReplica06 array[];
1588         } drsuapi_DsReplica06Ctr;
1589
1590         typedef [switch_type(drsuapi_DsReplicaInfoType)] union {
1591                 [case(DRSUAPI_DS_REPLICA_INFO_NEIGHBORS)] drsuapi_DsReplicaNeighbourCtr *neighbours;
1592                 [case(DRSUAPI_DS_REPLICA_INFO_CURSORS)] drsuapi_DsReplicaCursorCtr *cursors;
1593                 [case(DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA)] drsuapi_DsReplicaObjMetaDataCtr *objmetadata;
1594                 [case(DRSUAPI_DS_REPLICA_INFO_KCC_DSA_CONNECT_FAILURES)] drsuapi_DsReplicaKccDsaFailuresCtr *connectfailures;
1595                 [case(DRSUAPI_DS_REPLICA_INFO_KCC_DSA_LINK_FAILURES)] drsuapi_DsReplicaKccDsaFailuresCtr *linkfailures;
1596                 [case(DRSUAPI_DS_REPLICA_INFO_PENDING_OPS)] drsuapi_DsReplicaOpCtr *pendingops;
1597                 [case(DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA)] drsuapi_DsReplicaAttrValMetaDataCtr *attrvalmetadata;
1598                 [case(DRSUAPI_DS_REPLICA_INFO_CURSORS2)] drsuapi_DsReplicaCursor2Ctr *cursors2;
1599                 [case(DRSUAPI_DS_REPLICA_INFO_CURSORS3)] drsuapi_DsReplicaCursor3Ctr *cursors3;
1600                 [case(DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA2)] drsuapi_DsReplicaObjMetaData2Ctr *objmetadata2;
1601                 [case(DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA2)] drsuapi_DsReplicaAttrValMetaData2Ctr *attrvalmetadata2;
1602                 [case(DRSUAPI_DS_REPLICA_INFO_NEIGHBORS02)] drsuapi_DsReplicaNeighbourCtr *neighbours02;
1603                 [case(DRSUAPI_DS_REPLICA_INFO_CONNECTIONS04)] drsuapi_DsReplicaConnection04Ctr *connections04;
1604                 [case(DRSUAPI_DS_REPLICA_INFO_CURSORS05)] drsuapi_DsReplicaCursorCtrEx *cursors05;
1605                 [case(DRSUAPI_DS_REPLICA_INFO_06)] drsuapi_DsReplica06Ctr *i06;
1606         } drsuapi_DsReplicaInfo;
1607
1608         WERROR drsuapi_DsReplicaGetInfo(
1609                 [in] policy_handle *bind_handle,
1610                 [in] drsuapi_DsReplicaGetInfoLevel level,
1611                 [in,ref,switch_is(level)] drsuapi_DsReplicaGetInfoRequest *req,
1612                 [out,ref] drsuapi_DsReplicaInfoType *info_type,
1613                 [out,ref,switch_is(*info_type)] drsuapi_DsReplicaInfo *info
1614                 );
1615
1616         /*****************/
1617         /* Function 0x14 */
1618         [todo] WERROR DRSUAPI_ADD_SID_HISTORY();
1619
1620         /*****************/
1621         /* Function 0x15 */
1622
1623         typedef struct {
1624                 [range(0,10000)] uint32 num_entries;
1625                 [size_is(num_entries)] drsuapi_DsGetMembershipsCtr1 **ctrl_array;
1626         } drsuapi_DsGetMemberships2Ctr1;
1627
1628         typedef [switch_type(int32)] union {
1629                 [case(1)] drsuapi_DsGetMembershipsCtr1 ctr1;
1630         } drsuapi_DsGetMemberships2Ctr;
1631
1632         typedef struct {
1633                 [range(1,10000)] uint32 num_req;
1634                 [size_is(num_req)] drsuapi_DsGetMembershipsRequest1 **req_array;
1635         } drsuapi_DsGetMemberships2Request1;
1636
1637         typedef [switch_type(int32)] union {
1638                 [case(1)] drsuapi_DsGetMemberships2Request1 req1;
1639         } drsuapi_DsGetMemberships2Request;
1640
1641         WERROR drsuapi_DsGetMemberships2(
1642                 [in] policy_handle *bind_handle,
1643                 [in] int32 level,
1644                 [in,ref] [switch_is(level)] drsuapi_DsGetMemberships2Request *req,
1645                 [out,ref] int32 *level_out,
1646                 [out,ref] [switch_is(*level_out)] drsuapi_DsGetMemberships2Ctr *ctr
1647                 );
1648
1649         /*****************/
1650         /* Function 0x16 */
1651         [todo] WERROR DRSUAPI_REPLICA_VERIFY_OBJECTS();
1652
1653         /*****************/
1654         /* Function 0x17 */
1655         [todo] WERROR DRSUAPI_GET_OBJECT_EXISTENCE();
1656
1657         /*****************/
1658         /* Function 0x18 */
1659         typedef struct {
1660                 WERROR error_code;
1661                 uint32 site_cost;
1662         } drsuapi_DsSiteCostInfo;
1663
1664         typedef struct {
1665                 [range(0,10000)] uint32 num_info;
1666                 [size_is(num_info)] drsuapi_DsSiteCostInfo *info;
1667                 uint32 unknown;
1668         } drsuapi_QuerySitesByCostCtr1;
1669
1670         typedef [switch_type(int32)] union {
1671                 [case(1)] drsuapi_QuerySitesByCostCtr1 ctr1;
1672         } drsuapi_QuerySitesByCostCtr;
1673
1674         typedef struct {
1675                 [charset(UTF16),string] uint16 *site_from;
1676                 [range(1,10000)] uint32 num_req;
1677                 [size_is(num_req)] [charset(UTF16),string] uint16 **site_to;
1678                 uint32 flags;
1679         } drsuapi_QuerySitesByCostRequest1;
1680
1681         typedef [switch_type(int32)] union {
1682                 [case(1)] drsuapi_QuerySitesByCostRequest1 req1;
1683         } drsuapi_QuerySitesByCostRequest;
1684
1685         WERROR drsuapi_QuerySitesByCost(
1686                 [in] policy_handle *bind_handle,
1687                 [in] int32 level,
1688                 [in,ref] [switch_is(level)] drsuapi_QuerySitesByCostRequest *req,
1689                 [out,ref] int32 *level_out,
1690                 [out,ref] [switch_is(*level_out)] drsuapi_QuerySitesByCostCtr *ctr
1691         );
1692 }