From bfd8043a403dfed84bc568685580703a8470738d Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 13 Dec 2002 18:56:48 +0000 Subject: More printer publishing code. - Add published attribute to info2, needed for win clients to work properly - Return proper info on getprinter 7 This means you can now look at the sharing tab of a printer and get correct info about whether it is published or not, and change it. (This used to be commit adda04379ee46f105436262663652f3f576fa3cf) --- source3/printing/nt_printing.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'source3/printing') diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index cdcca6bbfe..532ab0794c 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -2540,7 +2540,8 @@ static BOOL map_nt_printer_info2_to_dsspooler(NT_PRINTER_INFO_LEVEL_2 *info2) map_dword_into_ctr(ctr, SPOOL_REG_PRIORITY, info2->priority); map_bool_into_ctr(ctr, SPOOL_REG_PRINTKEEPPRINTEDJOBS, - (info2->attributes & 0x100)); + (info2->attributes & + PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS)); switch (info2->attributes & 0x3) { case 0: @@ -2583,11 +2584,12 @@ WERROR nt_printer_publish(int snum, int action) if (!W_ERROR_IS_OK(win_rc)) return win_rc; - if ((SPOOL_DS_PUBLISH == action) || (SPOOL_DS_UPDATE == action) || - (SPOOL_DS_REPUBLISH == action)) { + if ((SPOOL_DS_PUBLISH == action) || (SPOOL_DS_UPDATE == action)) { if (!(map_nt_printer_info2_to_dsspooler(printer->info_2))) return WERR_NOMEM; + printer->info_2->attributes |= PRINTER_ATTRIBUTE_PUBLISHED; + win_rc = mod_a_printer(*printer, 2); if (!W_ERROR_IS_OK(win_rc)) { DEBUG(3, ("nt_printer_publish: err %d saving data\n", @@ -2600,13 +2602,22 @@ WERROR nt_printer_publish(int snum, int action) &printer->info_2->data); ads_mod_str(ctx, &mods, SPOOL_REG_PRINTERNAME, lp_servicename(snum)); + } else { + printer->info_2->attributes ^= PRINTER_ATTRIBUTE_PUBLISHED; + win_rc = mod_a_printer(*printer, 2); + if (!W_ERROR_IS_OK(win_rc)) { + DEBUG(3, ("nt_printer_publish: err %d saving data\n", + W_ERROR_V(win_rc))); + free_a_printer(&printer, 2); + return win_rc; + } } ads = ads_init(NULL, NULL, lp_ads_server()); ads_rc = ads_connect(ads); - if ((SPOOL_DS_UNPUBLISH == action) || (SPOOL_DS_REPUBLISH == action)) { + if (SPOOL_DS_UNPUBLISH == action) { ads_rc = ads_find_printer_on_server(ads, &res, printer->info_2->sharename, global_myname()); if (ADS_ERR_OK(ads_rc) && ads_count_replies(ads, res)) { @@ -2617,8 +2628,7 @@ WERROR nt_printer_publish(int snum, int action) } } - if ((SPOOL_DS_PUBLISH == action) || (SPOOL_DS_UPDATE == action) || - (SPOOL_DS_REPUBLISH == action)) { + if ((SPOOL_DS_PUBLISH == action) || (SPOOL_DS_UPDATE == action)) { ads_find_machine_acct(ads, &res, global_myname()); srv_dn = ldap_get_dn(ads->ld, res); ads_msgfree(ads, res); -- cgit