s3:smbd map_username() doesn't need sconn anymore
[Samba/ekacnet.git] / source3 / rpc_server / srv_spoolss_util.h
blob9b79ce5b67abcaf08ad42434500944cabc0d9a69
1 /*
2 * Unix SMB/CIFS implementation.
4 * SPOOLSS RPC Pipe server / winreg client routines
6 * Copyright (c) 2010 Andreas Schneider <asn@samba.org>
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 3 of the License, or
11 * (at your option) any later version.
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.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, see <http://www.gnu.org/licenses/>.
22 #ifndef _SRV_SPOOLSS_UITL_H
23 #define _SRV_SPOOLSS_UITL_H
26 enum spoolss_PrinterInfo2Mask {
27 SPOOLSS_PRINTER_INFO_ATTRIBUTES = (int)(0x00000001),
28 SPOOLSS_PRINTER_INFO_AVERAGEPPM = (int)(0x00000002),
29 SPOOLSS_PRINTER_INFO_CJOBS = (int)(0x00000004),
30 SPOOLSS_PRINTER_INFO_COMMENT = (int)(0x00000008),
31 SPOOLSS_PRINTER_INFO_DATATYPE = (int)(0x00000010),
32 SPOOLSS_PRINTER_INFO_DEFAULTPRIORITY = (int)(0x00000020),
33 SPOOLSS_PRINTER_INFO_DEVMODE = (int)(0x00000040),
34 SPOOLSS_PRINTER_INFO_DRIVERNAME = (int)(0x00000080),
35 SPOOLSS_PRINTER_INFO_LOCATION = (int)(0x00000100),
36 SPOOLSS_PRINTER_INFO_NAME = (int)(0x00000200),
37 SPOOLSS_PRINTER_INFO_PARAMETERS = (int)(0x00000400),
38 SPOOLSS_PRINTER_INFO_PORTNAME = (int)(0x00000800),
39 SPOOLSS_PRINTER_INFO_PRINTERNAME = (int)(0x00001000),
40 SPOOLSS_PRINTER_INFO_PRINTPROCESSOR = (int)(0x00002000),
41 SPOOLSS_PRINTER_INFO_PRIORITY = (int)(0x00004000),
42 SPOOLSS_PRINTER_INFO_SECDESC = (int)(0x00008000),
43 SPOOLSS_PRINTER_INFO_SEPFILE = (int)(0x00010000),
44 SPOOLSS_PRINTER_INFO_SERVERNAME = (int)(0x00020000),
45 SPOOLSS_PRINTER_INFO_SHARENAME = (int)(0x00040000),
46 SPOOLSS_PRINTER_INFO_STARTTIME = (int)(0x00080000),
47 SPOOLSS_PRINTER_INFO_STATUS = (int)(0x00100000),
48 SPOOLSS_PRINTER_INFO_UNTILTIME = (int)(0x00200000)
51 #define SPOOLSS_PRINTER_INFO_ALL SPOOLSS_PRINTER_INFO_ATTRIBUTES | \
52 SPOOLSS_PRINTER_INFO_AVERAGEPPM | \
53 SPOOLSS_PRINTER_INFO_CJOBS | \
54 SPOOLSS_PRINTER_INFO_COMMENT | \
55 SPOOLSS_PRINTER_INFO_DATATYPE | \
56 SPOOLSS_PRINTER_INFO_DEFAULTPRIORITY | \
57 SPOOLSS_PRINTER_INFO_DEVMODE | \
58 SPOOLSS_PRINTER_INFO_DRIVERNAME | \
59 SPOOLSS_PRINTER_INFO_LOCATION | \
60 SPOOLSS_PRINTER_INFO_NAME | \
61 SPOOLSS_PRINTER_INFO_PARAMETERS | \
62 SPOOLSS_PRINTER_INFO_PORTNAME | \
63 SPOOLSS_PRINTER_INFO_PRINTERNAME | \
64 SPOOLSS_PRINTER_INFO_PRINTPROCESSOR | \
65 SPOOLSS_PRINTER_INFO_PRIORITY | \
66 SPOOLSS_PRINTER_INFO_SECDESC | \
67 SPOOLSS_PRINTER_INFO_SEPFILE | \
68 SPOOLSS_PRINTER_INFO_SERVERNAME | \
69 SPOOLSS_PRINTER_INFO_SHARENAME | \
70 SPOOLSS_PRINTER_INFO_STARTTIME | \
71 SPOOLSS_PRINTER_INFO_STATUS | \
72 SPOOLSS_PRINTER_INFO_UNTILTIME
74 WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
75 struct auth_serversupplied_info *server_info,
76 const char *servername,
77 const char *sharename);
79 /**
80 * @internal
82 * @brief Update the information of a printer in the registry.
84 * @param[in] mem_ctx The talloc memory context to use.
86 * @param[in] server_info The server supplied session info.
88 * @param[in] sharename The share name.
90 * @param[in] info2_mask A bitmask which defines which values should be set.
92 * @param[in] info2 A SetPrinterInfo2 structure with the data to set.
94 * @param[in] devmode A device mode structure with the data to set.
96 * @param[in] secdesc A security descriptor structure with the data to set.
98 * @return On success WERR_OK, a corresponding DOS error is
99 * something went wrong.
101 WERROR winreg_update_printer(TALLOC_CTX *mem_ctx,
102 struct auth_serversupplied_info *server_info,
103 const char *sharename,
104 uint32_t info2_mask,
105 struct spoolss_SetPrinterInfo2 *info2,
106 struct spoolss_DeviceMode *devmode,
107 struct security_descriptor *secdesc);
111 * @brief Get the inforamtion of a printer stored in the registry.
113 * @param[in] mem_ctx The talloc memory context to use.
115 * @param[in] server_info The server supplied session info.
117 * @param[in] printer The servername to use.
119 * @param[in] printer The name of the printer to get.
121 * @param[out] pinfo2 A pointer to store a PRINTER_INFO_2 structure.
123 * @return On success WERR_OK, a corresponding DOS error is
124 * something went wrong.
126 WERROR winreg_get_printer(TALLOC_CTX *mem_ctx,
127 struct auth_serversupplied_info *server_info,
128 const char *servername,
129 const char *printer,
130 struct spoolss_PrinterInfo2 **pinfo2);
133 * @brief Get the security descriptor for a printer.
135 * @param[in] mem_ctx The talloc memory context to use.
137 * @param[in] server_info The server supplied session info.
139 * @param[in] sharename The share name.
141 * @param[out] psecdesc A pointer to store the security descriptor.
143 * @return On success WERR_OK, a corresponding DOS error is
144 * something went wrong.
146 WERROR winreg_get_printer_secdesc(TALLOC_CTX *mem_ctx,
147 struct auth_serversupplied_info *server_info,
148 const char *sharename,
149 struct spoolss_security_descriptor **psecdesc);
152 * @brief Set the security descriptor for a printer.
154 * @param[in] mem_ctx The talloc memory context to use.
156 * @param[in] server_info The server supplied session info.
158 * @param[in] sharename The share name.
160 * @param[in] secdesc The security descriptor to save.
162 * @return On success WERR_OK, a corresponding DOS error is
163 * something went wrong.
165 WERROR winreg_set_printer_secdesc(TALLOC_CTX *mem_ctx,
166 struct auth_serversupplied_info *server_info,
167 const char *sharename,
168 const struct spoolss_security_descriptor *secdesc);
171 * @internal
173 * @brief Set printer data over the winreg pipe.
175 * @param[in] mem_ctx The talloc memory context to use.
177 * @param[in] server_info The server supplied session info.
179 * @param[in] printer The printer name.
181 * @param[in] key The key of the printer data to store the value.
183 * @param[in] value The value name to save.
185 * @param[in] type The type of the value to use.
187 * @param[in] data The data which sould be saved under the given value.
189 * @param[in] data_size The size of the data.
191 * @return On success WERR_OK, a corresponding DOS error is
192 * something went wrong.
194 WERROR winreg_set_printer_dataex(TALLOC_CTX *mem_ctx,
195 struct auth_serversupplied_info *server_info,
196 const char *printer,
197 const char *key,
198 const char *value,
199 enum winreg_Type type,
200 uint8_t *data,
201 uint32_t data_size);
204 * @internal
206 * @brief Get printer data over a winreg pipe.
208 * @param[in] mem_ctx The talloc memory context to use.
210 * @param[in] server_info The server supplied session info.
212 * @param[in] printer The printer name.
214 * @param[in] key The key of the printer data to get the value.
216 * @param[in] value The name of the value to query.
218 * @param[in] type The type of the value to query.
220 * @param[out] data A pointer to store the data.
222 * @param[out] data_size A pointer to store the size of the data.
224 * @return On success WERR_OK, a corresponding DOS error is
225 * something went wrong.
227 WERROR winreg_get_printer_dataex(TALLOC_CTX *mem_ctx,
228 struct auth_serversupplied_info *server_info,
229 const char *printer,
230 const char *key,
231 const char *value,
232 enum winreg_Type *type,
233 uint8_t **data,
234 uint32_t *data_size);
237 * @internal
239 * @brief Enumerate on the values of a given key and provide the data.
241 * @param[in] mem_ctx The talloc memory context to use.
243 * @param[in] server_info The server supplied session info.
245 * @param[in] printer The printer name.
247 * @param[in] key The key of the printer data to get the value.
249 * @param[out] pnum_values A pointer to store the number of values we found.
251 * @param[out] penum_values A pointer to store the values and its data.
253 * @return WERR_OK on success, the corresponding DOS error
254 * code if something gone wrong.
256 WERROR winreg_enum_printer_dataex(TALLOC_CTX *mem_ctx,
257 struct auth_serversupplied_info *server_info,
258 const char *printer,
259 const char *key,
260 uint32_t *pnum_values,
261 struct spoolss_PrinterEnumValues **penum_values);
264 * @internal
266 * @brief Delete printer data over a winreg pipe.
268 * @param[in] mem_ctx The talloc memory context to use.
270 * @param[in] server_info The server supplied session info.
272 * @param[in] printer The printer name.
274 * @param[in] key The key of the printer data to delete.
276 * @param[in] value The name of the value to delete.
278 * @return On success WERR_OK, a corresponding DOS error is
279 * something went wrong.
281 WERROR winreg_delete_printer_dataex(TALLOC_CTX *mem_ctx,
282 struct auth_serversupplied_info *server_info,
283 const char *printer,
284 const char *key,
285 const char *value);
288 * @internal
290 * @brief Enumerate on the subkeys of a given key and provide the data.
292 * @param[in] mem_ctx The talloc memory context to use.
294 * @param[in] server_info The server supplied session info.
296 * @param[in] printer The printer name.
298 * @param[in] key The key of the printer data to get the value.
300 * @param[out] pnum_subkeys A pointer to store the number of subkeys found.
302 * @param[in] psubkeys A pointer to an array to store the names of the subkeys
303 * found.
305 * @return WERR_OK on success, the corresponding DOS error
306 * code if something gone wrong.
308 WERROR winreg_enum_printer_key(TALLOC_CTX *mem_ctx,
309 struct auth_serversupplied_info *server_info,
310 const char *printer,
311 const char *key,
312 uint32_t *pnum_subkeys,
313 const char ***psubkeys);
316 * @internal
318 * @brief Delete a key with subkeys of a given printer.
320 * @param[in] mem_ctx The talloc memory context to use.
322 * @param[in] server_info The server supplied session info.
324 * @param[in] printer The printer name.
326 * @param[in] key The key of the printer to delete.
328 * @return On success WERR_OK, a corresponding DOS error is
329 * something went wrong.
331 WERROR winreg_delete_printer_key(TALLOC_CTX *mem_ctx,
332 struct auth_serversupplied_info *server_info,
333 const char *printer,
334 const char *key);
337 * @brief Update the ChangeID of a printer.
339 * The ChangeID **must** be increasing over the lifetime of client's spoolss
340 * service in order for the client's cache to show updates.
342 * If a form is updated of a printer, the we need to update the ChangeID of the
343 * pritner.
345 * @param[in] mem_ctx The talloc memory context to use.
347 * @param[in] server_info The server supplied session info.
349 * @param[in] printer The printer name.
351 * @return On success WERR_OK, a corresponding DOS error is
352 * something went wrong.
354 WERROR winreg_printer_update_changeid(TALLOC_CTX *mem_ctx,
355 struct auth_serversupplied_info *server_info,
356 const char *printer);
359 * @brief Get the ChangeID of the given printer.
361 * @param[in] mem_ctx The talloc memory context to use.
363 * @param[in] server_info The server supplied session info.
365 * @param[in] printer The printer name.
367 * @param[in] changeid A pointer to store the changeid.
369 * @return On success WERR_OK, a corresponding DOS error is
370 * something went wrong.
372 WERROR winreg_printer_get_changeid(TALLOC_CTX *mem_ctx,
373 struct auth_serversupplied_info *server_info,
374 const char *printer,
375 uint32_t *pchangeid);
378 * @internal
380 * @brief This function adds a form to the list of available forms that can be
381 * selected for the specified printer.
383 * @param[in] mem_ctx The talloc memory context to use.
385 * @param[in] server_info The server supplied session info.
387 * @param[in] form The form to add.
389 * @return WERR_OK on success.
390 * WERR_ALREADY_EXISTS if the form already exists or is a
391 * builtin form.
392 * A corresponding DOS error is something went wrong.
394 WERROR winreg_printer_addform1(TALLOC_CTX *mem_ctx,
395 struct auth_serversupplied_info *server_info,
396 struct spoolss_AddFormInfo1 *form);
399 * @brief This function enumerates the forms supported by the specified printer.
401 * @param[in] mem_ctx The talloc memory context to use.
403 * @param[in] server_info The server supplied session info.
405 * @param[out] pnum_info A pointer to store the FormInfo count.
407 * @param[out] pinfo A pointer to store an array with FormInfo.
409 * @return On success WERR_OK, a corresponding DOS error is
410 * something went wrong.
412 WERROR winreg_printer_enumforms1(TALLOC_CTX *mem_ctx,
413 struct auth_serversupplied_info *server_info,
414 uint32_t *pnum_info,
415 union spoolss_FormInfo **pinfo);
418 * @brief This function removes a form name from the list of supported forms.
420 * @param[in] mem_ctx The talloc memory context to use.
422 * @param[in] server_info The server supplied session info.
424 * @param[in] form_name The name of the form to delete.
426 * @return WERR_OK on success.
427 * WERR_INVALID_PARAM if the form is a builtin form.
428 * WERR_INVALID_FORM_NAME if the form or key doesn't exist.
429 * A corresponding DOS error is something went wrong.
431 WERROR winreg_printer_deleteform1(TALLOC_CTX *mem_ctx,
432 struct auth_serversupplied_info *server_info,
433 const char *form_name);
436 * @brief This function sets the form information for the specified printer.
438 * If one provides both the name in the API call and inside the FormInfo
439 * structure, then the form gets renamed.
441 * @param[in] mem_ctx The talloc memory context to use.
443 * @param[in] server_info The server supplied session info.
445 * @param[in] form_name The name of the form to set or rename.
447 * @param[in] form The FormInfo structure to save.
449 * @return WERR_OK on success.
450 * WERR_INVALID_PARAM if the form is a builtin form.
451 * A corresponding DOS error is something went wrong.
453 WERROR winreg_printer_setform1(TALLOC_CTX *mem_ctx,
454 struct auth_serversupplied_info *server_info,
455 const char *form_name,
456 struct spoolss_AddFormInfo1 *form);
459 * @brief This function retrieves information about a specified form.
461 * @param[in] mem_ctx The talloc memory context to use.
463 * @param[in] server_info The server supplied session info.
465 * @param[in] form_name The name of the form to query.
467 * @param[out] form A pointer to a form structure to fill out.
469 * @return On success WERR_OK, a corresponding DOS error is
470 * something went wrong.
472 WERROR winreg_printer_getform1(TALLOC_CTX *mem_ctx,
473 struct auth_serversupplied_info *server_info,
474 const char *form_name,
475 struct spoolss_FormInfo1 *form);
478 * @brief This function adds a new spool driver
480 * @param[in] mem_ctx A talloc memory context.
482 * @param[in] server_info Auth info to open the pipe.
484 * @param[in] r The structure containing the new driver data.
486 * @param[out] driver_name Returns the driver name.
488 * @param[out] driver_version Returns the driver version.
490 * @return On success WERR_OK, a corresponding DOS error is
491 * something went wrong.
493 WERROR winreg_add_driver(TALLOC_CTX *mem_ctx,
494 struct auth_serversupplied_info *server_info,
495 struct spoolss_AddDriverInfoCtr *r,
496 const char **driver_name,
497 uint32_t *driver_version);
500 * @brief This function gets printer driver information
502 * @param[in] mem_ctx A talloc memory context.
504 * @param[in] server_info Auth info to open the pipe.
506 * @param[in] architecture The architecture type.
508 * @param[in] driver_name The driver name.
510 * @param[in] driver_version The driver version.
512 * @param[out] _info8 The structure that holds the full driver information.
514 * @return On success WERR_OK, a corresponding DOS error is
515 * something went wrong.
518 WERROR winreg_get_driver(TALLOC_CTX *mem_ctx,
519 struct auth_serversupplied_info *server_info,
520 const char *architecture,
521 const char *driver_name,
522 uint32_t driver_version,
523 struct spoolss_DriverInfo8 **_info8);
526 * @brief This function deletes a printer driver information
528 * @param[in] mem_ctx A talloc memory context.
530 * @param[in] server_info Auth info to open the pipe.
532 * @param[out] info8 The structure that holds the full driver information.
534 * @param[in] version The driver type version.
536 * @return On success WERR_OK, a corresponding DOS error is
537 * something went wrong.
540 WERROR winreg_del_driver(TALLOC_CTX *mem_ctx,
541 struct auth_serversupplied_info *server_info,
542 struct spoolss_DriverInfo8 *info8,
543 uint32_t version);
546 * @brief This function gets printer drivers list for the specified
547 * architecture and type version
549 * @param[in] mem_ctx A talloc memory context.
551 * @param[in] server_info Auth info to open the pipe.
553 * @param[in] architecture The architecture type.
555 * @param[in] version The driver version.
557 * @param[out] num_drivers The number of drivers.
559 * @param[out] version The drivers names.
561 * @return On success WERR_OK, a corresponding DOS error is
562 * something went wrong.
565 WERROR winreg_get_driver_list(TALLOC_CTX *mem_ctx,
566 struct auth_serversupplied_info *server_info,
567 const char *architecture,
568 uint32_t version,
569 uint32_t *num_drivers,
570 const char ***drivers);
572 #endif /* _SRV_SPOOLSS_UITL_H */