Fill the meta data vector in the responce struct.
[ira/wip.git] / source4 / rpc_server / drsuapi / dcesrv_drsuapi.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    endpoint server for the drsuapi pipe
5
6    Copyright (C) Stefan Metzmacher 2004
7    Copyright (C) Andrew Bartlett <abartlet@samba.org> 2006
8    
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 3 of the License, or
12    (at your option) any later version.
13    
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 #include "includes.h"
24 #include "librpc/gen_ndr/ndr_drsuapi.h"
25 #include "rpc_server/dcerpc_server.h"
26 #include "rpc_server/common/common.h"
27 #include "rpc_server/drsuapi/dcesrv_drsuapi.h"
28 #include "dsdb/samdb/samdb.h"
29 #include "lib/ldb/include/ldb_errors.h"
30 #include "param/param.h"
31 #include "librpc/gen_ndr/ndr_drsblobs.h"
32
33 /* 
34   drsuapi_DsBind 
35 */
36 static WERROR dcesrv_drsuapi_DsBind(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
37                        struct drsuapi_DsBind *r)
38 {
39         struct drsuapi_bind_state *b_state;
40         struct dcesrv_handle *handle;
41         struct drsuapi_DsBindInfoCtr *bind_info;
42         struct GUID site_guid;
43         struct ldb_result *site_res;
44         struct ldb_dn *server_site_dn;
45         static const char *site_attrs[] = { "objectGUID", NULL };
46         struct ldb_result *ntds_res;
47         struct ldb_dn *ntds_dn;
48         static const char *ntds_attrs[] = { "ms-DS-ReplicationEpoch", NULL };
49         uint32_t pid;
50         uint32_t repl_epoch;
51         int ret;
52
53         r->out.bind_info = NULL;
54         ZERO_STRUCTP(r->out.bind_handle);
55
56         b_state = talloc_zero(mem_ctx, struct drsuapi_bind_state);
57         W_ERROR_HAVE_NO_MEMORY(b_state);
58
59         /*
60          * connect to the samdb
61          */
62         b_state->sam_ctx = samdb_connect(b_state, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info); 
63         if (!b_state->sam_ctx) {
64                 return WERR_FOOBAR;
65         }
66
67         /*
68          * find out the guid of our own site
69          */
70         server_site_dn = samdb_server_site_dn(b_state->sam_ctx, mem_ctx);
71         W_ERROR_HAVE_NO_MEMORY(server_site_dn);
72
73         ret = ldb_search(b_state->sam_ctx, mem_ctx, &site_res,
74                                  server_site_dn, LDB_SCOPE_BASE, site_attrs,
75                                  "(objectClass=*)");
76         if (ret != LDB_SUCCESS) {
77                 return WERR_DS_DRA_INTERNAL_ERROR;
78         }
79         if (site_res->count != 1) {
80                 return WERR_DS_DRA_INTERNAL_ERROR;
81         }
82         site_guid = samdb_result_guid(site_res->msgs[0], "objectGUID");
83
84         /*
85          * lookup the local servers Replication Epoch
86          */
87         ntds_dn = samdb_ntds_settings_dn(b_state->sam_ctx);
88         W_ERROR_HAVE_NO_MEMORY(ntds_dn);
89
90         ret = ldb_search(b_state->sam_ctx, mem_ctx, &ntds_res,
91                                  ntds_dn, LDB_SCOPE_BASE, ntds_attrs,
92                                  "(objectClass=*)");
93         if (ret != LDB_SUCCESS) {
94                 return WERR_DS_DRA_INTERNAL_ERROR;
95         }
96         if (ntds_res->count != 1) {
97                 return WERR_DS_DRA_INTERNAL_ERROR;
98         }
99         repl_epoch = samdb_result_uint(ntds_res->msgs[0], "ms-DS-ReplicationEpoch", 0);
100
101         /*
102          * The "process identifier" of the client.
103          * According to the WSPP docs, sectin 5.35, this is
104          * for informational and debugging purposes only.
105          * The assignment is implementation specific.
106          */
107         pid = 0;
108
109         /*
110          * store the clients bind_guid
111          */
112         if (r->in.bind_guid) {
113                 b_state->remote_bind_guid = *r->in.bind_guid;
114         }
115
116         /*
117          * store the clients bind_info
118          */
119         if (r->in.bind_info) {
120                 switch (r->in.bind_info->length) {
121                 case 24: {
122                         struct drsuapi_DsBindInfo24 *info24;
123                         info24 = &r->in.bind_info->info.info24;
124                         b_state->remote_info28.supported_extensions     = info24->supported_extensions;
125                         b_state->remote_info28.site_guid                = info24->site_guid;
126                         b_state->remote_info28.pid                      = info24->pid;
127                         b_state->remote_info28.repl_epoch               = 0;
128                         break;
129                 }
130                 case 28:
131                         b_state->remote_info28 = r->in.bind_info->info.info28;
132                         break;
133                 }
134         }
135
136         /*
137          * fill in our local bind info 28
138          */
139         b_state->local_info28.supported_extensions      = 0;
140         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_BASE;
141         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_ASYNC_REPLICATION;
142         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_REMOVEAPI;
143         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_MOVEREQ_V2;
144 #if 0 /* we don't support MSZIP compression (only decompression) */
145         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_GETCHG_COMPRESS;
146 #endif
147         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V1;
148         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_RESTORE_USN_OPTIMIZATION;
149         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_KCC_EXECUTE;
150         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY_V2;
151         if (0 /*domain.behavior_version == 2*/) {
152                 /* TODO: find out how this is really triggered! */
153                 b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_LINKED_VALUE_REPLICATION;
154         }
155         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V2;
156         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD;
157         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_CRYPTO_BIND;
158         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_GET_REPL_INFO;
159         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION;
160         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V01;
161         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_TRANSITIVE_MEMBERSHIP;
162         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_ADD_SID_HISTORY;
163         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_POST_BETA3;
164         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_00100000;
165         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_GET_MEMBERSHIPS2;
166         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V6;
167         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_NONDOMAIN_NCS;
168         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8;
169         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V5;
170         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V6;
171         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3;
172         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V7;
173         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_VERIFY_OBJECT;
174 #if 0 /* we don't support XPRESS compression yet */
175         b_state->local_info28.supported_extensions      |= DRSUAPI_SUPPORTED_EXTENSION_XPRESS_COMPRESS;
176 #endif
177         b_state->local_info28.site_guid                 = site_guid;
178         b_state->local_info28.pid                       = pid;
179         b_state->local_info28.repl_epoch                = repl_epoch;
180
181         /*
182          * allocate the return bind_info
183          */
184         bind_info = talloc(mem_ctx, struct drsuapi_DsBindInfoCtr);
185         W_ERROR_HAVE_NO_MEMORY(bind_info);
186
187         bind_info->length       = 28;
188         bind_info->info.info28  = b_state->local_info28;
189
190         /*
191          * allocate a bind handle
192          */
193         handle = dcesrv_handle_new(dce_call->context, DRSUAPI_BIND_HANDLE);
194         W_ERROR_HAVE_NO_MEMORY(handle);
195         handle->data = talloc_steal(handle, b_state);
196
197         /*
198          * prepare reply
199          */
200         r->out.bind_info = bind_info;
201         *r->out.bind_handle = handle->wire_handle;
202
203         return WERR_OK;
204 }
205
206
207 /* 
208   drsuapi_DsUnbind 
209 */
210 static WERROR dcesrv_drsuapi_DsUnbind(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
211                                struct drsuapi_DsUnbind *r)
212 {
213         struct dcesrv_handle *h;
214
215         *r->out.bind_handle = *r->in.bind_handle;
216
217         DCESRV_PULL_HANDLE_WERR(h, r->in.bind_handle, DRSUAPI_BIND_HANDLE);
218
219         talloc_free(h);
220
221         ZERO_STRUCTP(r->out.bind_handle);
222
223         return WERR_OK;
224 }
225
226
227 /* 
228   drsuapi_DsReplicaSync 
229 */
230 static WERROR dcesrv_drsuapi_DsReplicaSync(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
231                        struct drsuapi_DsReplicaSync *r)
232 {
233         /* TODO: implement this call correct!
234          *       for now we just say yes,
235          *       because we have no output parameter
236          */
237         return WERR_OK;
238 }
239
240 int drsuapi_search_with_extended_dn(struct ldb_context *ldb,
241                                 TALLOC_CTX *mem_ctx,
242                                 struct ldb_result **_res,
243                                 struct ldb_dn *basedn,
244                                 enum ldb_scope scope,
245                                 const char * const *attrs,
246                                 const char *format, ...)
247 {
248         va_list ap;
249         int ret;
250         struct ldb_request *req;
251         char *filter;
252         TALLOC_CTX *tmp_ctx;
253         struct ldb_result *res;
254
255         tmp_ctx = talloc_new(mem_ctx);
256
257         res = talloc_zero(tmp_ctx, struct ldb_result);
258         if (!res) {
259                 return LDB_ERR_OPERATIONS_ERROR;
260         }
261
262         va_start(ap, format);
263         filter = talloc_vasprintf(tmp_ctx, format, ap);
264         va_end(ap);
265
266         if (filter == NULL) {
267                 talloc_free(tmp_ctx);
268                 return LDB_ERR_OPERATIONS_ERROR;
269         }
270
271         ret = ldb_build_search_req(&req, ldb, tmp_ctx,
272                                    basedn,
273                                    scope,
274                                    filter,
275                                    attrs,
276                                    NULL,
277                                    res,
278                                    ldb_search_default_callback,
279                                    NULL);
280         if (ret != LDB_SUCCESS) {
281                 talloc_free(tmp_ctx);
282                 return ret;
283         }
284
285         ret = ldb_request_add_control(req, LDB_CONTROL_EXTENDED_DN_OID, true, NULL);
286         if (ret != LDB_SUCCESS) {
287                 return ret;
288         }
289
290         ret = ldb_request(ldb, req);
291         if (ret == LDB_SUCCESS) {
292                 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
293         }
294
295         talloc_free(req);
296         *_res = res;
297         return ret;
298 }
299
300
301 /* 
302   drsuapi_DsGetNCChanges
303 */
304 static WERROR dcesrv_drsuapi_DsGetNCChanges(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
305                        struct drsuapi_DsGetNCChanges *r)
306 {
307         struct ldb_result *site_res;
308         struct drsuapi_DsReplicaObjectIdentifier *ncRoot;
309         struct drsuapi_bind_state *b_state;
310         struct ldb_dn *ncRoot_dn;
311         int ret;
312         int i;
313         int j;
314         int uSN;
315         struct dsdb_schema *schema;
316         struct drsuapi_DsReplicaOIDMapping_Ctr *ctr;
317         time_t t = time(NULL);
318         NTTIME now;
319         struct drsuapi_DsReplicaObjectListItemEx *currentObject;
320         struct dom_sid *zero_sid;
321         struct ldb_dn *obj_dn;
322         enum ndr_err_code ndr_err;
323         const struct ldb_val *md_value;
324         struct replPropertyMetaDataBlob md;
325         ZERO_STRUCT(md);
326         md.version = 1;
327         b_state = talloc_zero(mem_ctx, struct drsuapi_bind_state);
328         W_ERROR_HAVE_NO_MEMORY(b_state);
329         zero_sid = talloc_zero(mem_ctx, struct dom_sid);
330         /*
331          * connect to the samdb
332          */
333         b_state->sam_ctx = samdb_connect(b_state, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
334         if (!b_state->sam_ctx) {
335                 return WERR_FOOBAR;
336         }
337
338         /* Check request revision. */
339         if (r->in.level != 8) {
340                 return WERR_REVISION_MISMATCH;
341         }
342
343         /* Perform access checks. */
344         if (r->in.req->req8.naming_context == NULL) {
345                 return WERR_DS_DRA_INVALID_PARAMETER;
346         }
347
348         ncRoot = r->in.req->req8.naming_context;
349         if (ncRoot == NULL) {
350                 return WERR_DS_DRA_BAD_NC;
351         }
352
353         /* Construct response. */
354         ncRoot_dn = ldb_dn_new(mem_ctx, b_state->sam_ctx, ncRoot->dn);
355         ret = drsuapi_search_with_extended_dn(b_state->sam_ctx, mem_ctx, &site_res,
356                          ncRoot_dn, LDB_SCOPE_SUBTREE, NULL,
357                          "(&(uSNChanged>=%lld)(objectClass=*))", r->in.req->req8.highwatermark.highest_usn);
358         if (ret != LDB_SUCCESS) {
359                 return WERR_DS_DRA_INTERNAL_ERROR;
360         }
361
362         *r->out.level_out = 6;
363         r->out.ctr->ctr6.naming_context = talloc(mem_ctx, struct drsuapi_DsReplicaObjectIdentifier);
364         *r->out.ctr->ctr6.naming_context = *ncRoot;
365         /* TODO: linked attributes*/
366         r->out.ctr->ctr6.linked_attributes_count = 0;
367         r->out.ctr->ctr6.linked_attributes = NULL;
368
369         r->out.ctr->ctr6.object_count = 0;
370         r->out.ctr->ctr6.more_data = false;
371         r->out.ctr->ctr6.uptodateness_vector = NULL;
372
373         /* Prefix mapping */
374         schema = dsdb_get_schema(b_state->sam_ctx);
375         if (!schema) {
376                 DEBUG(0,("No schema in b_state->sam_ctx"));
377         }
378
379         dsdb_get_oid_mappings_drsuapi(schema, true, mem_ctx, &ctr);
380         r->out.ctr->ctr6.mapping_ctr = *ctr;
381
382         r->out.ctr->ctr6.source_dsa_guid = *(samdb_ntds_objectGUID(b_state->sam_ctx));
383         r->out.ctr->ctr6.source_dsa_invocation_id = *(samdb_ntds_invocation_id(b_state->sam_ctx));
384
385         r->out.ctr->ctr6.old_highwatermark = r->in.req->req8.highwatermark;
386         r->out.ctr->ctr6.new_highwatermark = r->in.req->req8.highwatermark;
387
388         r->out.ctr->ctr6.first_object = talloc(mem_ctx, struct drsuapi_DsReplicaObjectListItemEx);
389         currentObject = r->out.ctr->ctr6.first_object;
390
391         for(i=0; i<site_res->count; i++) {
392                 uSN = ldb_msg_find_attr_as_int(site_res->msgs[i],"uSNChanged", -1);
393                 r->out.ctr->ctr6.object_count++;
394                 if (uSN > r->out.ctr->ctr6.new_highwatermark.highest_usn) {
395                         r->out.ctr->ctr6.new_highwatermark.highest_usn = uSN;
396                 }
397
398                 if (ldb_dn_compare(ncRoot_dn, site_res->msgs[i]->dn) == 0) {
399                         currentObject->is_nc_prefix = true;
400                         currentObject->parent_object_guid = NULL;
401                 } else {
402                         currentObject->is_nc_prefix = false;
403                         currentObject->parent_object_guid = talloc(mem_ctx, struct GUID);
404                         *currentObject->parent_object_guid = samdb_result_guid(site_res->msgs[i], "parentGUID");
405                 }
406                 currentObject->next_object = NULL;
407
408                 currentObject->meta_data_ctr = talloc(mem_ctx, struct drsuapi_DsReplicaMetaDataCtr);
409                 md_value = ldb_msg_find_ldb_val(site_res->msgs[i], "replPropertyMetaData");
410                 if (md_value) {
411                         ndr_err = ndr_pull_struct_blob(md_value, mem_ctx,
412                                                        lp_iconv_convenience(ldb_get_opaque(b_state->sam_ctx, "loadparm")), &md,
413                                                        (ndr_pull_flags_fn_t)ndr_pull_replPropertyMetaDataBlob);
414                         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
415                                 return WERR_DS_DRA_INTERNAL_ERROR;
416                         }
417
418                         if (md.version != 1) {
419                                 return WERR_DS_DRA_INTERNAL_ERROR;
420                         }
421
422                         currentObject->meta_data_ctr->count = md.ctr.ctr1.count;
423                         currentObject->meta_data_ctr->meta_data = talloc_array(mem_ctx, struct drsuapi_DsReplicaMetaData, md.ctr.ctr1.count);
424                         for (j=0; j<md.ctr.ctr1.count; j++) {
425                                 currentObject->meta_data_ctr->meta_data[j].originating_change_time = md.ctr.ctr1.array[j].originating_change_time;
426                                 currentObject->meta_data_ctr->meta_data[j].version = md.ctr.ctr1.array[j].version;
427                                 currentObject->meta_data_ctr->meta_data[j].originating_invocation_id = md.ctr.ctr1.array[j].originating_invocation_id;
428                                 currentObject->meta_data_ctr->meta_data[j].originating_usn = md.ctr.ctr1.array[j].originating_usn;
429                         }
430                 } else {
431                         currentObject->meta_data_ctr->meta_data = talloc(mem_ctx, struct drsuapi_DsReplicaMetaData);
432                         currentObject->meta_data_ctr->count = 0;
433                 }
434                 currentObject->object.identifier = talloc(mem_ctx, struct drsuapi_DsReplicaObjectIdentifier);
435                 obj_dn = ldb_msg_find_attr_as_dn(b_state->sam_ctx, mem_ctx, site_res->msgs[i], "distinguishedName");
436                 currentObject->object.identifier->dn = ldb_dn_get_linearized(obj_dn);
437                 currentObject->object.identifier->guid = GUID_zero();
438                 currentObject->object.identifier->sid = *zero_sid;
439
440                 currentObject->object.attribute_ctr.num_attributes = site_res->msgs[i]->num_elements;
441                 /* Exclude non-replicate attributes from the responce.*/
442                 for (j=0; j<site_res->msgs[i]->num_elements; j++) {
443                         const struct dsdb_attribute *sa;
444                         sa = dsdb_attribute_by_lDAPDisplayName(schema, site_res->msgs[i]->elements[j].name);
445                         if (sa && sa->systemFlags & 0x00000001) {
446                                 ldb_msg_remove_attr(site_res->msgs[i], site_res->msgs[i]->elements[j].name);
447                                 currentObject->object.attribute_ctr.num_attributes--;
448                         }
449                 }
450                 currentObject->object.attribute_ctr.attributes = talloc_array(mem_ctx, struct drsuapi_DsReplicaAttribute,
451                                                                               currentObject->object.attribute_ctr.num_attributes);
452                 for (j=0; j<currentObject->object.attribute_ctr.num_attributes; j++) {
453                         dsdb_attribute_ldb_to_drsuapi(b_state->sam_ctx, schema,&site_res->msgs[i]->elements[j], mem_ctx,
454                                                       &currentObject->object.attribute_ctr.attributes[j]);
455                 }
456
457                 if (i == (site_res->count-1)) {
458                         break;
459                 }
460                 currentObject->next_object = talloc(mem_ctx, struct drsuapi_DsReplicaObjectListItemEx);
461                 currentObject = currentObject->next_object;
462         }
463
464         r->out.ctr->ctr6.uptodateness_vector = talloc(mem_ctx, struct drsuapi_DsReplicaCursor2CtrEx);
465
466         r->out.ctr->ctr6.uptodateness_vector->version = 2;
467         r->out.ctr->ctr6.uptodateness_vector->count = 1;
468         r->out.ctr->ctr6.uptodateness_vector->reserved1 = 0;
469         r->out.ctr->ctr6.uptodateness_vector->reserved2 = 0;
470         r->out.ctr->ctr6.uptodateness_vector->cursors = talloc(mem_ctx, struct drsuapi_DsReplicaCursor2);
471
472         r->out.ctr->ctr6.uptodateness_vector->cursors[0].source_dsa_invocation_id = *(samdb_ntds_invocation_id(b_state->sam_ctx));
473         r->out.ctr->ctr6.uptodateness_vector->cursors[0].highest_usn = r->out.ctr->ctr6.new_highwatermark.highest_usn;
474         unix_to_nt_time(&now, t);
475         r->out.ctr->ctr6.uptodateness_vector->cursors[0].last_sync_success = now;
476
477         return WERR_OK;
478 }
479
480
481 /* 
482   drsuapi_DsReplicaUpdateRefs
483 */
484 static WERROR dcesrv_drsuapi_DsReplicaUpdateRefs(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
485                        struct drsuapi_DsReplicaUpdateRefs *r)
486 {
487         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
488 }
489
490
491 /* 
492   DRSUAPI_REPLICA_ADD 
493 */
494 static WERROR dcesrv_DRSUAPI_REPLICA_ADD(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
495                        struct DRSUAPI_REPLICA_ADD *r)
496 {
497         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
498 }
499
500
501 /* 
502   DRSUAPI_REPLICA_DEL 
503 */
504 static WERROR dcesrv_DRSUAPI_REPLICA_DEL(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
505                        struct DRSUAPI_REPLICA_DEL *r)
506 {
507         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
508 }
509
510
511 /* 
512   DRSUAPI_REPLICA_MODIFY 
513 */
514 static WERROR dcesrv_DRSUAPI_REPLICA_MODIFY(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
515                        struct DRSUAPI_REPLICA_MODIFY *r)
516 {
517         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
518 }
519
520
521 /* 
522   DRSUAPI_VERIFY_NAMES 
523 */
524 static WERROR dcesrv_DRSUAPI_VERIFY_NAMES(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
525                        struct DRSUAPI_VERIFY_NAMES *r)
526 {
527         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
528 }
529
530
531 /* 
532   drsuapi_DsGetMemberships 
533 */
534 static WERROR dcesrv_drsuapi_DsGetMemberships(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
535                        struct drsuapi_DsGetMemberships *r)
536 {
537         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
538 }
539
540
541 /* 
542   DRSUAPI_INTER_DOMAIN_MOVE 
543 */
544 static WERROR dcesrv_DRSUAPI_INTER_DOMAIN_MOVE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
545                        struct DRSUAPI_INTER_DOMAIN_MOVE *r)
546 {
547         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
548 }
549
550
551 /* 
552   drsuapi_DsGetNT4ChangeLog 
553 */
554 static WERROR dcesrv_drsuapi_DsGetNT4ChangeLog(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
555                        struct drsuapi_DsGetNT4ChangeLog *r)
556 {
557         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
558 }
559
560
561 /* 
562   drsuapi_DsCrackNames 
563 */
564 static WERROR dcesrv_drsuapi_DsCrackNames(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
565                             struct drsuapi_DsCrackNames *r)
566 {
567         WERROR status;
568         struct drsuapi_bind_state *b_state;
569         struct dcesrv_handle *h;
570
571         *r->out.level_out = r->in.level;
572
573         DCESRV_PULL_HANDLE_WERR(h, r->in.bind_handle, DRSUAPI_BIND_HANDLE);
574         b_state = h->data;
575
576         r->out.ctr = talloc_zero(mem_ctx, union drsuapi_DsNameCtr);
577         W_ERROR_HAVE_NO_MEMORY(r->out.ctr);
578
579         switch (r->in.level) {
580                 case 1: {
581                         struct drsuapi_DsNameCtr1 *ctr1;
582                         struct drsuapi_DsNameInfo1 *names;
583                         int count;
584                         int i;
585
586                         ctr1 = talloc(mem_ctx, struct drsuapi_DsNameCtr1);
587                         W_ERROR_HAVE_NO_MEMORY(ctr1);
588
589                         count = r->in.req->req1.count;
590                         names = talloc_array(mem_ctx, struct drsuapi_DsNameInfo1, count);
591                         W_ERROR_HAVE_NO_MEMORY(names);
592
593                         for (i=0; i < count; i++) {
594                                 status = DsCrackNameOneName(b_state->sam_ctx, mem_ctx,
595                                                             r->in.req->req1.format_flags,
596                                                             r->in.req->req1.format_offered,
597                                                             r->in.req->req1.format_desired,
598                                                             r->in.req->req1.names[i].str,
599                                                             &names[i]);
600                                 if (!W_ERROR_IS_OK(status)) {
601                                         return status;
602                                 }
603                         }
604
605                         ctr1->count = count;
606                         ctr1->array = names;
607                         r->out.ctr->ctr1 = ctr1;
608
609                         return WERR_OK;
610                 }
611         }
612         
613         return WERR_UNKNOWN_LEVEL;
614 }
615
616 /* 
617   drsuapi_DsWriteAccountSpn 
618 */
619 static WERROR dcesrv_drsuapi_DsWriteAccountSpn(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
620                        struct drsuapi_DsWriteAccountSpn *r)
621 {
622         struct drsuapi_bind_state *b_state;
623         struct dcesrv_handle *h;
624
625         *r->out.level_out = r->in.level;
626
627         DCESRV_PULL_HANDLE_WERR(h, r->in.bind_handle, DRSUAPI_BIND_HANDLE);
628         b_state = h->data;
629
630         r->out.res = talloc(mem_ctx, union drsuapi_DsWriteAccountSpnResult);
631         W_ERROR_HAVE_NO_MEMORY(r->out.res);
632
633         switch (r->in.level) {
634                 case 1: {
635                         struct drsuapi_DsWriteAccountSpnRequest1 *req;
636                         struct ldb_message *msg;
637                         int count, i, ret;
638                         req = &r->in.req->req1;
639                         count = req->count;
640
641                         msg = ldb_msg_new(mem_ctx);
642                         if (msg == NULL) {
643                                 return WERR_NOMEM;
644                         }
645
646                         msg->dn = ldb_dn_new(msg, b_state->sam_ctx, req->object_dn);
647                         if ( ! ldb_dn_validate(msg->dn)) {
648                                 r->out.res->res1.status = WERR_OK;
649                                 return WERR_OK;
650                         }
651                         
652                         /* construct mods */
653                         for (i = 0; i < count; i++) {
654                                 samdb_msg_add_string(b_state->sam_ctx, 
655                                                      msg, msg, "servicePrincipalName",
656                                                      req->spn_names[i].str);
657                         }
658                         for (i=0;i<msg->num_elements;i++) {
659                                 switch (req->operation) {
660                                 case DRSUAPI_DS_SPN_OPERATION_ADD:
661                                         msg->elements[i].flags = LDB_FLAG_MOD_ADD;
662                                         break;
663                                 case DRSUAPI_DS_SPN_OPERATION_REPLACE:
664                                         msg->elements[i].flags = LDB_FLAG_MOD_REPLACE;
665                                         break;
666                                 case DRSUAPI_DS_SPN_OPERATION_DELETE:
667                                         msg->elements[i].flags = LDB_FLAG_MOD_DELETE;
668                                         break;
669                                 }
670                         }
671    
672                         /* Apply to database */
673
674                         ret = ldb_modify(b_state->sam_ctx, msg);
675                         if (ret != 0) {
676                                 DEBUG(0,("Failed to modify SPNs on %s: %s\n",
677                                          ldb_dn_get_linearized(msg->dn), 
678                                          ldb_errstring(b_state->sam_ctx)));
679                                 r->out.res->res1.status = WERR_ACCESS_DENIED;
680                         } else {
681                                 r->out.res->res1.status = WERR_OK;
682                         }
683
684                         return WERR_OK;
685                 }
686         }
687         
688         return WERR_UNKNOWN_LEVEL;
689 }
690
691
692 /* 
693   drsuapi_DsRemoveDSServer
694 */
695 static WERROR dcesrv_drsuapi_DsRemoveDSServer(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
696                                        struct drsuapi_DsRemoveDSServer *r)
697 {
698         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
699 }
700
701
702 /* 
703   DRSUAPI_REMOVE_DS_DOMAIN 
704 */
705 static WERROR dcesrv_DRSUAPI_REMOVE_DS_DOMAIN(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
706                        struct DRSUAPI_REMOVE_DS_DOMAIN *r)
707 {
708         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
709 }
710
711 /* Obtain the site name from a server DN */
712 static const char *result_site_name(struct ldb_dn *site_dn)
713 {
714         /* Format is cn=<NETBIOS name>,cn=Servers,cn=<site>,cn=sites.... */
715         const struct ldb_val *val = ldb_dn_get_component_val(site_dn, 2);
716         const char *name = ldb_dn_get_component_name(site_dn, 2);
717
718         if (!name || (ldb_attr_cmp(name, "cn") != 0)) {
719                 /* Ensure this matches the format.  This gives us a
720                  * bit more confidence that a 'cn' value will be a
721                  * ascii string */
722                 return NULL;
723         }
724         if (val) {
725                 return (char *)val->data;
726         }
727         return NULL;
728 }
729
730 /* 
731   drsuapi_DsGetDomainControllerInfo 
732 */
733 static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_state *b_state, 
734                                                 TALLOC_CTX *mem_ctx,
735                                                 struct drsuapi_DsGetDomainControllerInfo *r)
736 {
737         struct ldb_dn *sites_dn;
738         struct ldb_result *res;
739
740         const char *attrs_account_1[] = { "cn", "dnsHostName", NULL };
741         const char *attrs_account_2[] = { "cn", "dnsHostName", "objectGUID", NULL };
742
743         const char *attrs_none[] = { NULL };
744
745         const char *attrs_site[] = { "objectGUID", NULL };
746
747         const char *attrs_ntds[] = { "options", "objectGUID", NULL };
748
749         const char *attrs_1[] = { "serverReference", "cn", "dnsHostName", NULL };
750         const char *attrs_2[] = { "serverReference", "cn", "dnsHostName", "objectGUID", NULL };
751         const char **attrs;
752
753         struct drsuapi_DsGetDCInfoCtr1 *ctr1;
754         struct drsuapi_DsGetDCInfoCtr2 *ctr2;
755
756         int ret, i;
757
758         *r->out.level_out = r->in.req->req1.level;
759         r->out.ctr = talloc(mem_ctx, union drsuapi_DsGetDCInfoCtr);
760         W_ERROR_HAVE_NO_MEMORY(r->out.ctr);
761
762         sites_dn = samdb_sites_dn(b_state->sam_ctx, mem_ctx);
763         if (!sites_dn) {
764                 return WERR_DS_OBJ_NOT_FOUND;
765         }
766
767         switch (*r->out.level_out) {
768         case -1:
769                 /* this level is not like the others */
770                 return WERR_UNKNOWN_LEVEL;
771         case 1:
772                 attrs = attrs_1;
773                 break;
774         case 2:
775                 attrs = attrs_2;
776                 break;
777         default:
778                 return WERR_UNKNOWN_LEVEL;
779         }
780
781         ret = ldb_search(b_state->sam_ctx, mem_ctx, &res, sites_dn, LDB_SCOPE_SUBTREE, attrs,
782                                  "objectClass=server");
783         
784         if (ret) {
785                 DEBUG(1, ("searching for servers in sites DN %s failed: %s\n", 
786                           ldb_dn_get_linearized(sites_dn), ldb_errstring(b_state->sam_ctx)));
787                 return WERR_GENERAL_FAILURE;
788         }
789
790         switch (*r->out.level_out) {
791         case 1:
792                 ctr1 = &r->out.ctr->ctr1;
793                 ctr1->count = res->count;
794                 ctr1->array = talloc_zero_array(mem_ctx, 
795                                                 struct drsuapi_DsGetDCInfo1, 
796                                                 res->count);
797                 for (i=0; i < res->count; i++) {
798                         struct ldb_dn *domain_dn;
799                         struct ldb_result *res_domain;
800                         struct ldb_result *res_account;
801                         struct ldb_dn *ntds_dn = ldb_dn_copy(mem_ctx, res->msgs[i]->dn);
802                         
803                         struct ldb_dn *ref_dn
804                                 = ldb_msg_find_attr_as_dn(b_state->sam_ctx, 
805                                                           mem_ctx, res->msgs[i], 
806                                                           "serverReference");
807
808                         if (!ntds_dn || !ldb_dn_add_child_fmt(ntds_dn, "CN=NTDS Settings")) {
809                                 return WERR_NOMEM;
810                         }
811
812                         ret = ldb_search(b_state->sam_ctx, mem_ctx, &res_account, ref_dn,
813                                                  LDB_SCOPE_BASE, attrs_account_1, "objectClass=computer");
814                         if (ret == LDB_SUCCESS && res_account->count == 1) {
815                                 const char *errstr;
816                                 ctr1->array[i].dns_name
817                                         = ldb_msg_find_attr_as_string(res_account->msgs[0], "dNSHostName", NULL);
818                                 ctr1->array[i].netbios_name
819                                         = ldb_msg_find_attr_as_string(res_account->msgs[0], "cn", NULL);
820                                 ctr1->array[i].computer_dn
821                                         = ldb_dn_get_linearized(res_account->msgs[0]->dn);
822
823                                 /* Determine if this is the PDC */
824                                 ret = samdb_search_for_parent_domain(b_state->sam_ctx, 
825                                                                      mem_ctx, res_account->msgs[0]->dn,
826                                                                      &domain_dn, &errstr);
827                                 
828                                 if (ret == LDB_SUCCESS) {
829                                         ret = ldb_search(b_state->sam_ctx, mem_ctx, &res_domain, domain_dn,
830                                                                  LDB_SCOPE_BASE, attrs_none, "fSMORoleOwner=%s",
831                                                                  ldb_dn_get_linearized(ntds_dn));
832                                         if (ret) {
833                                                 return WERR_GENERAL_FAILURE;
834                                         }
835                                         if (res_domain->count == 1) {
836                                                 ctr1->array[i].is_pdc = true;
837                                         }
838                                 }
839                         }
840                         if ((ret != LDB_SUCCESS) && (ret != LDB_ERR_NO_SUCH_OBJECT)) {
841                                 DEBUG(5, ("warning: searching for computer DN %s failed: %s\n", 
842                                           ldb_dn_get_linearized(ref_dn), ldb_errstring(b_state->sam_ctx)));
843                         }
844
845                         /* Look at server DN and extract site component */
846                         ctr1->array[i].site_name = result_site_name(res->msgs[i]->dn);
847                         ctr1->array[i].server_dn = ldb_dn_get_linearized(res->msgs[i]->dn);
848
849
850                         ctr1->array[i].is_enabled = true;
851
852                 }
853                 break;
854         case 2:
855                 ctr2 = &r->out.ctr->ctr2;
856                 ctr2->count = res->count;
857                 ctr2->array = talloc_zero_array(mem_ctx, 
858                                                  struct drsuapi_DsGetDCInfo2, 
859                                                  res->count);
860                 for (i=0; i < res->count; i++) {
861                         struct ldb_dn *domain_dn;
862                         struct ldb_result *res_domain;
863                         struct ldb_result *res_account;
864                         struct ldb_dn *ntds_dn = ldb_dn_copy(mem_ctx, res->msgs[i]->dn);
865                         struct ldb_result *res_ntds;
866                         struct ldb_dn *site_dn = ldb_dn_copy(mem_ctx, res->msgs[i]->dn);
867                         struct ldb_result *res_site;
868                         struct ldb_dn *ref_dn
869                                 = ldb_msg_find_attr_as_dn(b_state->sam_ctx, 
870                                                           mem_ctx, res->msgs[i], 
871                                                           "serverReference");
872
873                         if (!ntds_dn || !ldb_dn_add_child_fmt(ntds_dn, "CN=NTDS Settings")) {
874                                 return WERR_NOMEM;
875                         }
876
877                         /* Format is cn=<NETBIOS name>,cn=Servers,cn=<site>,cn=sites.... */
878                         if (!site_dn || !ldb_dn_remove_child_components(site_dn, 2)) {
879                                 return WERR_NOMEM;
880                         }
881
882                         ret = ldb_search(b_state->sam_ctx, mem_ctx, &res_ntds, ntds_dn,
883                                                  LDB_SCOPE_BASE, attrs_ntds, "objectClass=nTDSDSA");
884                         if (ret == LDB_SUCCESS && res_ntds->count == 1) {
885                                 ctr2->array[i].is_gc
886                                         = (ldb_msg_find_attr_as_int(res_ntds->msgs[0], "options", 0) == 1);
887                                 ctr2->array[i].ntds_guid 
888                                         = samdb_result_guid(res_ntds->msgs[0], "objectGUID");
889                                 ctr2->array[i].ntds_dn = ldb_dn_get_linearized(res_ntds->msgs[0]->dn);
890                         }
891                         if ((ret != LDB_SUCCESS) && (ret != LDB_ERR_NO_SUCH_OBJECT)) {
892                                 DEBUG(5, ("warning: searching for NTDS DN %s failed: %s\n", 
893                                           ldb_dn_get_linearized(ntds_dn), ldb_errstring(b_state->sam_ctx)));
894                         }
895
896                         ret = ldb_search(b_state->sam_ctx, mem_ctx, &res_site, site_dn,
897                                                  LDB_SCOPE_BASE, attrs_site, "objectClass=site");
898                         if (ret == LDB_SUCCESS && res_site->count == 1) {
899                                 ctr2->array[i].site_guid 
900                                         = samdb_result_guid(res_site->msgs[0], "objectGUID");
901                                 ctr2->array[i].site_dn = ldb_dn_get_linearized(res_site->msgs[0]->dn);
902                         }
903                         if ((ret != LDB_SUCCESS) && (ret != LDB_ERR_NO_SUCH_OBJECT)) {
904                                 DEBUG(5, ("warning: searching for site DN %s failed: %s\n", 
905                                           ldb_dn_get_linearized(site_dn), ldb_errstring(b_state->sam_ctx)));
906                         }
907
908                         ret = ldb_search(b_state->sam_ctx, mem_ctx, &res_account, ref_dn,
909                                                  LDB_SCOPE_BASE, attrs_account_2, "objectClass=computer");
910                         if (ret == LDB_SUCCESS && res_account->count == 1) {
911                                 const char *errstr;
912                                 ctr2->array[i].dns_name
913                                         = ldb_msg_find_attr_as_string(res_account->msgs[0], "dNSHostName", NULL);
914                                 ctr2->array[i].netbios_name
915                                         = ldb_msg_find_attr_as_string(res_account->msgs[0], "cn", NULL);
916                                 ctr2->array[i].computer_dn = ldb_dn_get_linearized(res_account->msgs[0]->dn);
917                                 ctr2->array[i].computer_guid 
918                                         = samdb_result_guid(res_account->msgs[0], "objectGUID");
919
920                                 /* Determine if this is the PDC */
921                                 ret = samdb_search_for_parent_domain(b_state->sam_ctx, 
922                                                                      mem_ctx, res_account->msgs[0]->dn,
923                                                                      &domain_dn, &errstr);
924                                 
925                                 if (ret == LDB_SUCCESS) {
926                                         ret = ldb_search(b_state->sam_ctx, mem_ctx, &res_domain, domain_dn,
927                                                                  LDB_SCOPE_BASE, attrs_none, "fSMORoleOwner=%s",
928                                                                  ldb_dn_get_linearized(ntds_dn));
929                                         if (ret == LDB_SUCCESS && res_domain->count == 1) {
930                                                 ctr2->array[i].is_pdc = true;
931                                         }
932                                         if ((ret != LDB_SUCCESS) && (ret != LDB_ERR_NO_SUCH_OBJECT)) {
933                                                 DEBUG(5, ("warning: searching for domain DN %s failed: %s\n", 
934                                                           ldb_dn_get_linearized(domain_dn), ldb_errstring(b_state->sam_ctx)));
935                                         }
936                                 }
937                         }
938                         if ((ret != LDB_SUCCESS) && (ret != LDB_ERR_NO_SUCH_OBJECT)) {
939                                 DEBUG(5, ("warning: searching for computer account DN %s failed: %s\n", 
940                                           ldb_dn_get_linearized(ref_dn), ldb_errstring(b_state->sam_ctx)));
941                         }
942
943                         /* Look at server DN and extract site component */
944                         ctr2->array[i].site_name = result_site_name(res->msgs[i]->dn);
945                         ctr2->array[i].server_dn = ldb_dn_get_linearized(res->msgs[i]->dn);
946                         ctr2->array[i].server_guid 
947                                 = samdb_result_guid(res->msgs[i], "objectGUID");
948
949                         ctr2->array[i].is_enabled = true;
950
951                 }
952                 break;
953         }
954         return WERR_OK;
955 }
956
957 /* 
958   drsuapi_DsGetDomainControllerInfo 
959 */
960 static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
961                                                 struct drsuapi_DsGetDomainControllerInfo *r)
962 {
963         struct dcesrv_handle *h;
964         struct drsuapi_bind_state *b_state;     
965         DCESRV_PULL_HANDLE_WERR(h, r->in.bind_handle, DRSUAPI_BIND_HANDLE);
966         b_state = h->data;
967
968         switch (r->in.level) {
969         case 1:
970                 return dcesrv_drsuapi_DsGetDomainControllerInfo_1(b_state, mem_ctx, r);
971         }
972
973         return WERR_UNKNOWN_LEVEL;
974 }
975
976
977 /* 
978   drsuapi_DsAddEntry
979 */
980 static WERROR dcesrv_drsuapi_DsAddEntry(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
981                        struct drsuapi_DsAddEntry *r)
982 {
983         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
984 }
985
986
987 /* 
988   DRSUAPI_EXECUTE_KCC 
989 */
990 static WERROR dcesrv_DRSUAPI_EXECUTE_KCC(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
991                        struct DRSUAPI_EXECUTE_KCC *r)
992 {
993         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
994 }
995
996
997 /* 
998   drsuapi_DsReplicaGetInfo 
999 */
1000 static WERROR dcesrv_drsuapi_DsReplicaGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1001                        struct drsuapi_DsReplicaGetInfo *r)
1002 {
1003         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1004 }
1005
1006
1007 /* 
1008   DRSUAPI_ADD_SID_HISTORY 
1009 */
1010 static WERROR dcesrv_DRSUAPI_ADD_SID_HISTORY(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1011                        struct DRSUAPI_ADD_SID_HISTORY *r)
1012 {
1013         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1014 }
1015
1016 /* 
1017   drsuapi_DsGetMemberships2 
1018 */
1019 static WERROR dcesrv_drsuapi_DsGetMemberships2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1020                        struct drsuapi_DsGetMemberships2 *r)
1021 {
1022         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1023 }
1024
1025 /* 
1026   DRSUAPI_REPLICA_VERIFY_OBJECTS 
1027 */
1028 static WERROR dcesrv_DRSUAPI_REPLICA_VERIFY_OBJECTS(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1029                        struct DRSUAPI_REPLICA_VERIFY_OBJECTS *r)
1030 {
1031         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1032 }
1033
1034
1035 /* 
1036   DRSUAPI_GET_OBJECT_EXISTENCE 
1037 */
1038 static WERROR dcesrv_DRSUAPI_GET_OBJECT_EXISTENCE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1039                        struct DRSUAPI_GET_OBJECT_EXISTENCE *r)
1040 {
1041         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1042 }
1043
1044
1045 /* 
1046   drsuapi_QuerySitesByCost 
1047 */
1048 static WERROR dcesrv_drsuapi_QuerySitesByCost(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1049                        struct drsuapi_QuerySitesByCost *r)
1050 {
1051         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1052 }
1053
1054
1055 /* include the generated boilerplate */
1056 #include "librpc/gen_ndr/ndr_drsuapi_s.c"