From 82c214d58efba2ff38c3a64298c57237f83039f4 Mon Sep 17 00:00:00 2001 From: David Disseldorp Date: Tue, 22 Jan 2013 10:56:28 +0100 Subject: [PATCH] WIP: publish devmode based printer attributes in AD Many AD printer attributes defined in MS-ADA3 correspond to device limits and feature support rather than current settings. Therefore, the devmode is not an ideal source for these values. --- source3/printing/nt_printing_ads.c | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/source3/printing/nt_printing_ads.c b/source3/printing/nt_printing_ads.c index b99a972..6273ba5 100644 --- a/source3/printing/nt_printing_ads.c +++ b/source3/printing/nt_printing_ads.c @@ -87,6 +87,41 @@ done: talloc_free(tmp_ctx); } +static WERROR nt_printer_devmode_to_mods(TALLOC_CTX *ctx, + struct spoolss_DeviceMode *devmode, + ADS_MODLIST *mods) +{ + if (devmode->fields & DEVMODE_COLOR) { + if (devmode->color == DMRES_COLOR) { + ads_mod_str(ctx, mods, SPOOL_REG_PRINTCOLOR, "TRUE"); + } else { + ads_mod_str(ctx, mods, SPOOL_REG_PRINTCOLOR, "FALSE"); + } + } + if (devmode->fields & DEVMODE_DUPLEX) { + if (devmode->duplex != DMDUP_SIMPLEX) { + ads_mod_str(ctx, mods, SPOOL_REG_PRINTDUPLEXSUPPORTED, + "TRUE"); + } else { + ads_mod_str(ctx, mods, SPOOL_REG_PRINTDUPLEXSUPPORTED, + "FALSE"); + } + } + if (devmode->fields & DEVMODE_COLLATE) { + if (devmode->collate == DMCOLLATE_TRUE) { + ads_mod_str(ctx, mods, SPOOL_REG_PRINTCOLLATE, "TRUE"); + } else { + ads_mod_str(ctx, mods, SPOOL_REG_PRINTCOLLATE, "FALSE"); + } + } + if (devmode->fields & DEVMODE_FORMNAME) { + ads_mod_str(ctx, mods, SPOOL_REG_PRINTFORMNAME, + devmode->formname); + } + + return WERR_OK; +} + static WERROR nt_printer_info_to_mods(TALLOC_CTX *ctx, struct spoolss_PrinterInfo2 *info2, ADS_MODLIST *mods) @@ -164,6 +199,14 @@ static WERROR nt_printer_info_to_mods(TALLOC_CTX *ctx, info2->attributes)); } + if (info2->devmode != NULL) { + WERROR werr; + werr = nt_printer_devmode_to_mods(ctx, info2->devmode, mods); + if (!W_ERROR_IS_OK(werr)) { + return werr; + } + } + return WERR_OK; } -- 1.7.10.4