[cups-devel] setting AllowUser from API

Robert Welz Robert.Welz at thinprint.com
Wed May 31 07:19:04 PDT 2017


Dear Michel

I had no success with adding an AllowUser to the printing queue.

My code is as follows:

http_t        *http;        /* Connection to server */
    int           num_options;	/* Number of options */
    cups_option_t	*options;     /* Options */
    
    http        = NULL;
    num_options = 0;
    options     = NULL;
    
    ipp_t		*request;		/* IPP Request */
    char		uri[HTTP_MAX_URI];	/* URI for printer/class */


	httpAssembleURIf(HTTP_URI_CODING_ALL, uri, (int)sizeof(uri), "ipp", NULL, "localhost", ippPort(), "/printers/%s", [printerName UTF8String]);
    	request = ippNewRequest(IPP_OP_CUPS_ADD_MODIFY_PRINTER);
	
	num_options = cupsAddOption(IPP_ATTR_NAME_PRINTER_URI, [printerURI UTF8String], num_options, &options);
 	num_options = cupsAddOption(IPP_ATTR_NAME_DEVICE_URI, [printerURI UTF8String], num_options, &options);

	num_options = cupsAddOption(IPP_ATTR_NAME_REQUESTING_USERNAMES_ALLOWED, [userstring UTF8String], num_options, &options); 
	cupsEncodeOptions2(request, num_options, options, IPP_TAG_PRINTER);

	
	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, IPP_ATTR_NAME_PRINTER_URI, NULL, uri);
	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, IPP_ATTR_NAME_REQUESTING_USERNAME, NULL, cupsUser());
	ippAddInteger(request, IPP_TAG_PRINTER, IPP_TAG_ENUM, IPP_ATTR_NAME_PRINTER_STATE, IPP_PSTATE_IDLE);
	ippAddBoolean(request, IPP_TAG_PRINTER, IPP_ATTR_NAME_PRINTER_IS_ACCEPTING_JOBS, 1);

	ippDelete(cupsDoRequest(http, request, "/admin/"));
	ipp_status_t lastCupsError = cupsLastError();
	… error handling omitted...


The log says now:

D [31/May/2017:16:15:54 +0200] CUPS-Add-Modify-Printer client-error-bad-request: Attributgruppen sind durcheinander (1 < 4).
E [31/May/2017:16:15:54 +0200] [Client 318] Returning IPP client-error-bad-request for CUPS-Add-Modify-Printer (no URI) from localhost

I guess the german in this text would translate to „Attribute groups are mismatched (1 < 4)“.


kind regards,

Robert








Robert Welz  |  Software Development ThinPrint
ThinPrint GmbH  |  Alt-Moabit 91 a/b  |  10559 Berlin  |  Germany
Tel.: +49 (0)30 394931-0  |  Fax: +49 (0)30 394931-99
www.thinprint.com  |  robert.welz at .cortado.com
 
Geschäftsführung: Charlotte Künzell, Thorsten Hesse, Frank Hoffmann, Bernd Trappe, Amtsgericht Berlin-Charlottenburg, HRB 163480 B

> Am 31.05.2017 um 15:02 schrieb Michael Sweet <msweet at apple.com>:
> 
> cupsEncodeOptions2(request, num_options, options, IPP_TAG_PRINTER);



More information about the cups-devel mailing list