470c9e2674d1fb57366876ef0fda5163d48d186d
[samba.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    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "includes.h"
24 #include "rpc_server/dcerpc_server.h"
25 #include "librpc/gen_ndr/ndr_spoolss.h"
26 #include "rpc_server/common/common.h"
27 #include "rpc_server/spoolss/dcesrv_spoolss.h"
28
29 /* 
30   spoolss_EnumPrinters 
31 */
32 static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
33                        struct spoolss_EnumPrinters *r)
34 {
35         void *spoolss_ctx;
36         struct ldb_message **msgs;
37         int count;
38         int i;
39         union spoolss_PrinterInfo *info;
40
41         r->out.info = NULL;
42         *r->out.buf_size = 0;
43         r->out.count = 0;
44
45         spoolss_ctx = spoolssdb_connect();
46         W_ERROR_HAVE_NO_MEMORY(spoolss_ctx);
47
48         count = spoolssdb_search(spoolss_ctx, mem_ctx, NULL, &msgs, NULL,
49                                "(&(objectclass=printer))");
50         spoolssdb_close(spoolss_ctx);
51
52         if (count == 0) return WERR_OK;
53         if (count < 0) return WERR_GENERAL_FAILURE;
54
55         info = talloc_array(mem_ctx, union spoolss_PrinterInfo, count);
56         W_ERROR_HAVE_NO_MEMORY(info);
57
58         switch(r->in.level) {
59         case 1:
60                 for (i = 0; i < count; i++) {
61                         info[i].info1.flags             = samdb_result_uint(msgs[i], "flags", 0);
62
63                         info[i].info1.name              = samdb_result_string(msgs[i], "name", "");
64                         W_ERROR_HAVE_NO_MEMORY(info[i].info1.name);
65
66                         info[i].info1.description       = samdb_result_string(msgs[i], "description", "");
67                         W_ERROR_HAVE_NO_MEMORY(info[i].info1.description);
68
69                         info[i].info1.comment           = samdb_result_string(msgs[i], "comment", NULL);
70                 }
71                 return WERR_OK;
72         case 2:
73                 for (i = 0; i < count; i++) {
74                         info[i].info2.servername        = samdb_result_string(msgs[i], "servername", "");
75                         W_ERROR_HAVE_NO_MEMORY(info[i].info2.servername);
76
77                         info[i].info2.printername       = samdb_result_string(msgs[i], "printername", "");
78                         W_ERROR_HAVE_NO_MEMORY(info[i].info2.printername);
79
80                         info[i].info2.sharename         = samdb_result_string(msgs[i], "sharename", "");
81                         W_ERROR_HAVE_NO_MEMORY(info[i].info2.sharename);
82
83                         info[i].info2.portname          = samdb_result_string(msgs[i], "portname", "");
84                         W_ERROR_HAVE_NO_MEMORY(info[i].info2.portname);
85
86                         info[i].info2.drivername        = samdb_result_string(msgs[i], "drivername", "");
87                         W_ERROR_HAVE_NO_MEMORY(info[i].info2.drivername);
88
89                         info[i].info2.comment           = samdb_result_string(msgs[i], "comment", NULL);
90
91                         info[i].info2.location          = samdb_result_string(msgs[i], "location", NULL);
92
93                         info[i].info2.devmode           = NULL;
94
95                         info[i].info2.sepfile           = samdb_result_string(msgs[i], "sepfile", NULL);
96
97                         info[i].info2.printprocessor    = samdb_result_string(msgs[i], "printprocessor", "");
98                         W_ERROR_HAVE_NO_MEMORY(info[i].info2.printprocessor);
99
100                         info[i].info2.datatype          = samdb_result_string(msgs[i], "datatype", "");
101                         W_ERROR_HAVE_NO_MEMORY(info[i].info2.datatype);
102
103                         info[i].info2.parameters        = samdb_result_string(msgs[i], "parameters", NULL);
104
105                         info[i].info2.secdesc           = NULL;
106
107                         info[i].info2.attributes        = samdb_result_uint(msgs[i], "attributes", 0);
108                         info[i].info2.priority          = samdb_result_uint(msgs[i], "priority", 0);
109                         info[i].info2.defaultpriority   = samdb_result_uint(msgs[i], "defaultpriority", 0);
110                         info[i].info2.starttime         = samdb_result_uint(msgs[i], "starttime", 0);
111                         info[i].info2.untiltime         = samdb_result_uint(msgs[i], "untiltime", 0);
112                         info[i].info2.status            = samdb_result_uint(msgs[i], "status", 0);
113                         info[i].info2.cjobs             = samdb_result_uint(msgs[i], "cjobs", 0);
114                         info[i].info2.averageppm        = samdb_result_uint(msgs[i], "averageppm", 0);
115                 }
116                 return WERR_OK;
117         case 4:
118                 for (i = 0; i < count; i++) {
119                         info[i].info4.printername       = samdb_result_string(msgs[i], "printername", "");
120                         W_ERROR_HAVE_NO_MEMORY(info[i].info2.printername);
121
122                         info[i].info4.servername        = samdb_result_string(msgs[i], "servername", "");
123                         W_ERROR_HAVE_NO_MEMORY(info[i].info2.servername);
124
125                         info[i].info4.attributes        = samdb_result_uint(msgs[i], "attributes", 0);
126                 }
127                 return WERR_OK;
128         case 5:
129                 for (i = 0; i < count; i++) {
130                         info[i].info5.printername       = samdb_result_string(msgs[i], "name", "");
131                         W_ERROR_HAVE_NO_MEMORY(info[i].info5.printername);
132
133                         info[i].info5.portname          = samdb_result_string(msgs[i], "port", "");
134                         W_ERROR_HAVE_NO_MEMORY(info[i].info5.portname);
135
136                         info[i].info5.attributes        = samdb_result_uint(msgs[i], "attributes", 0);
137                         info[i].info5.device_not_selected_timeout = samdb_result_uint(msgs[i], "device_not_selected_timeout", 0);
138                         info[i].info5.transmission_retry_timeout  = samdb_result_uint(msgs[i], "transmission_retry_timeout", 0);
139                 }
140                 return WERR_OK;
141         }
142
143         return WERR_UNKNOWN_LEVEL;
144 }
145
146
147 /* 
148   spoolss_OpenPrinter 
149 */
150 static WERROR spoolss_OpenPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
151                        struct spoolss_OpenPrinter *r)
152 {
153         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
154 }
155
156
157 /* 
158   spoolss_SetJob 
159 */
160 static WERROR spoolss_SetJob(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
161                        struct spoolss_SetJob *r)
162 {
163         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
164 }
165
166
167 /* 
168   spoolss_GetJob 
169 */
170 static WERROR spoolss_GetJob(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
171                        struct spoolss_GetJob *r)
172 {
173         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
174 }
175
176
177 /* 
178   spoolss_EnumJobs 
179 */
180 static WERROR spoolss_EnumJobs(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
181                        struct spoolss_EnumJobs *r)
182 {
183         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
184 }
185
186
187 /* 
188   spoolss_AddPrinter 
189 */
190 static WERROR spoolss_AddPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
191                        struct spoolss_AddPrinter *r)
192 {
193         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
194 }
195
196
197 /* 
198   spoolss_DeletePrinter 
199 */
200 static WERROR spoolss_DeletePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
201                        struct spoolss_DeletePrinter *r)
202 {
203         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
204 }
205
206
207 /* 
208   spoolss_SetPrinter 
209 */
210 static WERROR spoolss_SetPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
211                        struct spoolss_SetPrinter *r)
212 {
213         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
214 }
215
216
217 /* 
218   spoolss_GetPrinter 
219 */
220 static WERROR spoolss_GetPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
221                        struct spoolss_GetPrinter *r)
222 {
223         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
224 }
225
226
227 /* 
228   spoolss_AddPrinterDriver 
229 */
230 static WERROR spoolss_AddPrinterDriver(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
231                        struct spoolss_AddPrinterDriver *r)
232 {
233         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
234 }
235
236
237 /* 
238   spoolss_EnumPrinterDrivers 
239 */
240 static WERROR spoolss_EnumPrinterDrivers(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
241                        struct spoolss_EnumPrinterDrivers *r)
242 {
243         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
244 }
245
246
247 /* 
248   spoolss_GetPrinterDriver 
249 */
250 static WERROR spoolss_GetPrinterDriver(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
251                        struct spoolss_GetPrinterDriver *r)
252 {
253         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
254 }
255
256
257 /* 
258   spoolss_GetPrinterDriverDirectory 
259 */
260 static WERROR spoolss_GetPrinterDriverDirectory(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
261                        struct spoolss_GetPrinterDriverDirectory *r)
262 {
263         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
264 }
265
266
267 /* 
268   spoolss_DeletePrinterDriver 
269 */
270 static WERROR spoolss_DeletePrinterDriver(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
271                        struct spoolss_DeletePrinterDriver *r)
272 {
273         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
274 }
275
276
277 /* 
278   spoolss_AddPrintProcessor 
279 */
280 static WERROR spoolss_AddPrintProcessor(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
281                        struct spoolss_AddPrintProcessor *r)
282 {
283         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
284 }
285
286
287 /* 
288   spoolss_EnumPrintProcessors 
289 */
290 static WERROR spoolss_EnumPrintProcessors(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
291                        struct spoolss_EnumPrintProcessors *r)
292 {
293         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
294 }
295
296
297 /* 
298   spoolss_GetPrintProcessorDirectory 
299 */
300 static WERROR spoolss_GetPrintProcessorDirectory(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
301                        struct spoolss_GetPrintProcessorDirectory *r)
302 {
303         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
304 }
305
306
307 /* 
308   spoolss_StartDocPrinter 
309 */
310 static WERROR spoolss_StartDocPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
311                        struct spoolss_StartDocPrinter *r)
312 {
313         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
314 }
315
316
317 /* 
318   spoolss_StartPagePrinter 
319 */
320 static WERROR spoolss_StartPagePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
321                        struct spoolss_StartPagePrinter *r)
322 {
323         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
324 }
325
326
327 /* 
328   spoolss_WritePrinter 
329 */
330 static WERROR spoolss_WritePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
331                        struct spoolss_WritePrinter *r)
332 {
333         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
334 }
335
336
337 /* 
338   spoolss_EndPagePrinter 
339 */
340 static WERROR spoolss_EndPagePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
341                        struct spoolss_EndPagePrinter *r)
342 {
343         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
344 }
345
346
347 /* 
348   spoolss_AbortPrinter 
349 */
350 static WERROR spoolss_AbortPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
351                        struct spoolss_AbortPrinter *r)
352 {
353         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
354 }
355
356
357 /* 
358   spoolss_ReadPrinter 
359 */
360 static WERROR spoolss_ReadPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
361                        struct spoolss_ReadPrinter *r)
362 {
363         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
364 }
365
366
367 /* 
368   spoolss_EndDocPrinter 
369 */
370 static WERROR spoolss_EndDocPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
371                        struct spoolss_EndDocPrinter *r)
372 {
373         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
374 }
375
376
377 /* 
378   spoolss_AddJob 
379 */
380 static WERROR spoolss_AddJob(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
381                        struct spoolss_AddJob *r)
382 {
383         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
384 }
385
386
387 /* 
388   spoolss_ScheduleJob 
389 */
390 static WERROR spoolss_ScheduleJob(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
391                        struct spoolss_ScheduleJob *r)
392 {
393         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
394 }
395
396
397 /* 
398   spoolss_GetPrinterData 
399 */
400 static WERROR spoolss_GetPrinterData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
401                        struct spoolss_GetPrinterData *r)
402 {
403         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
404 }
405
406
407 /* 
408   spoolss_SetPrinterData 
409 */
410 static WERROR spoolss_SetPrinterData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
411                        struct spoolss_SetPrinterData *r)
412 {
413         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
414 }
415
416
417 /* 
418   spoolss_WaitForPrinterChange 
419 */
420 static WERROR spoolss_WaitForPrinterChange(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
421                        struct spoolss_WaitForPrinterChange *r)
422 {
423         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
424 }
425
426
427 /* 
428   spoolss_ClosePrinter 
429 */
430 static WERROR spoolss_ClosePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
431                        struct spoolss_ClosePrinter *r)
432 {
433         struct dcesrv_handle *h;
434
435         *r->out.handle = *r->in.handle;
436
437         DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY);
438
439         talloc_free(h);
440
441         ZERO_STRUCTP(r->out.handle);
442
443         return WERR_OK;
444 }
445
446
447 /* 
448   spoolss_AddForm 
449 */
450 static WERROR spoolss_AddForm(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
451                        struct spoolss_AddForm *r)
452 {
453         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
454 }
455
456
457 /* 
458   spoolss_DeleteForm 
459 */
460 static WERROR spoolss_DeleteForm(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
461                        struct spoolss_DeleteForm *r)
462 {
463         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
464 }
465
466
467 /* 
468   spoolss_GetForm 
469 */
470 static WERROR spoolss_GetForm(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
471                        struct spoolss_GetForm *r)
472 {
473         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
474 }
475
476
477 /* 
478   spoolss_SetForm 
479 */
480 static WERROR spoolss_SetForm(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
481                        struct spoolss_SetForm *r)
482 {
483         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
484 }
485
486
487 /* 
488   spoolss_EnumForms 
489 */
490 static WERROR spoolss_EnumForms(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
491                        struct spoolss_EnumForms *r)
492 {
493         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
494 }
495
496
497 /* 
498   spoolss_EnumPorts 
499 */
500 static WERROR spoolss_EnumPorts(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
501                        struct spoolss_EnumPorts *r)
502 {
503         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
504 }
505
506
507 /* 
508   spoolss_EnumMonitors 
509 */
510 static WERROR spoolss_EnumMonitors(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
511                        struct spoolss_EnumMonitors *r)
512 {
513         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
514 }
515
516
517 /* 
518   spoolss_AddPort 
519 */
520 static WERROR spoolss_AddPort(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
521                        struct spoolss_AddPort *r)
522 {
523         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
524 }
525
526
527 /* 
528   spoolss_ConfigurePort 
529 */
530 static WERROR spoolss_ConfigurePort(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
531                        struct spoolss_ConfigurePort *r)
532 {
533         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
534 }
535
536
537 /* 
538   spoolss_DeletePort 
539 */
540 static WERROR spoolss_DeletePort(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
541                        struct spoolss_DeletePort *r)
542 {
543         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
544 }
545
546
547 /* 
548   spoolss_CreatePrinterIC 
549 */
550 static WERROR spoolss_CreatePrinterIC(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
551                        struct spoolss_CreatePrinterIC *r)
552 {
553         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
554 }
555
556
557 /* 
558   spoolss_PlayGDIScriptOnPrinterIC 
559 */
560 static WERROR spoolss_PlayGDIScriptOnPrinterIC(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
561                        struct spoolss_PlayGDIScriptOnPrinterIC *r)
562 {
563         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
564 }
565
566
567 /* 
568   spoolss_DeletePrinterIC 
569 */
570 static WERROR spoolss_DeletePrinterIC(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
571                        struct spoolss_DeletePrinterIC *r)
572 {
573         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
574 }
575
576
577 /* 
578   spoolss_AddPrinterConnection 
579 */
580 static WERROR spoolss_AddPrinterConnection(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
581                        struct spoolss_AddPrinterConnection *r)
582 {
583         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
584 }
585
586
587 /* 
588   spoolss_DeletePrinterConnection 
589 */
590 static WERROR spoolss_DeletePrinterConnection(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
591                        struct spoolss_DeletePrinterConnection *r)
592 {
593         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
594 }
595
596
597 /* 
598   spoolss_PrinterMessageBox 
599 */
600 static WERROR spoolss_PrinterMessageBox(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
601                        struct spoolss_PrinterMessageBox *r)
602 {
603         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
604 }
605
606
607 /* 
608   spoolss_AddMonitor 
609 */
610 static WERROR spoolss_AddMonitor(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
611                        struct spoolss_AddMonitor *r)
612 {
613         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
614 }
615
616
617 /* 
618   spoolss_DeleteMonitor 
619 */
620 static WERROR spoolss_DeleteMonitor(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
621                        struct spoolss_DeleteMonitor *r)
622 {
623         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
624 }
625
626
627 /* 
628   spoolss_DeletePrintProcessor 
629 */
630 static WERROR spoolss_DeletePrintProcessor(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
631                        struct spoolss_DeletePrintProcessor *r)
632 {
633         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
634 }
635
636
637 /* 
638   spoolss_AddPrintProvidor 
639 */
640 static WERROR spoolss_AddPrintProvidor(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
641                        struct spoolss_AddPrintProvidor *r)
642 {
643         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
644 }
645
646
647 /* 
648   spoolss_DeletePrintProvidor 
649 */
650 static WERROR spoolss_DeletePrintProvidor(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
651                        struct spoolss_DeletePrintProvidor *r)
652 {
653         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
654 }
655
656
657 /* 
658   spoolss_EnumPrintProcDataTypes 
659 */
660 static WERROR spoolss_EnumPrintProcDataTypes(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
661                        struct spoolss_EnumPrintProcDataTypes *r)
662 {
663         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
664 }
665
666
667 /* 
668   spoolss_ResetPrinter 
669 */
670 static WERROR spoolss_ResetPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
671                        struct spoolss_ResetPrinter *r)
672 {
673         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
674 }
675
676
677 /* 
678   spoolss_GetPrinterDriver2 
679 */
680 static WERROR spoolss_GetPrinterDriver2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
681                        struct spoolss_GetPrinterDriver2 *r)
682 {
683         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
684 }
685
686
687 /* 
688   spoolss_FindFirstPrinterChangeNotification 
689 */
690 static WERROR spoolss_FindFirstPrinterChangeNotification(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
691                        struct spoolss_FindFirstPrinterChangeNotification *r)
692 {
693         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
694 }
695
696
697 /* 
698   spoolss_FindNextPrinterChangeNotification 
699 */
700 static WERROR spoolss_FindNextPrinterChangeNotification(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
701                        struct spoolss_FindNextPrinterChangeNotification *r)
702 {
703         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
704 }
705
706
707 /* 
708   spoolss_FindClosePrinterNotify 
709 */
710 static WERROR spoolss_FindClosePrinterNotify(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
711                        struct spoolss_FindClosePrinterNotify *r)
712 {
713         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
714 }
715
716
717 /* 
718   spoolss_RouterFindFirstPrinterChangeNotificationOld 
719 */
720 static WERROR spoolss_RouterFindFirstPrinterChangeNotificationOld(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
721                        struct spoolss_RouterFindFirstPrinterChangeNotificationOld *r)
722 {
723         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
724 }
725
726
727 /* 
728   spoolss_ReplyOpenPrinter 
729 */
730 static WERROR spoolss_ReplyOpenPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
731                        struct spoolss_ReplyOpenPrinter *r)
732 {
733         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
734 }
735
736
737 /* 
738   spoolss_RouterReplyPrinter 
739 */
740 static WERROR spoolss_RouterReplyPrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
741                        struct spoolss_RouterReplyPrinter *r)
742 {
743         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
744 }
745
746
747 /* 
748   spoolss_ReplyClosePrinter 
749 */
750 static WERROR spoolss_ReplyClosePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
751                        struct spoolss_ReplyClosePrinter *r)
752 {
753         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
754 }
755
756
757 /* 
758   spoolss_AddPortEx 
759 */
760 static WERROR spoolss_AddPortEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
761                        struct spoolss_AddPortEx *r)
762 {
763         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
764 }
765
766
767 /* 
768   spoolss_RouterFindFirstPrinterChangeNotification 
769 */
770 static WERROR spoolss_RouterFindFirstPrinterChangeNotification(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
771                        struct spoolss_RouterFindFirstPrinterChangeNotification *r)
772 {
773         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
774 }
775
776
777 /* 
778   spoolss_SpoolerInit 
779 */
780 static WERROR spoolss_SpoolerInit(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
781                        struct spoolss_SpoolerInit *r)
782 {
783         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
784 }
785
786
787 /* 
788   spoolss_ResetPrinterEx 
789 */
790 static WERROR spoolss_ResetPrinterEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
791                        struct spoolss_ResetPrinterEx *r)
792 {
793         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
794 }
795
796
797 /* 
798   spoolss_RemoteFindFirstPrinterChangeNotifyEx 
799 */
800 static WERROR spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
801                        struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r)
802 {
803         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
804 }
805
806
807 /* 
808   spoolss_RouterRefreshPrinterChangeNotification 
809 */
810 static WERROR spoolss_RouterRefreshPrinterChangeNotification(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
811                        struct spoolss_RouterRefreshPrinterChangeNotification *r)
812 {
813         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
814 }
815
816
817 /* 
818   spoolss_RemoteFindNextPrinterChangeNotifyEx 
819 */
820 static WERROR spoolss_RemoteFindNextPrinterChangeNotifyEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
821                        struct spoolss_RemoteFindNextPrinterChangeNotifyEx *r)
822 {
823         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
824 }
825
826
827 /* 
828   spoolss_44 
829 */
830 static WERROR spoolss_44(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
831                        struct spoolss_44 *r)
832 {
833         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
834 }
835
836
837 static WERROR spoolss_OpenPrinterEx_server(struct dcesrv_call_state *dce_call, 
838                                            TALLOC_CTX *mem_ctx,
839                                            struct spoolss_OpenPrinterEx *r)
840 {
841         struct spoolss_openprinter_state *state;
842         struct dcesrv_handle *handle;
843
844         /* Check printername is our name */
845
846         if (!strequal(r->in.printername + 2, lp_netbios_name()))
847                 return WERR_INVALID_PRINTER_NAME;
848
849         handle = dcesrv_handle_new(dce_call->context, SPOOLSS_HANDLE_SERVER);
850         if (!handle) {
851                 return WERR_NOMEM;
852         }
853
854         state = talloc(handle, struct spoolss_openprinter_state);
855         if (!state) {
856                 return WERR_OK;
857         }
858
859         handle->data = state;
860
861         state->access_mask = r->in.access_mask;
862         *r->out.handle = handle->wire_handle;
863
864         return WERR_OK; 
865 }
866
867 static WERROR spoolss_OpenPrinterEx_printer(struct dcesrv_call_state *dce_call, 
868                                             TALLOC_CTX *mem_ctx,
869                                             struct spoolss_OpenPrinterEx *r)
870 {
871         char *server = talloc_strdup(mem_ctx, r->in.printername + 2);
872         char *pos, *printer;
873
874         pos = strchr(server, '\\');
875         *pos = 0;
876         printer = talloc_strdup(mem_ctx, pos + 1);
877
878         if (!strequal(server, lp_netbios_name()))
879                 return WERR_INVALID_PRINTER_NAME;
880
881         DEBUG(0, ("looking for server %s, printer %s\n", server, printer));
882         
883         return WERR_INVALID_PRINTER_NAME;
884 }
885
886 /* 
887   spoolss_OpenPrinterEx 
888 */
889 static WERROR spoolss_OpenPrinterEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
890                        struct spoolss_OpenPrinterEx *r)
891 {
892         ZERO_STRUCTP(r->out.handle);
893         
894         /* Printername must start with \\ */
895
896         if (strncmp(r->in.printername, "\\\\", 2) == 0)
897                 return WERR_INVALID_PARAM;
898
899         if (strchr_m(r->in.printername + 2, '\\'))
900                 return spoolss_OpenPrinterEx_server(dce_call, mem_ctx, r);
901         
902         return spoolss_OpenPrinterEx_printer(dce_call, mem_ctx, r);
903 }
904
905
906 /* 
907   spoolss_AddPrinterEx 
908 */
909 static WERROR spoolss_AddPrinterEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
910                        struct spoolss_AddPrinterEx *r)
911 {
912         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
913 }
914
915
916 /* 
917   spoolss_47 
918 */
919 static WERROR spoolss_47(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
920                        struct spoolss_47 *r)
921 {
922         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
923 }
924
925
926 /* 
927   spoolss_EnumPrinterData 
928 */
929 static WERROR spoolss_EnumPrinterData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
930                        struct spoolss_EnumPrinterData *r)
931 {
932         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
933 }
934
935
936 /* 
937   spoolss_DeletePrinterData 
938 */
939 static WERROR spoolss_DeletePrinterData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
940                        struct spoolss_DeletePrinterData *r)
941 {
942         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
943 }
944
945
946 /* 
947   spoolss_4a 
948 */
949 static WERROR spoolss_4a(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
950                        struct spoolss_4a *r)
951 {
952         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
953 }
954
955
956 /* 
957   spoolss_4b 
958 */
959 static WERROR spoolss_4b(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
960                        struct spoolss_4b *r)
961 {
962         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
963 }
964
965
966 /* 
967   spoolss_4c 
968 */
969 static WERROR spoolss_4c(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
970                        struct spoolss_4c *r)
971 {
972         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
973 }
974
975
976 /* 
977   spoolss_SetPrinterDataEx 
978 */
979 static WERROR spoolss_SetPrinterDataEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
980                        struct spoolss_SetPrinterDataEx *r)
981 {
982         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
983 }
984
985
986 /* 
987   spoolss_GetPrinterDataEx 
988 */
989 static WERROR spoolss_GetPrinterDataEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
990                        struct spoolss_GetPrinterDataEx *r)
991 {
992         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
993 }
994
995
996 /* 
997   spoolss_EnumPrinterDataEx 
998 */
999 static WERROR spoolss_EnumPrinterDataEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1000                        struct spoolss_EnumPrinterDataEx *r)
1001 {
1002         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1003 }
1004
1005
1006 /* 
1007   spoolss_EnumPrinterKey 
1008 */
1009 static WERROR spoolss_EnumPrinterKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1010                        struct spoolss_EnumPrinterKey *r)
1011 {
1012         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1013 }
1014
1015
1016 /* 
1017   spoolss_DeletePrinterDataEx 
1018 */
1019 static WERROR spoolss_DeletePrinterDataEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1020                        struct spoolss_DeletePrinterDataEx *r)
1021 {
1022         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1023 }
1024
1025
1026 /* 
1027   spoolss_DeletePrinterKey 
1028 */
1029 static WERROR spoolss_DeletePrinterKey(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1030                        struct spoolss_DeletePrinterKey *r)
1031 {
1032         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1033 }
1034
1035
1036 /* 
1037   spoolss_53 
1038 */
1039 static WERROR spoolss_53(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1040                        struct spoolss_53 *r)
1041 {
1042         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1043 }
1044
1045
1046 /* 
1047   spoolss_DeletePrinterDriverEx 
1048 */
1049 static WERROR spoolss_DeletePrinterDriverEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1050                        struct spoolss_DeletePrinterDriverEx *r)
1051 {
1052         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1053 }
1054
1055
1056 /* 
1057   spoolss_55 
1058 */
1059 static WERROR spoolss_55(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1060                        struct spoolss_55 *r)
1061 {
1062         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1063 }
1064
1065
1066 /* 
1067   spoolss_56 
1068 */
1069 static WERROR spoolss_56(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1070                        struct spoolss_56 *r)
1071 {
1072         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1073 }
1074
1075
1076 /* 
1077   spoolss_57 
1078 */
1079 static WERROR spoolss_57(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1080                        struct spoolss_57 *r)
1081 {
1082         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1083 }
1084
1085
1086 /* 
1087   spoolss_58 
1088 */
1089 static WERROR spoolss_58(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1090                        struct spoolss_58 *r)
1091 {
1092         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1093 }
1094
1095
1096 /* 
1097   spoolss_AddPrinterDriverEx 
1098 */
1099 static WERROR spoolss_AddPrinterDriverEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1100                        struct spoolss_AddPrinterDriverEx *r)
1101 {
1102         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1103 }
1104
1105
1106 /* 
1107   spoolss_5a 
1108 */
1109 static WERROR spoolss_5a(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1110                        struct spoolss_5a *r)
1111 {
1112         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1113 }
1114
1115
1116 /* 
1117   spoolss_5b 
1118 */
1119 static WERROR spoolss_5b(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1120                        struct spoolss_5b *r)
1121 {
1122         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1123 }
1124
1125
1126 /* 
1127   spoolss_5c 
1128 */
1129 static WERROR spoolss_5c(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1130                        struct spoolss_5c *r)
1131 {
1132         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1133 }
1134
1135
1136 /* 
1137   spoolss_5d 
1138 */
1139 static WERROR spoolss_5d(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1140                        struct spoolss_5d *r)
1141 {
1142         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1143 }
1144
1145
1146 /* 
1147   spoolss_5e 
1148 */
1149 static WERROR spoolss_5e(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1150                        struct spoolss_5e *r)
1151 {
1152         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1153 }
1154
1155
1156 /* 
1157   spoolss_5f 
1158 */
1159 static WERROR spoolss_5f(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
1160                        struct spoolss_5f *r)
1161 {
1162         DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
1163 }
1164
1165
1166 /* include the generated boilerplate */
1167 #include "librpc/gen_ndr/ndr_spoolss_s.c"