743abdde6fa47fc49042581dc88358845b7019ff
[nivanova/samba-autobuild/.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 2 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, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24 #include "includes.h"
25 #include "librpc/gen_ndr/ndr_drsuapi.h"
26 #include "rpc_server/dcerpc_server.h"
27 #include "rpc_server/common/common.h"
28 #include "rpc_server/drsuapi/dcesrv_drsuapi.h"
29 #include "dsdb/samdb/samdb.h"
30
31 /* 
32   drsuapi_DsBind 
33 */
34 static WERROR drsuapi_DsBind(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
35                        struct drsuapi_DsBind *r)
36 {
37         struct drsuapi_bind_state *b_state;
38         struct dcesrv_handle *handle;
39         struct drsuapi_DsBindInfoCtr *bind_info;
40         struct GUID site_guid;
41
42         r->out.bind_info = NULL;
43         ZERO_STRUCTP(r->out.bind_handle);
44
45         b_state = talloc(dce_call->conn, struct drsuapi_bind_state);
46         W_ERROR_HAVE_NO_MEMORY(b_state);
47
48         b_state->sam_ctx = samdb_connect(b_state, dce_call->conn->auth_state.session_info); 
49         if (!b_state->sam_ctx) {
50                 talloc_free(b_state);
51                 return WERR_FOOBAR;
52         }
53
54         handle = dcesrv_handle_new(dce_call->context, DRSUAPI_BIND_HANDLE);
55         if (!handle) {
56                 talloc_free(b_state);
57                 return WERR_NOMEM;
58         }
59
60         handle->data = talloc_steal(handle, b_state);
61
62         bind_info = talloc(mem_ctx, struct drsuapi_DsBindInfoCtr);
63         W_ERROR_HAVE_NO_MEMORY(bind_info);
64
65         ZERO_STRUCT(site_guid);
66
67         bind_info->length                               = 28;
68         bind_info->info.info28.supported_extensions     = 0;
69         bind_info->info.info28.site_guid                = site_guid;
70         bind_info->info.info28.u1                       = 0;
71         bind_info->info.info28.repl_epoch               = 0;
72
73         r->out.bind_info = bind_info;
74         *r->out.bind_handle = handle->wire_handle;
75
76         return WERR_OK;
77 }
78
79
80 /* 
81   drsuapi_DsUnbind 
82 */
83 static WERROR drsuapi_DsUnbind(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
84                                struct drsuapi_DsUnbind *r)
85 {
86         struct dcesrv_handle *h;
87
88         *r->out.bind_handle = *r->in.bind_handle;
89
90         DCESRV_PULL_HANDLE_WERR(h, r->in.bind_handle, DRSUAPI_BIND_HANDLE);
91
92         talloc_free(h);
93
94         ZERO_STRUCTP(r->out.bind_handle);
95
96         return WERR_OK;
97 }
98
99
100 /* 
101   drsuapi_DsReplicaSync 
102 */
103 static WERROR drsuapi_DsReplicaSync(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
104                        struct drsuapi_DsReplicaSync *r)
105 {
106         /* TODO: implement this call correct!
107          *       for now we just say yes,
108          *       because we have no output parameter
109          */
110         return WERR_OK;
111 }
112
113
114 /* 
115   drsuapi_DsGetNCChanges
116 */
117 static WERROR drsuapi_DsGetNCChanges(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
118                        struct drsuapi_DsGetNCChanges *r)
119 {
120         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
121 }
122
123
124 /* 
125   drsuapi_DsReplicaUpdateRefs
126 */
127 static WERROR drsuapi_DsReplicaUpdateRefs(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
128                        struct drsuapi_DsReplicaUpdateRefs *r)
129 {
130         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
131 }
132
133
134 /* 
135   DRSUAPI_REPLICA_ADD 
136 */
137 static WERROR DRSUAPI_REPLICA_ADD(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
138                        struct DRSUAPI_REPLICA_ADD *r)
139 {
140         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
141 }
142
143
144 /* 
145   DRSUAPI_REPLICA_DEL 
146 */
147 static WERROR DRSUAPI_REPLICA_DEL(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
148                        struct DRSUAPI_REPLICA_DEL *r)
149 {
150         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
151 }
152
153
154 /* 
155   DRSUAPI_REPLICA_MODIFY 
156 */
157 static WERROR DRSUAPI_REPLICA_MODIFY(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
158                        struct DRSUAPI_REPLICA_MODIFY *r)
159 {
160         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
161 }
162
163
164 /* 
165   DRSUAPI_VERIFY_NAMES 
166 */
167 static WERROR DRSUAPI_VERIFY_NAMES(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
168                        struct DRSUAPI_VERIFY_NAMES *r)
169 {
170         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
171 }
172
173
174 /* 
175   drsuapi_DsGetMemberships 
176 */
177 static WERROR drsuapi_DsGetMemberships(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
178                        struct drsuapi_DsGetMemberships *r)
179 {
180         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
181 }
182
183
184 /* 
185   DRSUAPI_INTER_DOMAIN_MOVE 
186 */
187 static WERROR DRSUAPI_INTER_DOMAIN_MOVE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
188                        struct DRSUAPI_INTER_DOMAIN_MOVE *r)
189 {
190         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
191 }
192
193
194 /* 
195   drsuapi_DsGetNT4ChangeLog 
196 */
197 static WERROR drsuapi_DsGetNT4ChangeLog(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
198                        struct drsuapi_DsGetNT4ChangeLog *r)
199 {
200         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
201 }
202
203
204 /* 
205   drsuapi_DsCrackNames 
206 */
207 WERROR drsuapi_DsCrackNames(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
208                             struct drsuapi_DsCrackNames *r)
209 {
210         WERROR status;
211         struct drsuapi_bind_state *b_state;
212         struct dcesrv_handle *h;
213
214         r->out.level = r->in.level;
215         ZERO_STRUCT(r->out.ctr);
216
217         DCESRV_PULL_HANDLE_WERR(h, r->in.bind_handle, DRSUAPI_BIND_HANDLE);
218         b_state = h->data;
219
220         switch (r->in.level) {
221                 case 1: {
222                         struct drsuapi_DsNameCtr1 *ctr1;
223                         struct drsuapi_DsNameInfo1 *names;
224                         int count;
225                         int i;
226
227                         ctr1 = talloc(mem_ctx, struct drsuapi_DsNameCtr1);
228                         W_ERROR_HAVE_NO_MEMORY(ctr1);
229
230                         count = r->in.req.req1.count;
231                         names = talloc_array(mem_ctx, struct drsuapi_DsNameInfo1, count);
232                         W_ERROR_HAVE_NO_MEMORY(names);
233
234                         for (i=0; i < count; i++) {
235                                 status = DsCrackNameOneName(b_state->sam_ctx, mem_ctx,
236                                                             r->in.req.req1.format_flags,
237                                                             r->in.req.req1.format_offered,
238                                                             r->in.req.req1.format_desired,
239                                                             r->in.req.req1.names[i].str,
240                                                             &names[i]);
241                                 if (!W_ERROR_IS_OK(status)) {
242                                         return status;
243                                 }
244                         }
245
246                         ctr1->count = count;
247                         ctr1->array = names;
248                         r->out.ctr.ctr1 = ctr1;
249
250                         return WERR_OK;
251                 }
252         }
253         
254         return WERR_UNKNOWN_LEVEL;
255 }
256
257 /* 
258   drsuapi_DsWriteAccountSpn 
259 */
260 static WERROR drsuapi_DsWriteAccountSpn(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
261                        struct drsuapi_DsWriteAccountSpn *r)
262 {
263         struct drsuapi_bind_state *b_state;
264         struct dcesrv_handle *h;
265
266         r->out.level = r->in.level;
267
268         DCESRV_PULL_HANDLE_WERR(h, r->in.bind_handle, DRSUAPI_BIND_HANDLE);
269         b_state = h->data;
270
271         switch (r->in.level) {
272                 case 1: {
273                         struct drsuapi_DsWriteAccountSpnRequest1 *req;
274                         struct ldb_message *msg;
275                         int count, i, ret;
276                         req = &r->in.req.req1;
277                         count = req->count;
278
279                         msg = ldb_msg_new(mem_ctx);
280                         if (msg == NULL) {
281                                 return WERR_NOMEM;
282                         }
283
284                         msg->dn = ldb_dn_new(msg, b_state->sam_ctx, req->object_dn);
285                         if ( ! ldb_dn_validate(msg->dn)) {
286                                 r->out.res.res1.status = WERR_OK;
287                                 return WERR_OK;
288                         }
289                         
290                         /* construct mods */
291                         for (i = 0; i < count; i++) {
292                                 samdb_msg_add_string(b_state->sam_ctx, 
293                                                      msg, msg, "servicePrincipalName",
294                                                      req->spn_names[i].str);
295                         }
296                         for (i=0;i<msg->num_elements;i++) {
297                                 switch (req->operation) {
298                                 case DRSUAPI_DS_SPN_OPERATION_ADD:
299                                         msg->elements[i].flags = LDB_FLAG_MOD_ADD;
300                                         break;
301                                 case DRSUAPI_DS_SPN_OPERATION_REPLACE:
302                                         msg->elements[i].flags = LDB_FLAG_MOD_REPLACE;
303                                         break;
304                                 case DRSUAPI_DS_SPN_OPERATION_DELETE:
305                                         msg->elements[i].flags = LDB_FLAG_MOD_DELETE;
306                                         break;
307                                 }
308                         }
309    
310                         /* Apply to database */
311
312                         ret = samdb_modify(b_state->sam_ctx, mem_ctx, msg);
313                         if (ret != 0) {
314                                 DEBUG(0,("Failed to modify SPNs on %s: %s\n",
315                                          ldb_dn_get_linearized(msg->dn), 
316                                          ldb_errstring(b_state->sam_ctx)));
317                                 r->out.res.res1.status = WERR_ACCESS_DENIED;
318                         } else {
319                                 r->out.res.res1.status = WERR_OK;
320                         }
321
322                         return WERR_OK;
323                 }
324         }
325         
326         return WERR_UNKNOWN_LEVEL;
327 }
328
329
330 /* 
331   drsuapi_DsRemoveDSServer
332 */
333 static WERROR drsuapi_DsRemoveDSServer(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
334                                        struct drsuapi_DsRemoveDSServer *r)
335 {
336         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
337 }
338
339
340 /* 
341   DRSUAPI_REMOVE_DS_DOMAIN 
342 */
343 static WERROR DRSUAPI_REMOVE_DS_DOMAIN(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
344                        struct DRSUAPI_REMOVE_DS_DOMAIN *r)
345 {
346         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
347 }
348
349 /* Obtain the site name from a server DN */
350 const char *result_site_name(struct ldb_dn *site_dn)
351 {
352         /* Format is cn=<NETBIOS name>,cn=Servers,cn=<site>,cn=sites.... */
353         const struct ldb_val *val = ldb_dn_get_component_val(site_dn, 2);
354         const char *name = ldb_dn_get_component_name(site_dn, 2);
355
356         if (!name || (ldb_attr_cmp(name, "cn") != 0)) {
357                 /* Ensure this matches the format.  This gives us a
358                  * bit more confidence that a 'cn' value will be a
359                  * ascii string */
360                 return NULL;
361         }
362         if (val) {
363                 return (char *)val->data;
364         }
365         return NULL;
366 }
367
368 /* 
369   drsuapi_DsGetDomainControllerInfo 
370 */
371 static WERROR drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_state *b_state, 
372                                                 TALLOC_CTX *mem_ctx,
373                                                 struct drsuapi_DsGetDomainControllerInfo *r)
374 {
375         struct ldb_dn *sites_dn;
376         struct ldb_result *res;
377
378         const char *attrs_account_1[] = { "cn", "dnsHostName", NULL };
379         const char *attrs_account_2[] = { "cn", "dnsHostName", "objectGUID", NULL };
380
381         const char *attrs_none[] = { NULL };
382
383         const char *attrs_site[] = { "objectGUID", NULL };
384
385         const char *attrs_ntds[] = { "options", "objectGUID", NULL };
386
387         const char *attrs_1[] = { "serverReference", "cn", "dnsHostName", NULL };
388         const char *attrs_2[] = { "serverReference", "cn", "dnsHostName", "objectGUID", NULL };
389         const char **attrs;
390
391         struct drsuapi_DsGetDCInfoCtr1 *ctr1;
392         struct drsuapi_DsGetDCInfoCtr2 *ctr2;
393
394         int ret, i;
395
396         r->out.level_out = r->in.req.req1.level;
397
398         sites_dn = samdb_domain_to_dn(b_state->sam_ctx, mem_ctx, r->in.req.req1.domain_name);
399         if (!sites_dn) {
400                 return WERR_DS_OBJ_NOT_FOUND;
401         }
402
403         if (!ldb_dn_add_child_fmt(sites_dn, "CN=Sites,CN=Configuration")) {
404                 return WERR_NOMEM;
405         }
406
407         switch (r->out.level_out) {
408         case -1:
409                 /* this level is not like the others */
410                 return WERR_UNKNOWN_LEVEL;
411         case 1:
412                 attrs = attrs_1;
413                 break;
414         case 2:
415                 attrs = attrs_2;
416                 break;
417         default:
418                 return WERR_UNKNOWN_LEVEL;
419         }
420
421         ret = ldb_search_exp_fmt(b_state->sam_ctx, mem_ctx, &res, sites_dn, LDB_SCOPE_SUBTREE, attrs, 
422                                  "objectClass=server");
423         
424         if (ret) {
425                 return WERR_GENERAL_FAILURE;
426         }
427
428         switch (r->out.level_out) {
429         case 1:
430                 ctr1 = &r->out.ctr.ctr1;
431                 ctr1->count = res->count;
432                 ctr1->array = talloc_zero_array(mem_ctx, 
433                                                 struct drsuapi_DsGetDCInfo1, 
434                                                 res->count);
435                 for (i=0; i < res->count; i++) {
436                         struct ldb_dn *domain_dn;
437                         struct ldb_result *res_domain;
438                         struct ldb_result *res_account;
439                         struct ldb_dn *ntds_dn = ldb_dn_copy(b_state->sam_ctx, res->msgs[i]->dn);
440                         
441                         struct ldb_dn *ref_dn
442                                 = ldb_msg_find_attr_as_dn(b_state->sam_ctx, 
443                                                           mem_ctx, res->msgs[i], 
444                                                           "serverReference");
445
446                         if (!ntds_dn || !ldb_dn_add_child_fmt(ntds_dn, "CN=NTDS Settings")) {
447                                 return WERR_NOMEM;
448                         }
449
450                         ret = ldb_search_exp_fmt(b_state->sam_ctx, mem_ctx, &res_account, ref_dn, 
451                                                  LDB_SCOPE_BASE, attrs_account_1, "objectClass=computer");
452                         if (ret) {
453                                 return WERR_GENERAL_FAILURE;
454                         }
455                         if (res_account->count == 1) {
456                                 ctr1->array[i].dns_name
457                                         = ldb_msg_find_attr_as_string(res_account->msgs[0], "dNSHostName", NULL);
458                                 ctr1->array[i].netbios_name
459                                         = ldb_msg_find_attr_as_string(res_account->msgs[0], "cn", NULL);
460                                 ctr1->array[i].computer_dn
461                                         = ldb_dn_get_linearized(res_account->msgs[0]->dn);
462
463                                 /* Determine if this is the PDC */
464                                 domain_dn = samdb_search_for_parent_domain(b_state->sam_ctx, 
465                                                                            mem_ctx, res_account->msgs[0]->dn);
466                                 
467                                 if (domain_dn) {
468                                         ret = ldb_search_exp_fmt(b_state->sam_ctx, mem_ctx, &res_domain, domain_dn, 
469                                                                  LDB_SCOPE_BASE, attrs_none, "fSMORoleOwner=%s",
470                                                                  ldb_dn_get_linearized(ntds_dn));
471                                         if (ret) {
472                                                 return WERR_GENERAL_FAILURE;
473                                         }
474                                         if (res_domain->count == 1) {
475                                                 ctr1->array[i].is_pdc = True;
476                                         }
477                                 }
478                         }
479
480                         /* Look at server DN and extract site component */
481                         ctr1->array[i].site_name = result_site_name(res->msgs[i]->dn);
482                         ctr1->array[i].server_dn = ldb_dn_get_linearized(res->msgs[i]->dn);
483
484
485                         ctr1->array[i].is_enabled = True;
486
487                 }
488                 break;
489         case 2:
490                 ctr2 = &r->out.ctr.ctr2;
491                 ctr2->count = res->count;
492                 ctr2->array = talloc_zero_array(mem_ctx, 
493                                                  struct drsuapi_DsGetDCInfo2, 
494                                                  res->count);
495                 for (i=0; i < res->count; i++) {
496                         struct ldb_dn *domain_dn;
497                         struct ldb_result *res_domain;
498                         struct ldb_result *res_account;
499                         struct ldb_dn *ntds_dn = ldb_dn_copy(b_state->sam_ctx, res->msgs[i]->dn);
500                         struct ldb_result *res_ntds;
501                         struct ldb_dn *site_dn = ldb_dn_copy(b_state->sam_ctx, res->msgs[i]->dn);
502                         struct ldb_result *res_site;
503                         struct ldb_dn *ref_dn
504                                 = ldb_msg_find_attr_as_dn(b_state->sam_ctx, 
505                                                           mem_ctx, res->msgs[i], 
506                                                           "serverReference");
507
508                         if (!ntds_dn || !ldb_dn_add_child_fmt(ntds_dn, "CN=NTDS Settings")) {
509                                 return WERR_NOMEM;
510                         }
511
512                         /* Format is cn=<NETBIOS name>,cn=Servers,cn=<site>,cn=sites.... */
513                         if (!site_dn || !ldb_dn_remove_child_components(site_dn, 2)) {
514                                 return WERR_NOMEM;
515                         }
516
517                         ret = ldb_search_exp_fmt(b_state->sam_ctx, mem_ctx, &res_ntds, ntds_dn, 
518                                                  LDB_SCOPE_BASE, attrs_ntds, "objectClass=nTDSDSA");
519                         if (ret) {
520                                 return WERR_GENERAL_FAILURE;
521                         }
522                         if (res_ntds->count == 1) {
523                                 ctr2->array[i].is_gc
524                                         = (ldb_msg_find_attr_as_int(res_ntds->msgs[0], "options", 0) == 1);
525                                 ctr2->array[i].ntds_guid 
526                                         = samdb_result_guid(res_ntds->msgs[0], "objectGUID");
527                                 ctr2->array[i].ntds_dn = ldb_dn_get_linearized(res_ntds->msgs[0]->dn);
528                         }
529
530                         ret = ldb_search_exp_fmt(b_state->sam_ctx, mem_ctx, &res_site, site_dn, 
531                                                  LDB_SCOPE_BASE, attrs_site, "objectClass=site");
532                         if (ret) {
533                                 return WERR_GENERAL_FAILURE;
534                         }
535                         if (res_site->count == 1) {
536                                 ctr2->array[i].site_guid 
537                                         = samdb_result_guid(res_site->msgs[0], "objectGUID");
538                                 ctr2->array[i].site_dn = ldb_dn_get_linearized(res_site->msgs[0]->dn);
539                         }
540
541                         ret = ldb_search_exp_fmt(b_state->sam_ctx, mem_ctx, &res_account, ref_dn, 
542                                                  LDB_SCOPE_BASE, attrs_account_2, "objectClass=computer");
543                         if (ret) {
544                                 return WERR_GENERAL_FAILURE;
545                         }
546                         if (res_account->count == 1) {
547                                 ctr2->array[i].dns_name
548                                         = ldb_msg_find_attr_as_string(res_account->msgs[0], "dNSHostName", NULL);
549                                 ctr2->array[i].netbios_name
550                                         = ldb_msg_find_attr_as_string(res_account->msgs[0], "cn", NULL);
551                                 ctr2->array[i].computer_dn = ldb_dn_get_linearized(res_account->msgs[0]->dn);
552                                 ctr2->array[i].computer_guid 
553                                         = samdb_result_guid(res_account->msgs[0], "objectGUID");
554
555                                 /* Determine if this is the PDC */
556                                 domain_dn = samdb_search_for_parent_domain(b_state->sam_ctx, 
557                                                                            mem_ctx, res_account->msgs[0]->dn);
558                                 
559                                 if (domain_dn) {
560                                         ret = ldb_search_exp_fmt(b_state->sam_ctx, mem_ctx, &res_domain, domain_dn, 
561                                                                  LDB_SCOPE_BASE, attrs_none, "fSMORoleOwner=%s",
562                                                                  ldb_dn_get_linearized(ntds_dn));
563                                         if (ret) {
564                                                 return WERR_GENERAL_FAILURE;
565                                         }
566                                         if (res_domain->count == 1) {
567                                                 ctr2->array[i].is_pdc = True;
568                                         }
569                                 }
570                         }
571
572                         /* Look at server DN and extract site component */
573                         ctr2->array[i].site_name = result_site_name(res->msgs[i]->dn);
574                         ctr2->array[i].server_dn = ldb_dn_get_linearized(res->msgs[i]->dn);
575                         ctr2->array[i].server_guid 
576                                 = samdb_result_guid(res->msgs[i], "objectGUID");
577
578                         ctr2->array[i].is_enabled = True;
579
580                 }
581                 break;
582         }
583         return WERR_OK;
584 }
585
586 /* 
587   drsuapi_DsGetDomainControllerInfo 
588 */
589 static WERROR drsuapi_DsGetDomainControllerInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
590                                                 struct drsuapi_DsGetDomainControllerInfo *r)
591 {
592         struct dcesrv_handle *h;
593         struct drsuapi_bind_state *b_state;     
594         DCESRV_PULL_HANDLE_WERR(h, r->in.bind_handle, DRSUAPI_BIND_HANDLE);
595         b_state = h->data;
596
597         switch (r->in.level) {
598         case 1:
599                 return drsuapi_DsGetDomainControllerInfo_1(b_state, mem_ctx, r);
600         }
601
602         return WERR_UNKNOWN_LEVEL;
603 }
604
605
606 /* 
607   drsuapi_DsAddEntry
608 */
609 static WERROR drsuapi_DsAddEntry(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
610                        struct drsuapi_DsAddEntry *r)
611 {
612         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
613 }
614
615
616 /* 
617   DRSUAPI_EXECUTE_KCC 
618 */
619 static WERROR DRSUAPI_EXECUTE_KCC(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
620                        struct DRSUAPI_EXECUTE_KCC *r)
621 {
622         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
623 }
624
625
626 /* 
627   drsuapi_DsReplicaGetInfo 
628 */
629 static WERROR drsuapi_DsReplicaGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
630                        struct drsuapi_DsReplicaGetInfo *r)
631 {
632         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
633 }
634
635
636 /* 
637   DRSUAPI_ADD_SID_HISTORY 
638 */
639 static WERROR DRSUAPI_ADD_SID_HISTORY(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
640                        struct DRSUAPI_ADD_SID_HISTORY *r)
641 {
642         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
643 }
644
645 /* 
646   drsuapi_DsGetMemberships2 
647 */
648 static WERROR drsuapi_DsGetMemberships2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
649                        struct drsuapi_DsGetMemberships2 *r)
650 {
651         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
652 }
653
654 /* 
655   DRSUAPI_REPLICA_VERIFY_OBJECTS 
656 */
657 static WERROR DRSUAPI_REPLICA_VERIFY_OBJECTS(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
658                        struct DRSUAPI_REPLICA_VERIFY_OBJECTS *r)
659 {
660         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
661 }
662
663
664 /* 
665   DRSUAPI_GET_OBJECT_EXISTENCE 
666 */
667 static WERROR DRSUAPI_GET_OBJECT_EXISTENCE(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
668                        struct DRSUAPI_GET_OBJECT_EXISTENCE *r)
669 {
670         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
671 }
672
673
674 /* 
675   DRSUAPI_QUERY_SITES_BY_COST 
676 */
677 static WERROR DRSUAPI_QUERY_SITES_BY_COST(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
678                        struct DRSUAPI_QUERY_SITES_BY_COST *r)
679 {
680         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
681 }
682
683
684 /* include the generated boilerplate */
685 #include "librpc/gen_ndr/ndr_drsuapi_s.c"