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