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