WERROR nt_printer_guid_store(struct messaging_context *msg_ctx, const char *printer, struct GUID guid) { TALLOC_CTX *tmp_ctx; const struct auth_session_info *session_info; const char *guid_str; DATA_BLOB blob; WERROR result; tmp_ctx = talloc_new(NULL); if (!tmp_ctx) { DEBUG(0, ("Out of memory?!\n")); return WERR_NOMEM; } session_info = get_session_info_system(); if (session_info == NULL) { DEBUG(0, ("Could not get system session_info\n")); result = WERR_NOMEM; goto done; } guid_str = GUID_string(tmp_ctx, &guid); if (!guid_str) { DEBUG(0, ("Out of memory?!\n")); result = WERR_NOMEM; goto done; } /* We used to store this as a REG_BINARY but that causes Vista to whine */ if (!push_reg_sz(tmp_ctx, &blob, guid_str)) { DEBUG(0, ("Could not marshall string %s for objectGUID\n", guid_str)); result = WERR_NOMEM; goto done; } result = winreg_set_printer_dataex_internal(tmp_ctx, session_info, msg_ctx, printer, SPOOL_DSSPOOLER_KEY, "objectGUID", REG_SZ, blob.data, blob.length); if (!W_ERROR_IS_OK(result)) { DEBUG(0, ("Failed to store GUID for printer %s\n", printer)); goto done; } result = WERR_OK; done: talloc_free(tmp_ctx); return result; }
static void store_printer_guid(struct messaging_context *msg_ctx, const char *printer, struct GUID guid) { TALLOC_CTX *tmp_ctx; struct auth_serversupplied_info *session_info = NULL; const char *guid_str; DATA_BLOB blob; NTSTATUS status; WERROR result; tmp_ctx = talloc_new(NULL); if (!tmp_ctx) { DEBUG(0, ("store_printer_guid: Out of memory?!\n")); return; } status = make_session_info_system(tmp_ctx, &session_info); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("store_printer_guid: " "Could not create system session_info\n")); goto done; } guid_str = GUID_string(tmp_ctx, &guid); if (!guid_str) { DEBUG(0, ("store_printer_guid: Out of memory?!\n")); goto done; } /* We used to store this as a REG_BINARY but that causes Vista to whine */ if (!push_reg_sz(tmp_ctx, &blob, guid_str)) { DEBUG(0, ("store_printer_guid: " "Could not marshall string %s for objectGUID\n", guid_str)); goto done; } result = winreg_set_printer_dataex_internal(tmp_ctx, session_info, msg_ctx, printer, SPOOL_DSSPOOLER_KEY, "objectGUID", REG_SZ, blob.data, blob.length); if (!W_ERROR_IS_OK(result)) { DEBUG(0, ("store_printer_guid: " "Failed to store GUID for printer %s\n", printer)); } done: talloc_free(tmp_ctx); }