s3-rpcclient: use rpccli_spoolss_openprinter_ex helper.
authorGünther Deschner <gd@samba.org>
Mon, 9 Feb 2009 17:49:34 +0000 (18:49 +0100)
committerGünther Deschner <gd@samba.org>
Tue, 10 Feb 2009 10:05:02 +0000 (11:05 +0100)
Guenther

source3/libads/ldap_printer.c
source3/rpcclient/cmd_spoolss.c
source3/utils/net_rpc_printer.c

index 1bcb86e996792aea479c3cbab58b5596a0ae129a..a61df3c9bd3ad2e53f189c0b1bebb05377d1727d 100644 (file)
@@ -319,11 +319,11 @@ WERROR get_remote_printer_publishing_data(struct rpc_pipe_client *cli,
                DEBUG(3, ("Insufficient memory\n"));
                return WERR_NOMEM;
        }
-       
-       result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, 
-                                            "", MAXIMUM_ALLOWED_ACCESS, 
-                                            cli->srv_name_slash, cli->auth->user_name,
-                                            &pol);
+
+       result = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername,
+                                              SEC_FLAG_MAXIMUM_ALLOWED,
+                                              &pol);
        if (!W_ERROR_IS_OK(result)) {
                DEBUG(3, ("Unable to open printer %s, error is %s.\n",
                          printername, win_errstr(result)));
index aba961a22d20aa13fdbf1de777a0e5302ddda348..9471c86e622f058e9fc32e112a690e93eaf6ea0e 100644 (file)
@@ -97,7 +97,6 @@ static WERROR cmd_spoolss_open_printer_ex(struct rpc_pipe_client *cli,
                                             int argc, const char **argv)
 {
        WERROR          werror;
-       fstring         printername;
        POLICY_HND      hnd;
 
        if (argc != 2) {
@@ -108,17 +107,14 @@ static WERROR cmd_spoolss_open_printer_ex(struct rpc_pipe_client *cli,
        if (!cli)
             return WERR_GENERAL_FAILURE;
 
-       fstrcpy(printername, argv[1]);
-
        /* Open the printer handle */
 
-       werror = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername,
-                                            "", PRINTER_ALL_ACCESS,
-                                            cli->srv_name_slash,
-                                            cli->auth->user_name, &hnd);
-
+       werror = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              argv[1],
+                                              PRINTER_ALL_ACCESS,
+                                              &hnd);
        if (W_ERROR_IS_OK(werror)) {
-               printf("Printer %s opened successfully\n", printername);
+               printf("Printer %s opened successfully\n", argv[1]);
                rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, &werror);
 
                if (!W_ERROR_IS_OK(werror)) {
@@ -486,10 +482,10 @@ static WERROR cmd_spoolss_setprinter(struct rpc_pipe_client *cli,
        slprintf(printername, sizeof(printername)-1, "%s\\%s", cli->srv_name_slash, argv[1]);
 
        /* get a printer handle */
-       result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "",
-                               PRINTER_ALL_ACCESS, cli->srv_name_slash,
-                               cli->auth->user_name, &pol);
-
+       result = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername,
+                                              PRINTER_ALL_ACCESS,
+                                              &pol);
        if (!W_ERROR_IS_OK(result))
                goto done;
 
@@ -547,10 +543,10 @@ static WERROR cmd_spoolss_setprintername(struct rpc_pipe_client *cli,
        slprintf(printername, sizeof(printername)-1, "%s\\%s", cli->srv_name_slash, argv[1]);
 
        /* get a printer handle */
-       result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "",
-                               PRINTER_ALL_ACCESS, cli->srv_name_slash,
-                               cli->auth->user_name, &pol);
-
+       result = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername,
+                                              PRINTER_ALL_ACCESS,
+                                              &pol);
        if (!W_ERROR_IS_OK(result))
                goto done;
 
@@ -606,11 +602,10 @@ static WERROR cmd_spoolss_getprinter(struct rpc_pipe_client *cli,
 
        /* get a printer handle */
 
-       result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername,
-                                            "", MAXIMUM_ALLOWED_ACCESS,
-                                            cli->srv_name_slash,
-                                            cli->auth->user_name, &pol);
-
+       result = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername,
+                                              SEC_FLAG_MAXIMUM_ALLOWED,
+                                              &pol);
        if (!W_ERROR_IS_OK(result))
                goto done;
 
@@ -745,11 +740,10 @@ static WERROR cmd_spoolss_getprinterdata(struct rpc_pipe_client *cli,
 
        /* get a printer handle */
 
-       result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername,
-                                            "", MAXIMUM_ALLOWED_ACCESS,
-                                            cli->srv_name_slash,
-                                            cli->auth->user_name, &pol);
-
+       result = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername,
+                                              SEC_FLAG_MAXIMUM_ALLOWED,
+                                              &pol);
        if (!W_ERROR_IS_OK(result))
                goto done;
 
@@ -808,11 +802,10 @@ static WERROR cmd_spoolss_getprinterdataex(struct rpc_pipe_client *cli,
 
        /* get a printer handle */
 
-       result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername,
-                                            "", MAXIMUM_ALLOWED_ACCESS,
-                                            cli->srv_name_slash,
-                                            cli->auth->user_name, &pol);
-
+       result = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername,
+                                              SEC_FLAG_MAXIMUM_ALLOWED,
+                                              &pol);
        if (!W_ERROR_IS_OK(result))
                goto done;
 
@@ -978,11 +971,10 @@ static WERROR cmd_spoolss_getdriver(struct rpc_pipe_client *cli,
 
        /* Open a printer handle */
 
-       werror = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "",
-                                            PRINTER_ACCESS_USE,
-                                            cli->srv_name_slash,
-                                            cli->auth->user_name, &pol);
-
+       werror = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername,
+                                              PRINTER_ACCESS_USE,
+                                              &pol);
        if (!W_ERROR_IS_OK(werror)) {
                printf("Error opening printer handle for %s!\n", printername);
                return werror;
@@ -1414,11 +1406,10 @@ static WERROR cmd_spoolss_setdriver(struct rpc_pipe_client *cli,
 
        /* Get a printer handle */
 
-       result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "",
-                                            PRINTER_ALL_ACCESS,
-                                            cli->srv_name_slash,
-                                            cli->auth->user_name, &pol);
-
+       result = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername,
+                                              PRINTER_ALL_ACCESS,
+                                              &pol);
        if (!W_ERROR_IS_OK(result))
                goto done;
 
@@ -1630,11 +1621,10 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
                return WERR_NOMEM;
        }
 
-       werror = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "",
-                                            PRINTER_ALL_ACCESS,
-                                            cli->srv_name_slash, cli->auth->user_name,
-                                            &handle);
-
+       werror = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername,
+                                              PRINTER_ALL_ACCESS,
+                                              &handle);
        if (!W_ERROR_IS_OK(werror))
                goto done;
 
@@ -1698,10 +1688,10 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
                return WERR_NOMEM;
        }
 
-       werror = rpccli_spoolss_open_printer_ex(
-               cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS,
-               cli->srv_name_slash, cli->auth->user_name, &handle);
-
+       werror = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername,
+                                              SEC_FLAG_MAXIMUM_ALLOWED,
+                                              &handle);
        if (!W_ERROR_IS_OK(werror))
                goto done;
 
@@ -1820,10 +1810,10 @@ static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
                return WERR_NOMEM;
        }
 
-       werror = rpccli_spoolss_open_printer_ex(
-               cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS,
-               cli->srv_name_slash, cli->auth->user_name, &handle);
-
+       werror = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername,
+                                              SEC_FLAG_MAXIMUM_ALLOWED,
+                                              &handle);
        if (!W_ERROR_IS_OK(werror))
                goto done;
 
@@ -1894,10 +1884,10 @@ static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli,
                return WERR_NOMEM;
        }
 
-       werror = rpccli_spoolss_open_printer_ex(
-               cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS,
-               cli->srv_name_slash, cli->auth->user_name, &handle);
-
+       werror = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername,
+                                              SEC_FLAG_MAXIMUM_ALLOWED,
+                                              &handle);
        if (!W_ERROR_IS_OK(werror))
                goto done;
 
@@ -1949,10 +1939,10 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli,
                return WERR_NOMEM;
        }
 
-       werror = rpccli_spoolss_open_printer_ex(
-               cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS,
-               cli->srv_name_slash, cli->auth->user_name, &handle);
-
+       werror = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername,
+                                              SEC_FLAG_MAXIMUM_ALLOWED,
+                                              &handle);
        if (!W_ERROR_IS_OK(werror))
                goto done;
 
@@ -2034,10 +2024,11 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
        }
 
        /* get a printer handle */
-       result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "",
-                                            MAXIMUM_ALLOWED_ACCESS,
-                                            cli->srv_name_slash,
-                                            cli->auth->user_name, &pol);
+
+       result = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername,
+                                              SEC_FLAG_MAXIMUM_ALLOWED,
+                                              &pol);
        if (!W_ERROR_IS_OK(result))
                goto done;
 
@@ -2224,11 +2215,10 @@ static WERROR cmd_spoolss_enum_jobs(struct rpc_pipe_client *cli,
                return WERR_NOMEM;
        }
 
-       result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername,
-                                            "", MAXIMUM_ALLOWED_ACCESS,
-                                            cli->srv_name_slash,
-                                            cli->auth->user_name, &hnd);
-
+       result = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername,
+                                              SEC_FLAG_MAXIMUM_ALLOWED,
+                                              &hnd);
        if (!W_ERROR_IS_OK(result))
                goto done;
 
@@ -2293,11 +2283,10 @@ static WERROR cmd_spoolss_enum_data( struct rpc_pipe_client *cli,
                return WERR_NOMEM;
        }
 
-       result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername,
-                                            "", MAXIMUM_ALLOWED_ACCESS,
-                                            cli->srv_name_slash,
-                                            cli->auth->user_name, &hnd);
-
+       result = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername,
+                                              SEC_FLAG_MAXIMUM_ALLOWED,
+                                              &hnd);
        if (!W_ERROR_IS_OK(result))
                goto done;
 
@@ -2360,11 +2349,10 @@ static WERROR cmd_spoolss_enum_data_ex( struct rpc_pipe_client *cli,
                return WERR_NOMEM;
        }
 
-       result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername,
-                                            "", MAXIMUM_ALLOWED_ACCESS,
-                                            cli->srv_name_slash,
-                                            cli->auth->user_name, &hnd);
-
+       result = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername,
+                                              SEC_FLAG_MAXIMUM_ALLOWED,
+                                              &hnd);
        if (!W_ERROR_IS_OK(result))
                goto done;
 
@@ -2429,12 +2417,10 @@ static WERROR cmd_spoolss_enum_printerkey( struct rpc_pipe_client *cli,
                return WERR_NOMEM;
        }
 
-
-       result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername,
-                                            "", MAXIMUM_ALLOWED_ACCESS,
-                                            cli->srv_name_slash,
-                                            cli->auth->user_name, &hnd);
-
+       result = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername,
+                                              SEC_FLAG_MAXIMUM_ALLOWED,
+                                              &hnd);
        if (!W_ERROR_IS_OK(result))
                goto done;
 
@@ -2494,10 +2480,10 @@ static WERROR cmd_spoolss_rffpcnex(struct rpc_pipe_client *cli,
                 cli->desthost, argv[1]);
        strupper_m(printername);
 
-       result = rpccli_spoolss_open_printer_ex(
-               cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS,
-               cli->srv_name_slash, cli->auth->user_name, &hnd);
-
+       result = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername,
+                                              SEC_FLAG_MAXIMUM_ALLOWED,
+                                              &hnd);
        if (!W_ERROR_IS_OK(result)) {
                printf("Error opening %s\n", argv[1]);
                goto done;
@@ -2658,7 +2644,6 @@ static WERROR cmd_spoolss_printercmp(struct rpc_pipe_client *cli,
 {
        fstring printername, servername1, servername2;
        char *printername_path = NULL;
-       struct cli_state *cli_server1 = rpc_pipe_np_smb_conn(cli);
        struct cli_state *cli_server2 = NULL;
        struct rpc_pipe_client *cli2 = NULL;
        POLICY_HND hPrinter1, hPrinter2;
@@ -2709,8 +2694,11 @@ static WERROR cmd_spoolss_printercmp(struct rpc_pipe_client *cli,
                return WERR_NOMEM;
        }
        printf("Opening %s...", printername_path);
-       werror = rpccli_spoolss_open_printer_ex( cli, mem_ctx, printername_path,
-               "", PRINTER_ALL_ACCESS, servername1, cli_server1->user_name, &hPrinter1);
+
+       werror = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+                                              printername_path,
+                                              PRINTER_ALL_ACCESS,
+                                              &hPrinter1);
        if ( !W_ERROR_IS_OK(werror) ) {
                printf("failed (%s)\n", win_errstr(werror));
                goto done;
@@ -2725,8 +2713,10 @@ static WERROR cmd_spoolss_printercmp(struct rpc_pipe_client *cli,
                return WERR_NOMEM;
        }
        printf("Opening %s...", printername_path);
-       werror = rpccli_spoolss_open_printer_ex( cli2, mem_ctx, printername_path,
-               "", PRINTER_ALL_ACCESS, servername2, cli_server2->user_name, &hPrinter2 );
+       werror = rpccli_spoolss_openprinter_ex(cli2, mem_ctx,
+                                              printername_path,
+                                              PRINTER_ALL_ACCESS,
+                                              &hPrinter2);
        if ( !W_ERROR_IS_OK(werror) ) {
                 printf("failed (%s)\n", win_errstr(werror));
                goto done;
index a40d5cadfd9c57f996704895355dd2028a4a1457..41a5e8fdeddc059c5d612707684f9682ed56f032 100644 (file)
@@ -736,9 +736,10 @@ static bool net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd,
                pipe_hnd->srv_name_slash, username, printername2, access_required));
 
        /* open printer */
-       result = rpccli_spoolss_open_printer_ex(pipe_hnd, mem_ctx, printername2,
-                       "", access_required,
-                       pipe_hnd->srv_name_slash, username, hnd);
+       result = rpccli_spoolss_openprinter_ex(pipe_hnd, mem_ctx,
+                                              printername2,
+                                              access_required,
+                                              hnd);
 
        /* be more verbose */
        if (W_ERROR_V(result) == W_ERROR_V(WERR_ACCESS_DENIED)) {