diff options
author | Andreas Schneider <asn@samba.org> | 2014-12-18 15:14:36 +0000 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2015-02-18 12:43:44 +0100 |
commit | a4157e7c5d75be7003ad0b72fdfe9856a9e5ba8f (patch) | |
tree | 479011e217184cc13e4c092da8dc6e1e2bd66d82 | |
parent | 6595ced146a53dcef9bbd5d2deb82a44c8ce1a1a (diff) | |
download | samba-a4157e7c5d75be7003ad0b72fdfe9856a9e5ba8f.tar.gz samba-a4157e7c5d75be7003ad0b72fdfe9856a9e5ba8f.tar.xz samba-a4157e7c5d75be7003ad0b72fdfe9856a9e5ba8f.zip |
spoolss: retrieve published printer GUID if not in registry
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>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Wed Feb 18 12:43:44 CET 2015 on sn-devel-104
-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, ""); |