Hello Emmanuel,

If your can compile the sources yourself, you could try the attached diff to extend the setprinter call of rpcclient.

usage: setprinter comment [location]

CAVE: It's just a may-be-buggy patch from me. Not from the samba team.
Use at your own risk! :-)

Bye,

Martin

Emmanuel Lacour schrieb:
On Wed, Jan 02, 2008 at 09:45:49AM -0800, Jeremy Allison wrote:
On Wed, Jan 02, 2008 at 08:52:46AM +0100, Martin Zielinski wrote:
Hello,

This is the result of asking cups for a comment and location string to sync them between cups and samba. I've allready asked the samba-team to replace it with a more general approach but got no response until now.
Sorry, your mail is sat in my inbox. I understand the issue and I'm planning
to try and get the fix into 3.2.


Thanks.

I'm currently trying to create a script to maintain comment/location for
my printers, using rpcclient.
I can change comment with "setprinter the_printer_name the_description"
without problem.
But when I try this for setting the location, I get WERR_ACCESS_DENIED:

setprinterdata the_printer_name string location the_location


any idea to solve this would be welcome ;)



--- samba-3.0.28.orig/source/rpcclient/cmd_spoolss.c    2007-11-15 
04:15:04.000000000 +0100
+++ samba-3.0.28/source/rpcclient/cmd_spoolss.c 2008-01-07 13:12:14.000000000 
+0100
@@ -476,17 +476,28 @@
        fstring         printername,
                        servername,
                        user,
-                       comment;
+                       comment,
+                   location;
 
-       if (argc == 1 || argc > 3) {
-               printf("Usage: %s printername comment\n", argv[0]);
+    /* Added the option to change the printer location */
+       
+       if (argc == 1 || argc > 4) {
+               printf("Usage: %s printername comment [location]\n", argv[0]);
 
                return WERR_OK;
        }
 
+       comment[0] = '\0';
+       location[0] = '\0';
+       
        /* Open a printer handle */
-       if (argc == 3) {
-               fstrcpy(comment, argv[2]);
+       if (argc >= 3) {
+               if (argv[2][0] != '-' || argv[2][1] != '\0') {
+                       fstrcpy(comment, argv[2]);
+               }
+       }
+       if (argc > 3) {
+                       fstrcpy(location, argv[3]);
        }
 
        slprintf(servername, sizeof(servername)-1, "\\\\%s", 
cli->cli->desthost);
@@ -513,12 +524,15 @@
 
        /* Modify the comment. */
        init_unistr(&ctr.printers_2->comment, comment);
+       /* Modify the location. */
+       if (argc > 3) 
+               init_unistr(&ctr.printers_2->location, location);
        ctr.printers_2->devmode = NULL;
        ctr.printers_2->secdesc = NULL;
 
        result = rpccli_spoolss_setprinter(cli, mem_ctx, &pol, info_level, 
&ctr, 0);
        if (W_ERROR_IS_OK(result))
-               printf("Success in setting comment.\n");
+               printf("Success in setting comment%s.\n", argc>3?" and 
location":"");
 
  done:
        if (opened_hnd)
-- 
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/listinfo/samba

Reply via email to