diff options
-rw-r--r-- | source3/rpc_server/spoolss/srv_spoolss_nt.c | 24 |
1 files 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, ""); |