]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
spoolss: retrieve published printer GUID if not in registry
authorAndreas Schneider <asn@samba.org>
Thu, 18 Dec 2014 15:14:36 +0000 (15:14 +0000)
committerKarolin Seeger <kseeger@samba.org>
Sun, 15 Mar 2015 21:13:08 +0000 (22:13 +0100)
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 <ddiss@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
(cherry picked from commit a4157e7c5d75be7003ad0b72fdfe9856a9e5ba8f)

source3/rpc_server/spoolss/srv_spoolss_nt.c

index 17eee50a31ea438e7bbb6ce3d534130d2fc7b240..34f0b5707d92cae675463cd4e0c77fa7c31e9e98 100644 (file)
@@ -4232,7 +4232,25 @@ static WERROR construct_printer_info7(TALLOC_CTX *mem_ctx,
                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->action = DSPRINT_PUBLISH;