7c821032ab3cac5cbacf7749e5d89e444160ec27
[nivanova/samba-autobuild/.git] / source4 / rpc_server / spoolss / dcesrv_spoolss.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    endpoint server for the spoolss pipe
5
6    Copyright (C) Tim Potter 2004
7    Copyright (C) Stefan Metzmacher 2005
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 "rpc_server/dcerpc_server.h"
26 #include "librpc/gen_ndr/ndr_spoolss.h"
27 #include "rpc_server/common/common.h"
28 #include "ntptr/ntptr.h"
29 #include "lib/socket/socket.h"
30 #include "smbd/service_stream.h"
31
32 #define SPOOLSS_BUFFER_UNION(fn,info,level) \
33         ((info)?ndr_size_##fn(info, level, 0):0)
34
35 #define SPOOLSS_BUFFER_UNION_ARRAY(fn,info,level,count) \
36         ((info)?ndr_size_##fn##_info(dce_call, level, count, info):0)
37
38 #define SPOOLSS_BUFFER_OK(val_true,val_false) ((r->in.offered >= r->out.needed)?val_true:val_false)
39
40 static WERROR spoolss_parse_printer_name(TALLOC_CTX *mem_ctx, const char *name,
41                                          const char **_server_name,
42                                          const char **_object_name,
43                                          enum ntptr_HandleType *_object_type)
44 {
45         char *p;
46         char *server = NULL;
47         char *server_unc = NULL;
48         const char *object = name;
49
50         /* no printername is there it's like open server */
51         if (!name) {
52                 *_server_name = NULL;
53                 *_object_name = NULL;
54                 *_object_type = NTPTR_HANDLE_SERVER;
55                 return WERR_OK;
56         }
57
58         /* just "\\" is invalid */
59         if (strequal("\\\\", name)) {
60                 return WERR_INVALID_PRINTER_NAME;
61         }
62
63         if (strncmp("\\\\", name, 2) == 0) {
64                 server_unc = talloc_strdup(mem_ctx, name);
65                 W_ERROR_HAVE_NO_MEMORY(server_unc);
66                 server = server_unc + 2;
67
68                 /* here we know we have "\\" in front not followed
69                  * by '\0', now see if we have another "\" in the string
70                  */
71                 p = strchr_m(server, '\\');
72                 if (!p) {
73                         /* there's no other "\", so it's ("\\%s",server)
74                          */
75                         *_server_name = server_unc;
76                         *_object_name = NULL;
77                         *_object_type = NTPTR_HANDLE_SERVER;
78                         return WERR_OK;
79                 }
80                 /* here we know that we have ("\\%s\",server),
81                  * if we have '\0' as next then it's an invalid name
82                  * otherwise the printer_name
83                  */
84                 p[0] = '\0';
85                 /* everything that follows is the printer name */
86                 p++;
87                 object = p;
88
89                 /* just "" as server is invalid */
90                 if (strequal(server, "")) {
91                         return WERR_INVALID_PRINTER_NAME;
92                 }
93         }
94
95         /* just "" is invalid */
96         if (strequal(object, "")) {
97                 return WERR_INVALID_PRINTER_NAME;
98         }
99
100 #define XCV_PORT ",XcvPort "
101 #define XCV_MONITOR ",XcvMonitor "
102         if (strncmp(object, XCV_PORT, strlen(XCV_PORT)) == 0) {
103                 object += strlen(XCV_PORT);
104
105                 /* just "" is invalid */
106                 if (strequal(object, "")) {
107                         return WERR_INVALID_PRINTER_NAME;
108                 }
109
110                 *_server_name = server_unc;
111                 *_object_name = object;
112                 *_object_type = NTPTR_HANDLE_PORT;
113                 return WERR_OK;
114         } else if (strncmp(object, XCV_MONITOR, strlen(XCV_MONITOR)) == 0) {
115                 object += strlen(XCV_MONITOR);
116
117                 /* just "" is invalid */
118                 if (strequal(object, "")) {
119                         return WERR_INVALID_PRINTER_NAME;
120                 }
121
122                 *_server_name = server_unc;
123                 *_object_name = object;
124                 *_object_type = NTPTR_HANDLE_MONITOR;
125                 return WERR_OK;
126         }
127
128         *_server_name = server_unc;
129         *_object_name = object;
130         *_object_type = NTPTR_HANDLE_PRINTER;
131         return WERR_OK;
132 }
133
134 /*
135  * Check server_name is:
136  * -  "" , functions that don't allow "",
137  *         should check that on their own, before calling this function
138  * -  our name (only netbios yet, TODO: need to test dns name!)
139  * -  our ip address of the current use socket
140  * otherwise return WERR_INVALID_PRINTER_NAME
141  */
142 static WERROR spoolss_check_server_name(struct dcesrv_call_state *dce_call, 
143                                         TALLOC_CTX *mem_ctx,
144                                         const char *server_name)
145 {
146         BOOL ret;
147         struct socket_address *myaddr;
148         const char **aliases;
149         int i;
150
151         /* NULL is ok */
152         if (!server_name) return WERR_OK;
153
154         /* "" is ok */
155         ret = strequal("",server_name);
156         if (ret) return WERR_OK;
157
158         /* just "\\" is invalid */
159         if (strequal("\\\\", server_name)) {
160                 return WERR_INVALID_PRINTER_NAME;
161         }
162
163         /* then we need "\\" */
164         if (strncmp("\\\\", server_name, 2) != 0) {
165                 return WERR_INVALID_PRINTER_NAME;
166         }
167
168         server_name += 2;
169
170         /* NETBIOS NAME is ok */
171         ret = strequal(lp_netbios_name(), server_name);
172         if (ret) return WERR_OK;
173
174         aliases = lp_netbios_aliases();
175
176         for (i=0; aliases && aliases[i]; i++) {
177                 if (strequal(aliases[i], server_name)) {
178                         return WERR_OK;
179                 }
180         }
181
182         /* DNS NAME is ok
183          * TODO: we need to check if aliases are also ok
184          */
185         if (lp_realm()) {
186                 char *str;
187
188                 str = talloc_asprintf(mem_ctx, "%s.%s",
189                                                 lp_netbios_name(),
190                                                 lp_realm());
191                 W_ERROR_HAVE_NO_MEMORY(str);
192
193                 ret = strequal(str, server_name);
194                 talloc_free(str);
195                 if (ret) return WERR_OK;
196         }
197
198         myaddr = dcesrv_connection_get_my_addr(dce_call->conn, mem_ctx);
199         W_ERROR_HAVE_NO_MEMORY(myaddr);
200
201         ret = strequal(myaddr->addr, server_name);
202         talloc_free(myaddr);
203         if (ret) return WERR_OK;
204
205         return WERR_INVALID_PRINTER_NAME;
206 }
207
208 static NTSTATUS dcerpc_spoolss_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface)
209 {
210         NTSTATUS status;
211         struct ntptr_context *ntptr;
212
213         status = ntptr_init_context(dce_call->context, lp_ntptr_providor(), &ntptr);
214         NT_STATUS_NOT_OK_RETURN(status);
215
216         dce_call->context->private = ntptr;
217
218         return NT_STATUS_OK;
219 }
220
221 #define DCESRV_INTERFACE_SPOOLSS_BIND dcerpc_spoolss_bind
222
223 /* 
224   spoolss_EnumPrinters 
225 */
226 static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
227                        struct spoolss_EnumPrinters *r)
228 {
229         struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private, struct ntptr_context);
230         WERROR status;
231
232         status = spoolss_check_server_name(dce_call, mem_ctx, r->in.server);
233         W_ERROR_NOT_OK_RETURN(status);
234
235         status = ntptr_EnumPrinters(ntptr, mem_ctx, r);
236         W_ERROR_NOT_OK_RETURN(status);
237
238         r->out.needed   = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumPrinters, r->out.info, r->in.level, r->out.count);
239         r->out.info     = SPOOLSS_BUFFER_OK(r->out.info, NULL);
240         r->out.count    = SPOOLSS_BUFFER_OK(r->out.count, 0);
241         return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
242 }
243
244 static WERROR spoolss_OpenPrinterEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
245                        struct spoolss_OpenPrinterEx *r);
246 /* 
247   spoolss_OpenPrinter 
248 */
249 static WERROR spoolss_OpenPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
250                        struct spoolss_OpenPrinter *r)
251 {
252         WERROR status;
253         struct spoolss_OpenPrinterEx *r2;
254
255         r2 = talloc(mem_ctx, struct spoolss_OpenPrinterEx);
256         W_ERROR_HAVE_NO_MEMORY(r2);
257
258         r2->in.printername      = r->in.printername;
259         r2->in.datatype         = r->in.datatype;
260         r2->in.devmode_ctr      = r->in.devmode_ctr;
261         r2->in.access_mask      = r->in.access_mask;
262         r2->in.level            = 1;
263         r2->in.userlevel.level1 = NULL;
264
265         r2->out.handle          = r->out.handle;
266
267         /* TODO: we should take care about async replies here,
268                  if spoolss_OpenPrinterEx() would be async!
269          */
270         status = spoolss_OpenPrinterEx(dce_call, mem_ctx, r2);
271
272         r->out.handle           = r2->out.handle;
273
274         return status;
275 }
276
277
278 /* 
279   spoolss_SetJob 
280 */
281 static WERROR spoolss_SetJob(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
282                        struct spoolss_SetJob *r)
283 {
284         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
285 }
286
287
288 /* 
289   spoolss_GetJob 
290 */
291 static WERROR spoolss_GetJob(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
292                        struct spoolss_GetJob *r)
293 {
294         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
295 }
296
297
298 /* 
299   spoolss_EnumJobs 
300 */
301 static WERROR spoolss_EnumJobs(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
302                        struct spoolss_EnumJobs *r)
303 {
304         return WERR_OK;
305 }
306
307
308 /* 
309   spoolss_AddPrinter 
310 */
311 static WERROR spoolss_AddPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
312                        struct spoolss_AddPrinter *r)
313 {
314         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
315 }
316
317
318 /* 
319   spoolss_DeletePrinter 
320 */
321 static WERROR spoolss_DeletePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
322                        struct spoolss_DeletePrinter *r)
323 {
324         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
325 }
326
327
328 /* 
329   spoolss_SetPrinter 
330 */
331 static WERROR spoolss_SetPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
332                        struct spoolss_SetPrinter *r)
333 {
334         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
335 }
336
337
338 /* 
339   spoolss_GetPrinter 
340 */
341 static WERROR spoolss_GetPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
342                        struct spoolss_GetPrinter *r)
343 {
344         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
345 }
346
347
348 /* 
349   spoolss_AddPrinterDriver 
350 */
351 static WERROR spoolss_AddPrinterDriver(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
352                        struct spoolss_AddPrinterDriver *r)
353 {
354         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
355 }
356
357
358 /* 
359   spoolss_EnumPrinterDrivers 
360 */
361 static WERROR spoolss_EnumPrinterDrivers(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
362                        struct spoolss_EnumPrinterDrivers *r)
363 {
364         struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private, struct ntptr_context);
365         WERROR status;
366
367         status = spoolss_check_server_name(dce_call, mem_ctx, r->in.server);
368         W_ERROR_NOT_OK_RETURN(status);
369
370         status = ntptr_EnumPrinterDrivers(ntptr, mem_ctx, r);
371         W_ERROR_NOT_OK_RETURN(status);
372
373         r->out.needed   = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumPrinterDrivers, r->out.info, r->in.level, r->out.count);
374         r->out.info     = SPOOLSS_BUFFER_OK(r->out.info, NULL);
375         r->out.count    = SPOOLSS_BUFFER_OK(r->out.count, 0);
376         return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
377 }
378
379
380 /* 
381   spoolss_GetPrinterDriver 
382 */
383 static WERROR spoolss_GetPrinterDriver(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
384                        struct spoolss_GetPrinterDriver *r)
385 {
386         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
387 }
388
389
390 /* 
391   spoolss_GetPrinterDriverDirectory 
392 */
393 static WERROR spoolss_GetPrinterDriverDirectory(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
394                        struct spoolss_GetPrinterDriverDirectory *r)
395 {
396         struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private, struct ntptr_context);
397         WERROR status;
398
399         status = spoolss_check_server_name(dce_call, mem_ctx, r->in.server);
400         W_ERROR_NOT_OK_RETURN(status);
401
402         status = ntptr_GetPrinterDriverDirectory(ntptr, mem_ctx, r);
403         W_ERROR_NOT_OK_RETURN(status);
404
405         r->out.needed   = SPOOLSS_BUFFER_UNION(spoolss_DriverDirectoryInfo, r->out.info, r->in.level);
406         r->out.info     = SPOOLSS_BUFFER_OK(r->out.info, NULL);
407         return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
408 }
409
410
411 /* 
412   spoolss_DeletePrinterDriver 
413 */
414 static WERROR spoolss_DeletePrinterDriver(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
415                        struct spoolss_DeletePrinterDriver *r)
416 {
417         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
418 }
419
420
421 /* 
422   spoolss_AddPrintProcessor 
423 */
424 static WERROR spoolss_AddPrintProcessor(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
425                        struct spoolss_AddPrintProcessor *r)
426 {
427         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
428 }
429
430
431 /* 
432   spoolss_EnumPrintProcessors 
433 */
434 static WERROR spoolss_EnumPrintProcessors(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
435                        struct spoolss_EnumPrintProcessors *r)
436 {
437         return WERR_OK;
438 }
439
440
441 /* 
442   spoolss_GetPrintProcessorDirectory 
443 */
444 static WERROR spoolss_GetPrintProcessorDirectory(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
445                        struct spoolss_GetPrintProcessorDirectory *r)
446 {
447         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
448 }
449
450
451 /* 
452   spoolss_StartDocPrinter 
453 */
454 static WERROR spoolss_StartDocPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
455                        struct spoolss_StartDocPrinter *r)
456 {
457         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
458 }
459
460
461 /* 
462   spoolss_StartPagePrinter 
463 */
464 static WERROR spoolss_StartPagePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
465                        struct spoolss_StartPagePrinter *r)
466 {
467         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
468 }
469
470
471 /* 
472   spoolss_WritePrinter 
473 */
474 static WERROR spoolss_WritePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
475                        struct spoolss_WritePrinter *r)
476 {
477         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
478 }
479
480
481 /* 
482   spoolss_EndPagePrinter 
483 */
484 static WERROR spoolss_EndPagePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
485                        struct spoolss_EndPagePrinter *r)
486 {
487         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
488 }
489
490
491 /* 
492   spoolss_AbortPrinter 
493 */
494 static WERROR spoolss_AbortPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
495                        struct spoolss_AbortPrinter *r)
496 {
497         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
498 }
499
500
501 /* 
502   spoolss_ReadPrinter 
503 */
504 static WERROR spoolss_ReadPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
505                        struct spoolss_ReadPrinter *r)
506 {
507         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
508 }
509
510
511 /* 
512   spoolss_EndDocPrinter 
513 */
514 static WERROR spoolss_EndDocPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
515                        struct spoolss_EndDocPrinter *r)
516 {
517         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
518 }
519
520
521 /* 
522   spoolss_AddJob 
523 */
524 static WERROR spoolss_AddJob(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
525                        struct spoolss_AddJob *r)
526 {
527         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
528 }
529
530
531 /* 
532   spoolss_ScheduleJob 
533 */
534 static WERROR spoolss_ScheduleJob(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
535                        struct spoolss_ScheduleJob *r)
536 {
537         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
538 }
539
540
541 /* 
542   spoolss_GetPrinterData 
543 */
544 static WERROR spoolss_GetPrinterData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
545                        struct spoolss_GetPrinterData *r)
546 {
547         struct ntptr_GenericHandle *handle;
548         struct dcesrv_handle *h;
549         WERROR status;
550
551         DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY);
552         handle = talloc_get_type(h->data, struct ntptr_GenericHandle);
553         if (!handle)
554                 return WERR_BADFID;
555
556         switch (handle->type) {
557                 case NTPTR_HANDLE_SERVER:
558                         status = ntptr_GetPrintServerData(handle, mem_ctx, r);
559                         break;
560                 default:
561                         status = WERR_FOOBAR;
562                         break;
563         }
564
565         W_ERROR_NOT_OK_RETURN(status);
566
567         r->out.needed   = ndr_size_spoolss_PrinterData(&r->out.data, r->out.type, 0);
568         r->out.type     = SPOOLSS_BUFFER_OK(r->out.type, SPOOLSS_PRINTER_DATA_TYPE_NULL);
569         r->out.data     = SPOOLSS_BUFFER_OK(r->out.data, r->out.data);
570         return SPOOLSS_BUFFER_OK(WERR_OK, WERR_MORE_DATA);
571 }
572
573
574 /* 
575   spoolss_SetPrinterData 
576 */
577 static WERROR spoolss_SetPrinterData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
578                        struct spoolss_SetPrinterData *r)
579 {
580         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
581 }
582
583
584 /* 
585   spoolss_WaitForPrinterChange 
586 */
587 static WERROR spoolss_WaitForPrinterChange(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
588                        struct spoolss_WaitForPrinterChange *r)
589 {
590         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
591 }
592
593
594 /* 
595   spoolss_ClosePrinter 
596 */
597 static WERROR spoolss_ClosePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
598                        struct spoolss_ClosePrinter *r)
599 {
600         struct dcesrv_handle *h;
601
602         *r->out.handle = *r->in.handle;
603
604         DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY);
605
606         talloc_free(h);
607
608         ZERO_STRUCTP(r->out.handle);
609
610         return WERR_OK;
611 }
612
613
614 /* 
615   spoolss_AddForm 
616 */
617 static WERROR spoolss_AddForm(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
618                        struct spoolss_AddForm *r)
619 {
620         struct ntptr_GenericHandle *handle;
621         struct dcesrv_handle *h;
622         WERROR status;
623
624         DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY);
625         handle = talloc_get_type(h->data, struct ntptr_GenericHandle);
626         if (!handle)
627                 return WERR_BADFID;
628
629         switch (handle->type) {
630                 case NTPTR_HANDLE_SERVER:
631                         status = ntptr_AddPrintServerForm(handle, mem_ctx, r);
632                         W_ERROR_NOT_OK_RETURN(status);
633                         break;
634                 case NTPTR_HANDLE_PRINTER:
635                         status = ntptr_AddPrinterForm(handle, mem_ctx, r);
636                         W_ERROR_NOT_OK_RETURN(status);
637                         break;
638                 default:
639                         return WERR_FOOBAR;
640         }
641
642         return WERR_OK;
643 }
644
645
646 /* 
647   spoolss_DeleteForm 
648 */
649 static WERROR spoolss_DeleteForm(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
650                        struct spoolss_DeleteForm *r)
651 {
652         struct ntptr_GenericHandle *handle;
653         struct dcesrv_handle *h;
654         WERROR status;
655
656         DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY);
657         handle = talloc_get_type(h->data, struct ntptr_GenericHandle);
658         if (!handle)
659                 return WERR_BADFID;
660
661         switch (handle->type) {
662                 case NTPTR_HANDLE_SERVER:
663                         status = ntptr_DeletePrintServerForm(handle, mem_ctx, r);
664                         W_ERROR_NOT_OK_RETURN(status);
665                         break;
666                 case NTPTR_HANDLE_PRINTER:
667                         status = ntptr_DeletePrinterForm(handle, mem_ctx, r);
668                         W_ERROR_NOT_OK_RETURN(status);
669                         break;
670                 default:
671                         return WERR_FOOBAR;
672         }
673
674         return WERR_OK;
675 }
676
677
678 /* 
679   spoolss_GetForm 
680 */
681 static WERROR spoolss_GetForm(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
682                        struct spoolss_GetForm *r)
683 {
684         struct ntptr_GenericHandle *handle;
685         struct dcesrv_handle *h;
686         WERROR status;
687
688         DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY);
689         handle = talloc_get_type(h->data, struct ntptr_GenericHandle);
690         if (!handle)
691                 return WERR_BADFID;
692
693         switch (handle->type) {
694                 case NTPTR_HANDLE_SERVER:
695                         /*
696                          * stupid, but w2k3 returns WERR_BADFID here?
697                          */
698                         return WERR_BADFID;
699                 case NTPTR_HANDLE_PRINTER:
700                         status = ntptr_GetPrinterForm(handle, mem_ctx, r);
701                         W_ERROR_NOT_OK_RETURN(status);
702                         break;
703                 default:
704                         return WERR_FOOBAR;
705         }
706
707         r->out.needed   = SPOOLSS_BUFFER_UNION(spoolss_FormInfo, r->out.info, r->in.level);
708         r->out.info     = SPOOLSS_BUFFER_OK(r->out.info, NULL);
709         return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
710 }
711
712
713 /* 
714   spoolss_SetForm 
715 */
716 static WERROR spoolss_SetForm(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
717                        struct spoolss_SetForm *r)
718 {
719         struct ntptr_GenericHandle *handle;
720         struct dcesrv_handle *h;
721         WERROR status;
722
723         DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY);
724         handle = talloc_get_type(h->data, struct ntptr_GenericHandle);
725         if (!handle)
726                 return WERR_BADFID;
727
728         switch (handle->type) {
729                 case NTPTR_HANDLE_SERVER:
730                         status = ntptr_SetPrintServerForm(handle, mem_ctx, r);
731                         W_ERROR_NOT_OK_RETURN(status);
732                         break;
733                 case NTPTR_HANDLE_PRINTER:
734                         status = ntptr_SetPrinterForm(handle, mem_ctx, r);
735                         W_ERROR_NOT_OK_RETURN(status);
736                         break;
737                 default:
738                         return WERR_FOOBAR;
739         }
740
741         return WERR_OK;
742 }
743
744
745 /* 
746   spoolss_EnumForms 
747 */
748 static WERROR spoolss_EnumForms(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
749                        struct spoolss_EnumForms *r)
750 {
751         struct ntptr_GenericHandle *handle;
752         struct dcesrv_handle *h;
753         WERROR status;
754
755         DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY);
756         handle = talloc_get_type(h->data, struct ntptr_GenericHandle);
757         if (!handle)
758                 return WERR_BADFID;
759
760         switch (handle->type) {
761                 case NTPTR_HANDLE_SERVER:
762                         status = ntptr_EnumPrintServerForms(handle, mem_ctx, r);
763                         W_ERROR_NOT_OK_RETURN(status);
764                         break;
765                 case NTPTR_HANDLE_PRINTER:
766                         status = ntptr_EnumPrinterForms(handle, mem_ctx, r);
767                         W_ERROR_NOT_OK_RETURN(status);
768                         break;
769                 default:
770                         return WERR_FOOBAR;
771         }
772
773         r->out.needed   = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumForms, r->out.info, r->in.level, r->out.count);
774         r->out.info     = SPOOLSS_BUFFER_OK(r->out.info, NULL);
775         r->out.count    = SPOOLSS_BUFFER_OK(r->out.count, 0);
776         return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
777 }
778
779
780 /* 
781   spoolss_EnumPorts 
782 */
783 static WERROR spoolss_EnumPorts(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
784                        struct spoolss_EnumPorts *r)
785 {
786         struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private, struct ntptr_context);
787         WERROR status;
788
789         status = spoolss_check_server_name(dce_call, mem_ctx, r->in.servername);
790         W_ERROR_NOT_OK_RETURN(status);
791
792         status = ntptr_EnumPorts(ntptr, mem_ctx, r);
793         W_ERROR_NOT_OK_RETURN(status);
794
795         r->out.needed   = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumPorts, r->out.info, r->in.level, r->out.count);
796         r->out.info     = SPOOLSS_BUFFER_OK(r->out.info, NULL);
797         r->out.count    = SPOOLSS_BUFFER_OK(r->out.count, 0);
798         return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
799 }
800
801
802 /* 
803   spoolss_EnumMonitors 
804 */
805 static WERROR spoolss_EnumMonitors(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
806                        struct spoolss_EnumMonitors *r)
807 {
808         struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private, struct ntptr_context);
809         WERROR status;
810
811         status = spoolss_check_server_name(dce_call, mem_ctx, r->in.servername);
812         W_ERROR_NOT_OK_RETURN(status);
813
814         status = ntptr_EnumMonitors(ntptr, mem_ctx, r);
815         W_ERROR_NOT_OK_RETURN(status);
816
817         r->out.needed   = SPOOLSS_BUFFER_UNION_ARRAY(spoolss_EnumMonitors, r->out.info, r->in.level, r->out.count);
818         r->out.info     = SPOOLSS_BUFFER_OK(r->out.info, NULL);
819         r->out.count    = SPOOLSS_BUFFER_OK(r->out.count, 0);
820         return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
821 }
822
823
824 /* 
825   spoolss_AddPort 
826 */
827 static WERROR spoolss_AddPort(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
828                        struct spoolss_AddPort *r)
829 {
830         return WERR_NOT_SUPPORTED;
831 }
832
833
834 /* 
835   spoolss_ConfigurePort 
836 */
837 static WERROR spoolss_ConfigurePort(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
838                        struct spoolss_ConfigurePort *r)
839 {
840         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
841 }
842
843
844 /* 
845   spoolss_DeletePort 
846 */
847 static WERROR spoolss_DeletePort(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
848                        struct spoolss_DeletePort *r)
849 {
850         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
851 }
852
853
854 /* 
855   spoolss_CreatePrinterIC 
856 */
857 static WERROR spoolss_CreatePrinterIC(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
858                        struct spoolss_CreatePrinterIC *r)
859 {
860         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
861 }
862
863
864 /* 
865   spoolss_PlayGDIScriptOnPrinterIC 
866 */
867 static WERROR spoolss_PlayGDIScriptOnPrinterIC(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
868                        struct spoolss_PlayGDIScriptOnPrinterIC *r)
869 {
870         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
871 }
872
873
874 /* 
875   spoolss_DeletePrinterIC 
876 */
877 static WERROR spoolss_DeletePrinterIC(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
878                        struct spoolss_DeletePrinterIC *r)
879 {
880         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
881 }
882
883
884 /* 
885   spoolss_AddPrinterConnection 
886 */
887 static WERROR spoolss_AddPrinterConnection(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
888                        struct spoolss_AddPrinterConnection *r)
889 {
890         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
891 }
892
893
894 /* 
895   spoolss_DeletePrinterConnection 
896 */
897 static WERROR spoolss_DeletePrinterConnection(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
898                        struct spoolss_DeletePrinterConnection *r)
899 {
900         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
901 }
902
903
904 /* 
905   spoolss_PrinterMessageBox 
906 */
907 static WERROR spoolss_PrinterMessageBox(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
908                        struct spoolss_PrinterMessageBox *r)
909 {
910         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
911 }
912
913
914 /* 
915   spoolss_AddMonitor 
916 */
917 static WERROR spoolss_AddMonitor(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
918                        struct spoolss_AddMonitor *r)
919 {
920         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
921 }
922
923
924 /* 
925   spoolss_DeleteMonitor 
926 */
927 static WERROR spoolss_DeleteMonitor(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
928                        struct spoolss_DeleteMonitor *r)
929 {
930         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
931 }
932
933
934 /* 
935   spoolss_DeletePrintProcessor 
936 */
937 static WERROR spoolss_DeletePrintProcessor(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
938                        struct spoolss_DeletePrintProcessor *r)
939 {
940         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
941 }
942
943
944 /* 
945   spoolss_AddPrintProvidor 
946 */
947 static WERROR spoolss_AddPrintProvidor(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
948                        struct spoolss_AddPrintProvidor *r)
949 {
950         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
951 }
952
953
954 /* 
955   spoolss_DeletePrintProvidor 
956 */
957 static WERROR spoolss_DeletePrintProvidor(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
958                        struct spoolss_DeletePrintProvidor *r)
959 {
960         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
961 }
962
963
964 /* 
965   spoolss_EnumPrintProcDataTypes 
966 */
967 static WERROR spoolss_EnumPrintProcDataTypes(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
968                        struct spoolss_EnumPrintProcDataTypes *r)
969 {
970         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
971 }
972
973
974 /* 
975   spoolss_ResetPrinter 
976 */
977 static WERROR spoolss_ResetPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
978                        struct spoolss_ResetPrinter *r)
979 {
980         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
981 }
982
983
984 /* 
985   spoolss_GetPrinterDriver2 
986 */
987 static WERROR spoolss_GetPrinterDriver2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
988                        struct spoolss_GetPrinterDriver2 *r)
989 {
990         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
991 }
992
993
994 /* 
995   spoolss_FindFirstPrinterChangeNotification 
996 */
997 static WERROR spoolss_FindFirstPrinterChangeNotification(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
998                        struct spoolss_FindFirstPrinterChangeNotification *r)
999 {
1000         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1001 }
1002
1003
1004 /* 
1005   spoolss_FindNextPrinterChangeNotification 
1006 */
1007 static WERROR spoolss_FindNextPrinterChangeNotification(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1008                        struct spoolss_FindNextPrinterChangeNotification *r)
1009 {
1010         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1011 }
1012
1013
1014 /* 
1015   spoolss_FindClosePrinterNotify 
1016 */
1017 static WERROR spoolss_FindClosePrinterNotify(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1018                        struct spoolss_FindClosePrinterNotify *r)
1019 {
1020         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1021 }
1022
1023
1024 /* 
1025   spoolss_RouterFindFirstPrinterChangeNotificationOld 
1026 */
1027 static WERROR spoolss_RouterFindFirstPrinterChangeNotificationOld(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1028                        struct spoolss_RouterFindFirstPrinterChangeNotificationOld *r)
1029 {
1030         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1031 }
1032
1033
1034 /* 
1035   spoolss_ReplyOpenPrinter 
1036 */
1037 static WERROR spoolss_ReplyOpenPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1038                        struct spoolss_ReplyOpenPrinter *r)
1039 {
1040         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1041 }
1042
1043
1044 /* 
1045   spoolss_RouterReplyPrinter 
1046 */
1047 static WERROR spoolss_RouterReplyPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1048                        struct spoolss_RouterReplyPrinter *r)
1049 {
1050         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1051 }
1052
1053
1054 /* 
1055   spoolss_ReplyClosePrinter 
1056 */
1057 static WERROR spoolss_ReplyClosePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1058                        struct spoolss_ReplyClosePrinter *r)
1059 {
1060         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1061 }
1062
1063
1064 /* 
1065   spoolss_AddPortEx 
1066 */
1067 static WERROR spoolss_AddPortEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1068                        struct spoolss_AddPortEx *r)
1069 {
1070         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1071 }
1072
1073
1074 /* 
1075   spoolss_RouterFindFirstPrinterChangeNotification 
1076 */
1077 static WERROR spoolss_RouterFindFirstPrinterChangeNotification(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1078                        struct spoolss_RouterFindFirstPrinterChangeNotification *r)
1079 {
1080         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1081 }
1082
1083
1084 /* 
1085   spoolss_SpoolerInit 
1086 */
1087 static WERROR spoolss_SpoolerInit(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1088                        struct spoolss_SpoolerInit *r)
1089 {
1090         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1091 }
1092
1093
1094 /* 
1095   spoolss_ResetPrinterEx 
1096 */
1097 static WERROR spoolss_ResetPrinterEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1098                        struct spoolss_ResetPrinterEx *r)
1099 {
1100         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1101 }
1102
1103
1104 /* 
1105   spoolss_RemoteFindFirstPrinterChangeNotifyEx 
1106 */
1107 static WERROR spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1108                        struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r)
1109 {
1110         /*
1111          * TODO: for now just return ok,
1112          *       to keep the w2k3 PrintServer 
1113          *       happy to allow to open the Add Printer GUI
1114          */
1115         return WERR_OK;
1116 }
1117
1118
1119 /* 
1120   spoolss_RouterRefreshPrinterChangeNotification 
1121 */
1122 static WERROR spoolss_RouterRefreshPrinterChangeNotification(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1123                        struct spoolss_RouterRefreshPrinterChangeNotification *r)
1124 {
1125         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1126 }
1127
1128
1129 /* 
1130   spoolss_RemoteFindNextPrinterChangeNotifyEx 
1131 */
1132 static WERROR spoolss_RemoteFindNextPrinterChangeNotifyEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1133                        struct spoolss_RemoteFindNextPrinterChangeNotifyEx *r)
1134 {
1135         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1136 }
1137
1138
1139 /* 
1140   spoolss_44 
1141 */
1142 static WERROR spoolss_44(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1143                        struct spoolss_44 *r)
1144 {
1145         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1146 }
1147
1148 /* 
1149   spoolss_OpenPrinterEx 
1150 */
1151 static WERROR spoolss_OpenPrinterEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1152                        struct spoolss_OpenPrinterEx *r)
1153 {
1154         struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private, struct ntptr_context);
1155         struct ntptr_GenericHandle *handle;
1156         struct dcesrv_handle *h;
1157         const char *server;
1158         const char *object;
1159         enum ntptr_HandleType type;
1160         WERROR status;
1161
1162         ZERO_STRUCTP(r->out.handle);
1163
1164         status = spoolss_parse_printer_name(mem_ctx, r->in.printername, &server, &object, &type);
1165         W_ERROR_NOT_OK_RETURN(status);
1166
1167         status = spoolss_check_server_name(dce_call, mem_ctx, server);
1168         W_ERROR_NOT_OK_RETURN(status);
1169
1170         switch (type) {
1171                 case NTPTR_HANDLE_SERVER:
1172                         status = ntptr_OpenPrintServer(ntptr, mem_ctx, r, server, &handle);
1173                         W_ERROR_NOT_OK_RETURN(status);
1174                         break;
1175                 case NTPTR_HANDLE_PORT:
1176                         status = ntptr_OpenPort(ntptr, mem_ctx, r, object, &handle);
1177                         W_ERROR_NOT_OK_RETURN(status);
1178                         break;
1179                 case NTPTR_HANDLE_MONITOR:
1180                         status = ntptr_OpenMonitor(ntptr, mem_ctx, r, object, &handle);
1181                         W_ERROR_NOT_OK_RETURN(status);
1182                         break;
1183                 case NTPTR_HANDLE_PRINTER:
1184                         status = ntptr_OpenPrinter(ntptr, mem_ctx, r, object, &handle);
1185                         W_ERROR_NOT_OK_RETURN(status);
1186                         break;
1187                 default:
1188                         return WERR_FOOBAR;
1189         }
1190
1191         h = dcesrv_handle_new(dce_call->context, handle->type);
1192         W_ERROR_HAVE_NO_MEMORY(h);
1193
1194         h->data = talloc_steal(h, handle);
1195
1196         *r->out.handle  = h->wire_handle;
1197
1198         return WERR_OK;
1199 }
1200
1201 /* 
1202   spoolss_AddPrinterEx 
1203 */
1204 static WERROR spoolss_AddPrinterEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1205                        struct spoolss_AddPrinterEx *r)
1206 {
1207         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1208 }
1209
1210
1211 /* 
1212   spoolss_47 
1213 */
1214 static WERROR spoolss_47(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1215                        struct spoolss_47 *r)
1216 {
1217         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1218 }
1219
1220
1221 /* 
1222   spoolss_EnumPrinterData 
1223 */
1224 static WERROR spoolss_EnumPrinterData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1225                        struct spoolss_EnumPrinterData *r)
1226 {
1227         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1228 }
1229
1230
1231 /* 
1232   spoolss_DeletePrinterData 
1233 */
1234 static WERROR spoolss_DeletePrinterData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1235                        struct spoolss_DeletePrinterData *r)
1236 {
1237         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1238 }
1239
1240
1241 /* 
1242   spoolss_4a 
1243 */
1244 static WERROR spoolss_4a(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1245                        struct spoolss_4a *r)
1246 {
1247         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1248 }
1249
1250
1251 /* 
1252   spoolss_4b 
1253 */
1254 static WERROR spoolss_4b(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1255                        struct spoolss_4b *r)
1256 {
1257         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1258 }
1259
1260
1261 /* 
1262   spoolss_4c 
1263 */
1264 static WERROR spoolss_4c(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1265                        struct spoolss_4c *r)
1266 {
1267         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1268 }
1269
1270
1271 /* 
1272   spoolss_SetPrinterDataEx 
1273 */
1274 static WERROR spoolss_SetPrinterDataEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1275                        struct spoolss_SetPrinterDataEx *r)
1276 {
1277         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1278 }
1279
1280
1281 /* 
1282   spoolss_GetPrinterDataEx 
1283 */
1284 static WERROR spoolss_GetPrinterDataEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1285                        struct spoolss_GetPrinterDataEx *r)
1286 {
1287         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1288 }
1289
1290
1291 /* 
1292   spoolss_EnumPrinterDataEx 
1293 */
1294 static WERROR spoolss_EnumPrinterDataEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1295                        struct spoolss_EnumPrinterDataEx *r)
1296 {
1297         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1298 }
1299
1300
1301 /* 
1302   spoolss_EnumPrinterKey 
1303 */
1304 static WERROR spoolss_EnumPrinterKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1305                        struct spoolss_EnumPrinterKey *r)
1306 {
1307         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1308 }
1309
1310
1311 /* 
1312   spoolss_DeletePrinterDataEx 
1313 */
1314 static WERROR spoolss_DeletePrinterDataEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1315                        struct spoolss_DeletePrinterDataEx *r)
1316 {
1317         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1318 }
1319
1320
1321 /* 
1322   spoolss_DeletePrinterKey 
1323 */
1324 static WERROR spoolss_DeletePrinterKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1325                        struct spoolss_DeletePrinterKey *r)
1326 {
1327         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1328 }
1329
1330
1331 /* 
1332   spoolss_53 
1333 */
1334 static WERROR spoolss_53(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1335                        struct spoolss_53 *r)
1336 {
1337         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1338 }
1339
1340
1341 /* 
1342   spoolss_DeletePrinterDriverEx 
1343 */
1344 static WERROR spoolss_DeletePrinterDriverEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1345                        struct spoolss_DeletePrinterDriverEx *r)
1346 {
1347         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1348 }
1349
1350
1351 /* 
1352   spoolss_55 
1353 */
1354 static WERROR spoolss_55(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1355                        struct spoolss_55 *r)
1356 {
1357         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1358 }
1359
1360
1361 /* 
1362   spoolss_56 
1363 */
1364 static WERROR spoolss_56(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1365                        struct spoolss_56 *r)
1366 {
1367         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1368 }
1369
1370
1371 /* 
1372   spoolss_57 
1373 */
1374 static WERROR spoolss_57(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1375                        struct spoolss_57 *r)
1376 {
1377         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1378 }
1379
1380
1381 /* 
1382   spoolss_XcvData
1383 */
1384 static WERROR spoolss_XcvData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1385                        struct spoolss_XcvData *r)
1386 {
1387         struct ntptr_GenericHandle *handle;
1388         struct dcesrv_handle *h;
1389         WERROR status;
1390
1391         DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY);
1392         handle = talloc_get_type(h->data, struct ntptr_GenericHandle);
1393
1394         switch (handle->type) {
1395                 case NTPTR_HANDLE_SERVER:
1396                         status = ntptr_XcvDataPrintServer(handle, mem_ctx, r);
1397                         W_ERROR_NOT_OK_RETURN(status);
1398                         break;
1399                 case NTPTR_HANDLE_PRINTER:
1400                         status = ntptr_XcvDataPrinter(handle, mem_ctx, r);
1401                         W_ERROR_NOT_OK_RETURN(status);
1402                         break;
1403                 case NTPTR_HANDLE_PORT:
1404                         status = ntptr_XcvDataPort(handle, mem_ctx, r);
1405                         W_ERROR_NOT_OK_RETURN(status);
1406                         break;
1407                 case NTPTR_HANDLE_MONITOR:
1408                         status = ntptr_XcvDataMonitor(handle, mem_ctx, r);
1409                         W_ERROR_NOT_OK_RETURN(status);
1410                         break;
1411                 default:
1412                         return WERR_FOOBAR;
1413         }
1414
1415         /* TODO: handle the buffer sizes here! */
1416         return WERR_OK;
1417 }
1418
1419
1420 /* 
1421   spoolss_AddPrinterDriverEx 
1422 */
1423 static WERROR spoolss_AddPrinterDriverEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1424                        struct spoolss_AddPrinterDriverEx *r)
1425 {
1426         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1427 }
1428
1429
1430 /* 
1431   spoolss_5a 
1432 */
1433 static WERROR spoolss_5a(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1434                        struct spoolss_5a *r)
1435 {
1436         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1437 }
1438
1439
1440 /* 
1441   spoolss_5b 
1442 */
1443 static WERROR spoolss_5b(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1444                        struct spoolss_5b *r)
1445 {
1446         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1447 }
1448
1449
1450 /* 
1451   spoolss_5c 
1452 */
1453 static WERROR spoolss_5c(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1454                        struct spoolss_5c *r)
1455 {
1456         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1457 }
1458
1459
1460 /* 
1461   spoolss_5d 
1462 */
1463 static WERROR spoolss_5d(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1464                        struct spoolss_5d *r)
1465 {
1466         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1467 }
1468
1469
1470 /* 
1471   spoolss_5e 
1472 */
1473 static WERROR spoolss_5e(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1474                        struct spoolss_5e *r)
1475 {
1476         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1477 }
1478
1479
1480 /* 
1481   spoolss_5f 
1482 */
1483 static WERROR spoolss_5f(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1484                        struct spoolss_5f *r)
1485 {
1486         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1487 }
1488
1489
1490 /* include the generated boilerplate */
1491 #include "librpc/gen_ndr/ndr_spoolss_s.c"