From a4157e7c5d75be7003ad0b72fdfe9856a9e5ba8f Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 18 Dec 2014 15:14:36 +0000 Subject: spoolss: retrieve published printer GUID if not in registry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a printer is published, the GUID for the published DN is retrieved from the domain controller and stored in the registry. When handling a spoolss GetPrinter(level=7) request, the same GUID is obtained from the registry and returned to the client. This change sees the spoolss server query the DC for the published printer GUID if it is not present in the registry when handling a spoolss GetPrinter(level=7) request. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11018 Pair-Programmed-With: David Disseldorp Signed-off-by: Andreas Schneider Signed-off-by: David Disseldorp Reviewed-by: Guenther Deschner Autobuild-User(master): Günther Deschner Autobuild-Date(master): Wed Feb 18 12:43:44 CET 2015 on sn-devel-104 --- source3/rpc_server/spoolss/srv_spoolss_nt.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c index 115af2d686..a195eb6710 100644 --- a/source3/rpc_server/spoolss/srv_spoolss_nt.c +++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c @@ -4234,12 +4234,32 @@ static WERROR construct_printer_info7(TALLOC_CTX *mem_ctx, if (is_printer_published(tmp_ctx, session_info, msg_ctx, servername, printer, NULL)) { struct GUID guid; + struct GUID_txt_buf guid_txt; werr = nt_printer_guid_get(tmp_ctx, session_info, msg_ctx, printer, &guid); if (!W_ERROR_IS_OK(werr)) { - goto out_tmp_free; + /* + * If we do not have a GUID entry in the registry, then + * try to retrieve it from AD and store it now. + */ + werr = nt_printer_guid_retrieve(tmp_ctx, printer, + &guid); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(1, ("Failed to retrieve GUID for " + "printer [%s] from AD - " + "Is the the printer still " + "published ?\n", printer)); + goto out_tmp_free; + } + + werr = nt_printer_guid_store(msg_ctx, printer, guid); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(3, ("failed to store printer %s guid\n", + printer)); + } } - r->guid = talloc_strdup_upper(mem_ctx, GUID_string2(mem_ctx, &guid)); + r->guid = talloc_strdup_upper(mem_ctx, + GUID_buf_string(&guid, &guid_txt)); r->action = DSPRINT_PUBLISH; } else { r->guid = talloc_strdup(mem_ctx, ""); -- cgit