From 0f18ca772da544a93799ca130a8f23529aad98f6 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sat, 6 Nov 1999 19:52:04 +0000 Subject: added rpcclient spoolenum command. enumerates printers. spoolss_r_io_enumprinters doesn't decode strings correctly as printer_info_1/2 code has only been written to write structures, not read them. (This used to be commit 135eaa977385cdd5f572a51f654f14d893347d7b) --- source3/rpc_client/cli_spoolss.c | 64 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'source3/rpc_client/cli_spoolss.c') diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index adb850673f..9d8d5f5736 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -32,6 +32,70 @@ extern int DEBUGLEVEL; +/**************************************************************************** +do a SPOOLSS Enum Printers +****************************************************************************/ +BOOL spoolss_enum_printers(struct cli_state *cli, uint16 fnum, + uint32 flags, char *servername, + uint32 level, + uint32 *count, + void ***printers) +{ + prs_struct rbuf; + prs_struct buf; + SPOOL_Q_ENUMPRINTERS q_o; + BOOL valid_pol = False; + + if (count == NULL || printers == NULL) return False; + + prs_init(&buf , 1024, 4, SAFETY_MARGIN, False); + prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True ); + + /* create and send a MSRPC command with api SPOOLSS_ENUM_PRINTERS */ + + DEBUG(5,("SPOOLSS Enum Printers (Server: %s level: %d)\n", + servername, level)); + + make_spoolss_q_enumprinters(&q_o, flags, servername, level, 0x200); + + /* turn parameters into data stream */ + spoolss_io_q_enumprinters("", &q_o, &buf, 0); + + /* send the data on \PIPE\ */ + if (rpc_api_pipe_req(cli, fnum, SPOOLSS_ENUMPRINTERS, &buf, &rbuf)) + { + SPOOL_R_ENUMPRINTERS r_o; + BOOL p; + + ZERO_STRUCT(r_o); + + r_o.level = level; + + spoolss_io_r_enumprinters("", &r_o, &rbuf, 0); + p = rbuf.offset != 0; + + if (p && r_o.status != 0) + { + /* report error code */ + DEBUG(5,("SPOOLSS_ENUM_PRINTERS: %s\n", get_nt_error_msg(r_o.status))); + p = False; + } + + if (p) + { + /* ok, at last: we're happy. return the policy handle */ + (*count) = r_o.returned; + (*printers) = r_o.printer.info; + valid_pol = True; + } + } + + prs_mem_free(&rbuf); + prs_mem_free(&buf ); + + return valid_pol; +} + /**************************************************************************** do a SPOOLSS Open Printer Ex ****************************************************************************/ -- cgit