s3-build: avoid to globally include printing and spoolss headers.
[vlendec/samba-autobuild/.git] / source3 / utils / net_rpc_printer.c
index a40d5cadfd9c57f996704895355dd2028a4a1457..589a569879776ee13d9707d237f8bdd6d58386a4 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Samba Unix/Linux SMB client library
    Distributed SMB/CIFS Server Management Utility
-   Copyright (C) 2004 Guenther Deschner (gd@samba.org)
+   Copyright (C) 2004,2009 Guenther Deschner (gd@samba.org)
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 */
 #include "includes.h"
 #include "utils/net.h"
-
-struct table_node {
-       const char *long_archi;
-       const char *short_archi;
-       int version;
-};
-
+#include "../librpc/gen_ndr/cli_spoolss.h"
+#include "rpc_client/cli_spoolss.h"
+#include "rpc_client/init_spoolss.h"
+#include "nt_printing.h"
+#include "registry.h"
+#include "registry/reg_objects.h"
 
 /* support itanium as well */
-static const struct table_node archi_table[]= {
+static const struct print_architecture_table_node archi_table[]= {
 
        {"Windows 4.0",          "WIN40",       0 },
        {"Windows NT x86",       "W32X86",      2 },
@@ -50,101 +49,72 @@ static const struct table_node archi_table[]= {
  Printer info level 3 display function.
 ****************************************************************************/
 
-static void display_print_driver_3(DRIVER_INFO_3 *i1)
+static void display_print_driver3(struct spoolss_DriverInfo3 *r)
 {
-       fstring name = "";
-       fstring architecture = "";
-       fstring driverpath = "";
-       fstring datafile = "";
-       fstring configfile = "";
-       fstring helpfile = "";
-       fstring dependentfiles = "";
-       fstring monitorname = "";
-       fstring defaultdatatype = "";
-
-       int length=0;
-       bool valid = true;
-
-       if (i1 == NULL)
-               return;
+       int i;
 
-       rpcstr_pull(name, i1->name.buffer, sizeof(name), -1, STR_TERMINATE);
-       rpcstr_pull(architecture, i1->architecture.buffer, sizeof(architecture), -1, STR_TERMINATE);
-       rpcstr_pull(driverpath, i1->driverpath.buffer, sizeof(driverpath), -1, STR_TERMINATE);
-       rpcstr_pull(datafile, i1->datafile.buffer, sizeof(datafile), -1, STR_TERMINATE);
-       rpcstr_pull(configfile, i1->configfile.buffer, sizeof(configfile), -1, STR_TERMINATE);
-       rpcstr_pull(helpfile, i1->helpfile.buffer, sizeof(helpfile), -1, STR_TERMINATE);
-       rpcstr_pull(monitorname, i1->monitorname.buffer, sizeof(monitorname), -1, STR_TERMINATE);
-       rpcstr_pull(defaultdatatype, i1->defaultdatatype.buffer, sizeof(defaultdatatype), -1, STR_TERMINATE);
-
-       d_printf ("Printer Driver Info 3:\n");
-       d_printf ("\tVersion: [%x]\n", i1->version);
-       d_printf ("\tDriver Name: [%s]\n",name);
-       d_printf ("\tArchitecture: [%s]\n", architecture);
-       d_printf ("\tDriver Path: [%s]\n", driverpath);
-       d_printf ("\tDatafile: [%s]\n", datafile);
-       d_printf ("\tConfigfile: [%s]\n", configfile);
-       d_printf ("\tHelpfile: [%s]\n\n", helpfile);
-
-       while (valid) {
-               rpcstr_pull(dependentfiles, i1->dependentfiles+length, sizeof(dependentfiles), -1, STR_TERMINATE);
-
-               length+=strlen(dependentfiles)+1;
-
-               if (strlen(dependentfiles) > 0) {
-                       d_printf ("\tDependentfiles: [%s]\n", dependentfiles);
-               } else {
-                       valid = false;
-               }
+       if (!r) {
+               return;
        }
 
-       printf ("\n");
+       printf(_("Printer Driver Info 3:\n"));
+       printf(_("\tVersion: [%x]\n"), r->version);
+       printf(_("\tDriver Name: [%s]\n"), r->driver_name);
+       printf(_("\tArchitecture: [%s]\n"), r->architecture);
+       printf(_("\tDriver Path: [%s]\n"), r->driver_path);
+       printf(_("\tDatafile: [%s]\n"), r->data_file);
+       printf(_("\tConfigfile: [%s]\n\n"), r->config_file);
+       printf(_("\tHelpfile: [%s]\n\n"), r->help_file);
+
+       for (i=0; r->dependent_files[i] != NULL; i++) {
+               printf(_("\tDependentfiles: [%s]\n"), r->dependent_files[i]);
+       }
 
-       d_printf ("\tMonitorname: [%s]\n", monitorname);
-       d_printf ("\tDefaultdatatype: [%s]\n\n", defaultdatatype);
+       printf("\n");
 
-       return;
+       printf(_("\tMonitorname: [%s]\n"), r->monitor_name);
+       printf(_("\tDefaultdatatype: [%s]\n\n"), r->default_datatype);
 }
 
-static void display_reg_value(const char *subkey, REGISTRY_VALUE value)
+static void display_reg_value(const char *subkey, struct regval_blob *value)
 {
-       char *text;
+       const char *text;
+       DATA_BLOB blob;
 
-       switch(value.type) {
+       switch(regval_type(value)) {
        case REG_DWORD:
-               d_printf("\t[%s:%s]: REG_DWORD: 0x%08x\n", subkey, value.valuename,
-                      *((uint32 *) value.data_p));
+               d_printf(_("\t[%s:%s]: REG_DWORD: 0x%08x\n"), subkey,
+                       regval_name(value), *((uint32_t *) regval_data_p(value)));
                break;
 
        case REG_SZ:
-               rpcstr_pull_talloc(talloc_tos(),
-                               &text,
-                               value.data_p,
-                               value.size,
-                               STR_TERMINATE);
+               blob = data_blob_const(regval_data_p(value), regval_size(value));
+               pull_reg_sz(talloc_tos(), &blob, &text);
                if (!text) {
                        break;
                }
-               d_printf("\t[%s:%s]: REG_SZ: %s\n", subkey, value.valuename, text);
+               d_printf(_("\t[%s:%s]: REG_SZ: %s\n"), subkey, regval_name(value),
+                        text);
                break;
 
        case REG_BINARY:
-               d_printf("\t[%s:%s]: REG_BINARY: unknown length value not displayed\n",
-                        subkey, value.valuename);
+               d_printf(_("\t[%s:%s]: REG_BINARY: unknown length value not "
+                          "displayed\n"),
+                        subkey, regval_name(value));
                break;
 
        case REG_MULTI_SZ: {
-               uint32 i, num_values;
-               char **values;
+               uint32_t i;
+               const char **values;
+               blob = data_blob_const(regval_data_p(value), regval_size(value));
 
-               if (!W_ERROR_IS_OK(reg_pull_multi_sz(NULL, value.data_p,
-                                                    value.size, &num_values,
-                                                    &values))) {
-                       d_printf("reg_pull_multi_sz failed\n");
+               if (!pull_reg_multi_sz(NULL, &blob, &values)) {
+                       d_printf("pull_reg_multi_sz failed\n");
                        break;
                }
 
-               for (i=0; i<num_values; i++) {
+               printf("%s: REG_MULTI_SZ: \n", regval_name(value));
+               for (i=0; values[i] != NULL; i++) {
                        d_printf("%s\n", values[i]);
                }
                TALLOC_FREE(values);
@@ -152,7 +122,8 @@ static void display_reg_value(const char *subkey, REGISTRY_VALUE value)
        }
 
        default:
-               d_printf("\t%s: unknown type %d\n", value.valuename, value.type);
+               d_printf(_("\t%s: unknown type %d\n"), regval_name(value),
+                        regval_type(value));
        }
 
 }
@@ -184,10 +155,10 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
                  bool copy_timestamps, bool is_file)
 {
        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
-       int fnum_src = 0;
-       int fnum_dst = 0;
-       SEC_DESC *sd = NULL;
-       uint16 attr;
+       uint16_t fnum_src = 0;
+       uint16_t fnum_dst = 0;
+       struct security_descriptor *sd = NULL;
+       uint16_t attr;
        time_t f_atime, f_ctime, f_mtime;
 
 
@@ -199,8 +170,8 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
        DEBUGADD(3,("opening %s %s on originating server\n",
                is_file?"file":"dir", src_name));
 
-       fnum_src = cli_nt_create(cli_share_src, src_name, READ_CONTROL_ACCESS);
-       if (fnum_src == -1) {
+       if (!NT_STATUS_IS_OK(cli_ntcreate(cli_share_src, src_name, 0, READ_CONTROL_ACCESS, 0,
+                               FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum_src))) {
                DEBUGADD(0,("cannot open %s %s on originating server %s\n",
                        is_file?"file":"dir", src_name, cli_errstr(cli_share_src)));
                nt_status = cli_nt_error(cli_share_src);
@@ -227,8 +198,8 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
        if (copy_attrs || copy_timestamps) {
 
                /* get file attributes */
-               if (!cli_getattrE(cli_share_src, fnum_src, &attr, NULL,
-                                &f_ctime, &f_atime, &f_mtime)) {
+               if (!NT_STATUS_IS_OK(cli_getattrE(cli_share_src, fnum_src, &attr, NULL,
+                                &f_ctime, &f_atime, &f_mtime))) {
                        DEBUG(0,("failed to get file-attrs: %s\n",
                                cli_errstr(cli_share_src)));
                        nt_status = cli_nt_error(cli_share_src);
@@ -239,8 +210,8 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
 
        /* open the file/dir on the destination server */
 
-       fnum_dst = cli_nt_create(cli_share_dst, dst_name, WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS);
-       if (fnum_dst == -1) {
+       if (!NT_STATUS_IS_OK(cli_ntcreate(cli_share_dst, dst_name, 0, WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS, 0,
+                               FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum_dst))) {
                DEBUG(0,("failed to open %s on the destination server: %s: %s\n",
                        is_file?"file":"dir", dst_name, cli_errstr(cli_share_dst)));
                nt_status = cli_nt_error(cli_share_dst);
@@ -250,7 +221,7 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
        if (copy_timestamps) {
 
                /* set timestamps */
-               if (!cli_setattrE(cli_share_dst, fnum_dst, f_ctime, f_atime, f_mtime)) {
+               if (!NT_STATUS_IS_OK(cli_setattrE(cli_share_dst, fnum_dst, f_ctime, f_atime, f_mtime))) {
                        DEBUG(0,("failed to set file-attrs (timestamps): %s\n",
                                cli_errstr(cli_share_dst)));
                        nt_status = cli_nt_error(cli_share_dst);
@@ -272,7 +243,7 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
        if (copy_attrs) {
 
                /* set attrs */
-               if (!cli_setatr(cli_share_dst, dst_name, attr, 0)) {
+               if (!NT_STATUS_IS_OK(cli_setatr(cli_share_dst, dst_name, attr, 0))) {
                        DEBUG(0,("failed to set file-attrs: %s\n",
                                cli_errstr(cli_share_dst)));
                        nt_status = cli_nt_error(cli_share_dst);
@@ -283,15 +254,17 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
 
        /* closing files */
 
-       if (!cli_close(cli_share_src, fnum_src)) {
-               d_fprintf(stderr, "could not close %s on originating server: %s\n",
+       if (!NT_STATUS_IS_OK(cli_close(cli_share_src, fnum_src))) {
+               d_fprintf(stderr,
+                       _("could not close %s on originating server: %s\n"),
                        is_file?"file":"dir", cli_errstr(cli_share_src));
                nt_status = cli_nt_error(cli_share_src);
                goto out;
        }
 
-       if (!cli_close(cli_share_dst, fnum_dst)) {
-               d_fprintf(stderr, "could not close %s on destination server: %s\n",
+       if (!NT_STATUS_IS_OK(cli_close(cli_share_dst, fnum_dst))) {
+               d_fprintf(stderr,
+                       _("could not close %s on destination server: %s\n"),
                        is_file?"file":"dir", cli_errstr(cli_share_dst));
                nt_status = cli_nt_error(cli_share_dst);
                goto out;
@@ -338,8 +311,8 @@ NTSTATUS net_copy_file(struct net_context *c,
                       bool copy_timestamps, bool is_file)
 {
        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
-       int fnum_src = 0;
-       int fnum_dst = 0;
+       uint16_t fnum_src = 0;
+       uint16_t fnum_dst = 0;
        static int io_bufsize = 64512;
        int read_size = io_bufsize;
        char *data = NULL;
@@ -356,15 +329,15 @@ NTSTATUS net_copy_file(struct net_context *c,
        DEBUGADD(3,("opening %s %s on originating server\n",
                is_file ? "file":"dir", src_name));
        if (is_file)
-               fnum_src = cli_open(cli_share_src, src_name, O_RDONLY, DENY_NONE);
+               nt_status = cli_open(cli_share_src, src_name, O_RDONLY, DENY_NONE, &fnum_src);
        else
-               fnum_src = cli_nt_create(cli_share_src, src_name, READ_CONTROL_ACCESS);
+               nt_status = cli_ntcreate(cli_share_src, src_name, 0, READ_CONTROL_ACCESS, 0,
+                               FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum_src);
 
-       if (fnum_src == -1) {
+       if (!NT_STATUS_IS_OK(nt_status)) {
                DEBUGADD(0,("cannot open %s %s on originating server %s\n",
                        is_file ? "file":"dir",
                        src_name, cli_errstr(cli_share_src)));
-               nt_status = cli_nt_error(cli_share_src);
                goto out;
        }
 
@@ -373,19 +346,19 @@ NTSTATUS net_copy_file(struct net_context *c,
 
                /* open file on the destination server */
                DEBUGADD(3,("opening file %s on destination server\n", dst_name));
-               fnum_dst = cli_open(cli_share_dst, dst_name,
-                               O_RDWR|O_CREAT|O_TRUNC, DENY_NONE);
+               nt_status = cli_open(cli_share_dst, dst_name,
+                               O_RDWR|O_CREAT|O_TRUNC, DENY_NONE, &fnum_dst);
 
-               if (fnum_dst == -1) {
+               if (!NT_STATUS_IS_OK(nt_status)) {
                        DEBUGADD(1,("cannot create file %s on destination server: %s\n", 
                                dst_name, cli_errstr(cli_share_dst)));
-                       nt_status = cli_nt_error(cli_share_dst);
                        goto out;
                }
 
                /* allocate memory */
                if (!(data = (char *)SMB_MALLOC(read_size))) {
-                       d_fprintf(stderr, "malloc fail for size %d\n", read_size);
+                       d_fprintf(stderr, _("malloc fail for size %d\n"),
+                                 read_size);
                        nt_status = NT_STATUS_NO_MEMORY;
                        goto out;
                }
@@ -395,13 +368,13 @@ NTSTATUS net_copy_file(struct net_context *c,
 
        if (c->opt_verbose) {
 
-               d_printf("copying [\\\\%s\\%s%s] => [\\\\%s\\%s%s] "
-                        "%s ACLs and %s DOS Attributes %s\n",
+               d_printf(_("copying [\\\\%s\\%s%s] => [\\\\%s\\%s%s] "
+                          "%s ACLs and %s DOS Attributes %s\n"),
                        cli_share_src->desthost, cli_share_src->share, src_name,
                        cli_share_dst->desthost, cli_share_dst->share, dst_name,
-                       copy_acls ?  "with" : "without",
-                       copy_attrs ? "with" : "without",
-                       copy_timestamps ? "(preserving timestamps)" : "" );
+                       copy_acls ?  _("with") : _("without"),
+                       copy_attrs ? _("with") : _("without"),
+                       copy_timestamps ? _("(preserving timestamps)") : "" );
        }
 
 
@@ -419,7 +392,7 @@ NTSTATUS net_copy_file(struct net_context *c,
                        nread, n);
 
                if (n != ret) {
-                       d_fprintf(stderr, "Error writing file: %s\n",
+                       d_fprintf(stderr, _("Error writing file: %s\n"),
                                cli_errstr(cli_share_dst));
                        nt_status = cli_nt_error(cli_share_dst);
                        goto out;
@@ -429,20 +402,21 @@ NTSTATUS net_copy_file(struct net_context *c,
        }
 
 
-       if (!is_file && !cli_chkpath(cli_share_dst, dst_name)) {
+       if (!is_file && !NT_STATUS_IS_OK(cli_chkpath(cli_share_dst, dst_name))) {
 
                /* creating dir */
                DEBUGADD(3,("creating dir %s on the destination server\n",
                        dst_name));
 
-               if (!cli_mkdir(cli_share_dst, dst_name)) {
+               if (!NT_STATUS_IS_OK(cli_mkdir(cli_share_dst, dst_name))) {
                        DEBUG(0,("cannot create directory %s: %s\n",
                                dst_name, cli_errstr(cli_share_dst)));
                        nt_status = NT_STATUS_NO_SUCH_FILE;
                }
 
-               if (!cli_chkpath(cli_share_dst, dst_name)) {
-                       d_fprintf(stderr, "cannot check for directory %s: %s\n",
+               if (!NT_STATUS_IS_OK(cli_chkpath(cli_share_dst, dst_name))) {
+                       d_fprintf(stderr,
+                               _("cannot check for directory %s: %s\n"),
                                dst_name, cli_errstr(cli_share_dst));
                        goto out;
                }
@@ -450,15 +424,17 @@ NTSTATUS net_copy_file(struct net_context *c,
 
 
        /* closing files */
-       if (!cli_close(cli_share_src, fnum_src)) {
-               d_fprintf(stderr, "could not close file on originating server: %s\n",
+       if (!NT_STATUS_IS_OK(cli_close(cli_share_src, fnum_src))) {
+               d_fprintf(stderr,
+                       _("could not close file on originating server: %s\n"),
                        cli_errstr(cli_share_src));
                nt_status = cli_nt_error(cli_share_src);
                goto out;
        }
 
-       if (is_file && !cli_close(cli_share_dst, fnum_dst)) {
-               d_fprintf(stderr, "could not close file on destination server: %s\n",
+       if (is_file && !NT_STATUS_IS_OK(cli_close(cli_share_dst, fnum_dst))) {
+               d_fprintf(stderr,
+                       _("could not close file on destination server: %s\n"),
                        cli_errstr(cli_share_dst));
                nt_status = cli_nt_error(cli_share_dst);
                goto out;
@@ -513,16 +489,19 @@ static NTSTATUS net_copy_driverfile(struct net_context *c,
                                    TALLOC_CTX *mem_ctx,
                                    struct cli_state *cli_share_src,
                                    struct cli_state *cli_share_dst,
-                                   char *file, const char *short_archi) {
+                                   const char *file, const char *short_archi) {
 
-       NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
        const char *p;
        char *src_name;
        char *dst_name;
-       char *version;
-       char *filename;
+       char *version = NULL;
+       char *filename = NULL;
        char *tok;
 
+       if (!file) {
+               return NT_STATUS_OK;
+       }
+
        /* scroll through the file until we have the part
           beyond archi_table.short_archi */
        p = file;
@@ -533,29 +512,27 @@ static NTSTATUS net_copy_driverfile(struct net_context *c,
                }
        }
 
+       if (version == NULL || filename == NULL) {
+               return NT_STATUS_UNSUCCESSFUL;
+       }
+
        /* build source file name */
-       if (asprintf(&src_name, "\\%s\\%s\\%s", short_archi, version, filename) < 0 )
+       src_name = talloc_asprintf(mem_ctx, "\\%s\\%s\\%s",
+                                  short_archi, version, filename);
+       if (src_name == NULL) {
                return NT_STATUS_NO_MEMORY;
-
+       }
 
        /* create destination file name */
-       if (asprintf(&dst_name, "\\%s\\%s", short_archi, filename) < 0 )
-                return NT_STATUS_NO_MEMORY;
+       dst_name = talloc_asprintf(mem_ctx, "\\%s\\%s", short_archi, filename);
+       if (dst_name == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
 
 
        /* finally copy the file */
-       nt_status = net_copy_file(c, mem_ctx, cli_share_src, cli_share_dst,
-                                 src_name, dst_name, false, false, false, true);
-       if (!NT_STATUS_IS_OK(nt_status))
-               goto out;
-
-       nt_status = NT_STATUS_OK;
-
-out:
-       SAFE_FREE(src_name);
-       SAFE_FREE(dst_name);
-
-       return nt_status;
+       return net_copy_file(c, mem_ctx, cli_share_src, cli_share_dst,
+                            src_name, dst_name, false, false, false, true);
 }
 
 /**
@@ -580,14 +557,14 @@ static NTSTATUS check_arch_dir(struct cli_state *cli_share, const char *short_ar
        DEBUG(10,("creating print-driver dir for architecture: %s\n",
                short_archi));
 
-       if (!cli_mkdir(cli_share, dir)) {
+       if (!NT_STATUS_IS_OK(cli_mkdir(cli_share, dir))) {
                 DEBUG(1,("cannot create directory %s: %s\n",
                          dir, cli_errstr(cli_share)));
                 nt_status = NT_STATUS_NO_SUCH_FILE;
         }
 
-       if (!cli_chkpath(cli_share, dir)) {
-               d_fprintf(stderr, "cannot check %s: %s\n",
+       if (!NT_STATUS_IS_OK(cli_chkpath(cli_share, dir))) {
+               d_fprintf(stderr, _("cannot check %s: %s\n"),
                        dir, cli_errstr(cli_share));
                goto out;
        }
@@ -617,67 +594,48 @@ static NTSTATUS copy_print_driver_3(struct net_context *c,
                    TALLOC_CTX *mem_ctx,
                    struct cli_state *cli_share_src,
                    struct cli_state *cli_share_dst,
-                   const char *short_archi, DRIVER_INFO_3 *i1)
+                   const char *short_archi,
+                   struct spoolss_DriverInfo3 *r)
 {
        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
-       int length = 0;
-       bool valid = true;
-
-       fstring name = "";
-       fstring driverpath = "";
-       fstring datafile = "";
-       fstring configfile = "";
-       fstring helpfile = "";
-       fstring dependentfiles = "";
+       int i;
 
-       if (i1 == NULL)
+       if (r == NULL) {
                return nt_status;
-
-       rpcstr_pull(name, i1->name.buffer, sizeof(name), -1, STR_TERMINATE);
-       rpcstr_pull(driverpath, i1->driverpath.buffer, sizeof(driverpath), -1, STR_TERMINATE);
-       rpcstr_pull(datafile, i1->datafile.buffer, sizeof(datafile), -1, STR_TERMINATE);
-       rpcstr_pull(configfile, i1->configfile.buffer, sizeof(configfile), -1, STR_TERMINATE);
-       rpcstr_pull(helpfile, i1->helpfile.buffer, sizeof(helpfile), -1, STR_TERMINATE);
-
+       }
 
        if (c->opt_verbose)
-               d_printf("copying driver: [%s], for architecture: [%s], version: [%d]\n",
-                         name, short_archi, i1->version);
+               d_printf(_("copying driver: [%s], for architecture: [%s], "
+                          "version: [%d]\n"),
+                         r->driver_name, short_archi, r->version);
 
        nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
-               driverpath, short_archi);
+               r->driver_path, short_archi);
        if (!NT_STATUS_IS_OK(nt_status))
                return nt_status;
 
        nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
-               datafile, short_archi);
+               r->data_file, short_archi);
        if (!NT_STATUS_IS_OK(nt_status))
                return nt_status;
 
        nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
-               configfile, short_archi);
+               r->config_file, short_archi);
        if (!NT_STATUS_IS_OK(nt_status))
                return nt_status;
 
        nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
-               helpfile, short_archi);
+               r->help_file, short_archi);
        if (!NT_STATUS_IS_OK(nt_status))
                return nt_status;
 
-       while (valid) {
-
-               rpcstr_pull(dependentfiles, i1->dependentfiles+length, sizeof(dependentfiles), -1, STR_TERMINATE);
-               length += strlen(dependentfiles)+1;
+       for (i=0; r->dependent_files[i] != NULL; i++) {
 
-               if (strlen(dependentfiles) > 0) {
-
-                       nt_status = net_copy_driverfile(c, mem_ctx,
-                                       cli_share_src, cli_share_dst,
-                                       dependentfiles, short_archi);
-                       if (!NT_STATUS_IS_OK(nt_status))
-                               return nt_status;
-               } else {
-                       valid = false;
+               nt_status = net_copy_driverfile(c, mem_ctx,
+                               cli_share_src, cli_share_dst,
+                               r->dependent_files[i], short_archi);
+               if (!NT_STATUS_IS_OK(nt_status)) {
+                       return nt_status;
                }
        }
 
@@ -699,19 +657,24 @@ static NTSTATUS copy_print_driver_3(struct net_context *c,
 static bool net_spoolss_enum_printers(struct rpc_pipe_client *pipe_hnd,
                                        TALLOC_CTX *mem_ctx,
                                        char *name,
-                                       uint32 flags,
-                                       uint32 level,
-                                       uint32 *num_printers,
-                                       PRINTER_INFO_CTR *ctr)
+                                       uint32_t flags,
+                                       uint32_t level,
+                                       uint32_t *num_printers,
+                                       union spoolss_PrinterInfo **info)
 {
        WERROR result;
 
        /* enum printers */
-       result = rpccli_spoolss_enum_printers(pipe_hnd, mem_ctx, name, flags,
-               level, num_printers, ctr);
 
+       result = rpccli_spoolss_enumprinters(pipe_hnd, mem_ctx,
+                                            flags,
+                                            name,
+                                            level,
+                                            0,
+                                            num_printers,
+                                            info);
        if (!W_ERROR_IS_OK(result)) {
-               printf("cannot enum printers: %s\n", win_errstr(result));
+               printf(_("cannot enum printers: %s\n"), win_errstr(result));
                return false;
        }
 
@@ -721,9 +684,9 @@ static bool net_spoolss_enum_printers(struct rpc_pipe_client *pipe_hnd,
 static bool net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd,
                                        TALLOC_CTX *mem_ctx,
                                        const char *printername,
-                                       uint32 access_required,
+                                       uint32_t access_required,
                                        const char *username,
-                                       POLICY_HND *hnd)
+                                       struct policy_handle *hnd)
 {
        WERROR result;
        fstring printername2;
@@ -736,19 +699,22 @@ static bool net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd,
                pipe_hnd->srv_name_slash, username, printername2, access_required));
 
        /* open printer */
-       result = rpccli_spoolss_open_printer_ex(pipe_hnd, mem_ctx, printername2,
-                       "", access_required,
-                       pipe_hnd->srv_name_slash, username, hnd);
+       result = rpccli_spoolss_openprinter_ex(pipe_hnd, mem_ctx,
+                                              printername2,
+                                              access_required,
+                                              hnd);
 
        /* be more verbose */
        if (W_ERROR_V(result) == W_ERROR_V(WERR_ACCESS_DENIED)) {
-               d_fprintf(stderr, "no access to printer [%s] on [%s] for user [%s] granted\n",
+               d_fprintf(stderr,
+                       _("no access to printer [%s] on [%s] for user [%s] "
+                         "granted\n"),
                        printername2, pipe_hnd->srv_name_slash, username);
                return false;
        }
 
        if (!W_ERROR_IS_OK(result)) {
-               d_fprintf(stderr, "cannot open printer %s on server %s: %s\n",
+               d_fprintf(stderr,_("cannot open printer %s on server %s: %s\n"),
                        printername2, pipe_hnd->srv_name_slash, win_errstr(result));
                return false;
        }
@@ -761,17 +727,20 @@ static bool net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd,
 
 static bool net_spoolss_getprinter(struct rpc_pipe_client *pipe_hnd,
                                TALLOC_CTX *mem_ctx,
-                               POLICY_HND *hnd,
-                               uint32 level,
-                               PRINTER_INFO_CTR *ctr)
+                               struct policy_handle *hnd,
+                               uint32_t level,
+                               union spoolss_PrinterInfo *info)
 {
        WERROR result;
 
        /* getprinter call */
-       result = rpccli_spoolss_getprinter(pipe_hnd, mem_ctx, hnd, level, ctr);
-
+       result = rpccli_spoolss_getprinter(pipe_hnd, mem_ctx,
+                                          hnd,
+                                          level,
+                                          0, /* offered */
+                                          info);
        if (!W_ERROR_IS_OK(result)) {
-               printf("cannot get printer-info: %s\n", win_errstr(result));
+               printf(_("cannot get printer-info: %s\n"), win_errstr(result));
                return false;
        }
 
@@ -780,17 +749,80 @@ static bool net_spoolss_getprinter(struct rpc_pipe_client *pipe_hnd,
 
 static bool net_spoolss_setprinter(struct rpc_pipe_client *pipe_hnd,
                                TALLOC_CTX *mem_ctx,
-                               POLICY_HND *hnd,
-                               uint32 level,
-                               PRINTER_INFO_CTR *ctr)
+                               struct policy_handle *hnd,
+                               uint32_t level,
+                               union spoolss_PrinterInfo *info)
 {
        WERROR result;
+       NTSTATUS status;
+       struct spoolss_SetPrinterInfoCtr info_ctr;
+       struct spoolss_SetPrinterInfo2 info2;
+       struct spoolss_DevmodeContainer devmode_ctr;
+       struct sec_desc_buf secdesc_ctr;
+
+       ZERO_STRUCT(devmode_ctr);
+       ZERO_STRUCT(secdesc_ctr);
 
        /* setprinter call */
-       result = rpccli_spoolss_setprinter(pipe_hnd, mem_ctx, hnd, level, ctr, 0);
+
+       info_ctr.level = level;
+       switch (level) {
+       case 0:
+               info_ctr.info.info0 = (struct spoolss_SetPrinterInfo0 *)
+                       (void *)&info->info0;
+               break;
+       case 1:
+               info_ctr.info.info1 = (struct spoolss_SetPrinterInfo1 *)
+                       (void *)&info->info1;
+               break;
+       case 2:
+               spoolss_printerinfo2_to_setprinterinfo2(&info->info2, &info2);
+               info_ctr.info.info2 = &info2;
+               break;
+       case 3:
+               info_ctr.info.info3 = (struct spoolss_SetPrinterInfo3 *)
+                       (void *)&info->info3;
+               break;
+       case 4:
+               info_ctr.info.info4 = (struct spoolss_SetPrinterInfo4 *)
+                       (void *)&info->info4;
+               break;
+       case 5:
+               info_ctr.info.info5 = (struct spoolss_SetPrinterInfo5 *)
+                       (void *)&info->info5;
+               break;
+       case 6:
+               info_ctr.info.info6 = (struct spoolss_SetPrinterInfo6 *)
+                       (void *)&info->info6;
+               break;
+       case 7:
+               info_ctr.info.info7 = (struct spoolss_SetPrinterInfo7 *)
+                       (void *)&info->info7;
+               break;
+#if 0 /* FIXME GD */
+       case 8:
+               info_ctr.info.info8 = (struct spoolss_SetPrinterInfo8 *)
+                       (void *)&info->info8;
+               break;
+       case 9:
+               info_ctr.info.info9 = (struct spoolss_SetPrinterInfo9 *)
+                       (void *)&info->info9;
+               break;
+#endif
+       default:
+               break; /* FIXME */
+       }
+
+       status = rpccli_spoolss_SetPrinter(pipe_hnd, mem_ctx,
+                                          hnd,
+                                          &info_ctr,
+                                          &devmode_ctr,
+                                          &secdesc_ctr,
+                                          0, /* command */
+                                          &result);
 
        if (!W_ERROR_IS_OK(result)) {
-               printf("cannot set printer-info: %s\n", win_errstr(result));
+               printf(_("cannot set printer-info: %s\n"), win_errstr(result));
                return false;
        }
 
@@ -799,17 +831,28 @@ static bool net_spoolss_setprinter(struct rpc_pipe_client *pipe_hnd,
 
 
 static bool net_spoolss_setprinterdata(struct rpc_pipe_client *pipe_hnd,
-                                       TALLOC_CTX *mem_ctx,
-                                       POLICY_HND *hnd,
-                                       REGISTRY_VALUE *value)
+                                      TALLOC_CTX *mem_ctx,
+                                      struct policy_handle *hnd,
+                                      const char *value_name,
+                                      enum winreg_Type type,
+                                      uint8_t *data,
+                                      uint32_t offered)
 {
        WERROR result;
+       NTSTATUS status;
 
        /* setprinterdata call */
-       result = rpccli_spoolss_setprinterdata(pipe_hnd, mem_ctx, hnd, value);
+       status = rpccli_spoolss_SetPrinterData(pipe_hnd, mem_ctx,
+                                              hnd,
+                                              value_name,
+                                              type,
+                                              data,
+                                              offered,
+                                              &result);
 
        if (!W_ERROR_IS_OK(result)) {
-               printf ("unable to set printerdata: %s\n", win_errstr(result));
+               printf (_("unable to set printerdata: %s\n"),
+                       win_errstr(result));
                return false;
        }
 
@@ -819,17 +862,17 @@ static bool net_spoolss_setprinterdata(struct rpc_pipe_client *pipe_hnd,
 
 static bool net_spoolss_enumprinterkey(struct rpc_pipe_client *pipe_hnd,
                                        TALLOC_CTX *mem_ctx,
-                                       POLICY_HND *hnd,
+                                       struct policy_handle *hnd,
                                        const char *keyname,
-                                       uint16 **keylist)
+                                       const char ***keylist)
 {
        WERROR result;
 
        /* enumprinterkey call */
-       result = rpccli_spoolss_enumprinterkey(pipe_hnd, mem_ctx, hnd, keyname, keylist, NULL);
+       result = rpccli_spoolss_enumprinterkey(pipe_hnd, mem_ctx, hnd, keyname, keylist, 0);
 
        if (!W_ERROR_IS_OK(result)) {
-               printf("enumprinterkey failed: %s\n", win_errstr(result));
+               printf(_("enumprinterkey failed: %s\n"), win_errstr(result));
                return false;
        }
 
@@ -838,18 +881,24 @@ static bool net_spoolss_enumprinterkey(struct rpc_pipe_client *pipe_hnd,
 
 static bool net_spoolss_enumprinterdataex(struct rpc_pipe_client *pipe_hnd,
                                        TALLOC_CTX *mem_ctx,
-                                       uint32 offered,
-                                       POLICY_HND *hnd,
+                                       uint32_t offered,
+                                       struct policy_handle *hnd,
                                        const char *keyname,
-                                       REGVAL_CTR *ctr)
+                                       uint32_t *count,
+                                       struct spoolss_PrinterEnumValues **info)
 {
        WERROR result;
 
        /* enumprinterdataex call */
-       result = rpccli_spoolss_enumprinterdataex(pipe_hnd, mem_ctx, hnd, keyname, ctr);
+       result = rpccli_spoolss_enumprinterdataex(pipe_hnd, mem_ctx,
+                                                 hnd,
+                                                 keyname,
+                                                 0, /* offered */
+                                                 count,
+                                                 info);
 
        if (!W_ERROR_IS_OK(result)) {
-               printf("enumprinterdataex failed: %s\n", win_errstr(result));
+               printf(_("enumprinterdataex failed: %s\n"), win_errstr(result));
                return false;
        }
 
@@ -859,18 +908,26 @@ static bool net_spoolss_enumprinterdataex(struct rpc_pipe_client *pipe_hnd,
 
 static bool net_spoolss_setprinterdataex(struct rpc_pipe_client *pipe_hnd,
                                        TALLOC_CTX *mem_ctx,
-                                       POLICY_HND *hnd,
-                                       char *keyname,
-                                       REGISTRY_VALUE *value)
+                                       struct policy_handle *hnd,
+                                       const char *keyname,
+                                       struct regval_blob *value)
 {
        WERROR result;
+       NTSTATUS status;
 
        /* setprinterdataex call */
-       result = rpccli_spoolss_setprinterdataex(pipe_hnd, mem_ctx, hnd,
-                                             keyname, value);
+       status = rpccli_spoolss_SetPrinterDataEx(pipe_hnd, mem_ctx,
+                                                hnd,
+                                                keyname,
+                                                regval_name(value),
+                                                regval_type(value),
+                                                regval_data_p(value),
+                                                regval_size(value),
+                                                &result);
 
        if (!W_ERROR_IS_OK(result)) {
-               printf("could not set printerdataex: %s\n", win_errstr(result));
+               printf(_("could not set printerdataex: %s\n"),
+                      win_errstr(result));
                return false;
        }
 
@@ -879,18 +936,22 @@ static bool net_spoolss_setprinterdataex(struct rpc_pipe_client *pipe_hnd,
 
 static bool net_spoolss_enumforms(struct rpc_pipe_client *pipe_hnd,
                                TALLOC_CTX *mem_ctx,
-                               POLICY_HND *hnd,
+                               struct policy_handle *hnd,
                                int level,
-                               uint32 *num_forms,
-                               FORM_1 **forms)
+                               uint32_t *num_forms,
+                               union spoolss_FormInfo **forms)
 {
        WERROR result;
 
        /* enumforms call */
-       result = rpccli_spoolss_enumforms(pipe_hnd, mem_ctx, hnd, level, num_forms, forms);
-
+       result = rpccli_spoolss_enumforms(pipe_hnd, mem_ctx,
+                                         hnd,
+                                         level,
+                                         0,
+                                         num_forms,
+                                         forms);
        if (!W_ERROR_IS_OK(result)) {
-               printf("could not enum forms: %s\n", win_errstr(result));
+               printf(_("could not enum forms: %s\n"), win_errstr(result));
                return false;
        }
 
@@ -899,19 +960,22 @@ static bool net_spoolss_enumforms(struct rpc_pipe_client *pipe_hnd,
 
 static bool net_spoolss_enumprinterdrivers (struct rpc_pipe_client *pipe_hnd,
                                        TALLOC_CTX *mem_ctx,
-                                       uint32 level, const char *env,
-                                       uint32 *num_drivers,
-                                       PRINTER_DRIVER_CTR *ctr)
+                                       uint32_t level, const char *env,
+                                       uint32_t *count,
+                                       union spoolss_DriverInfo **info)
 {
        WERROR result;
 
        /* enumprinterdrivers call */
-       result = rpccli_spoolss_enumprinterdrivers(
-                       pipe_hnd, mem_ctx, level,
-                       env, num_drivers, ctr);
-
+       result = rpccli_spoolss_enumprinterdrivers(pipe_hnd, mem_ctx,
+                                                  pipe_hnd->srv_name_slash,
+                                                  env,
+                                                  level,
+                                                  0,
+                                                  count,
+                                                  info);
        if (!W_ERROR_IS_OK(result)) {
-               printf("cannot enum drivers: %s\n", win_errstr(result));
+               printf(_("cannot enum drivers: %s\n"), win_errstr(result));
                return false;
        }
 
@@ -920,23 +984,32 @@ static bool net_spoolss_enumprinterdrivers (struct rpc_pipe_client *pipe_hnd,
 
 static bool net_spoolss_getprinterdriver(struct rpc_pipe_client *pipe_hnd,
                             TALLOC_CTX *mem_ctx,
-                            POLICY_HND *hnd, uint32 level,
+                            struct policy_handle *hnd, uint32_t level,
                             const char *env, int version,
-                            PRINTER_DRIVER_CTR *ctr)
+                            union spoolss_DriverInfo *info)
 {
        WERROR result;
+       uint32_t server_major_version;
+       uint32_t server_minor_version;
 
        /* getprinterdriver call */
-       result = rpccli_spoolss_getprinterdriver(
-                       pipe_hnd, mem_ctx, hnd, level,
-                       env, version, ctr);
-
+       result = rpccli_spoolss_getprinterdriver2(pipe_hnd, mem_ctx,
+                                                 hnd,
+                                                 env,
+                                                 level,
+                                                 0,
+                                                 version,
+                                                 2,
+                                                 info,
+                                                 &server_major_version,
+                                                 &server_minor_version);
        if (!W_ERROR_IS_OK(result)) {
                DEBUG(1,("cannot get driver (for architecture: %s): %s\n",
                        env, win_errstr(result)));
                if (W_ERROR_V(result) != W_ERROR_V(WERR_UNKNOWN_PRINTER_DRIVER) &&
                    W_ERROR_V(result) != W_ERROR_V(WERR_INVALID_ENVIRONMENT)) {
-                       printf("cannot get driver: %s\n", win_errstr(result));
+                       printf(_("cannot get driver: %s\n"),
+                              win_errstr(result));
                }
                return false;
        }
@@ -946,21 +1019,41 @@ static bool net_spoolss_getprinterdriver(struct rpc_pipe_client *pipe_hnd,
 
 
 static bool net_spoolss_addprinterdriver(struct rpc_pipe_client *pipe_hnd,
-                            TALLOC_CTX *mem_ctx, uint32 level,
-                            PRINTER_DRIVER_CTR *ctr)
+                            TALLOC_CTX *mem_ctx, uint32_t level,
+                            union spoolss_DriverInfo *info)
 {
        WERROR result;
+       NTSTATUS status;
+       struct spoolss_AddDriverInfoCtr info_ctr;
 
-       /* addprinterdriver call */
-       result = rpccli_spoolss_addprinterdriver(pipe_hnd, mem_ctx, level, ctr);
+       info_ctr.level = level;
 
+       switch (level) {
+       case 2:
+               info_ctr.info.info2 = (struct spoolss_AddDriverInfo2 *)
+                       (void *)&info->info2;
+               break;
+       case 3:
+               info_ctr.info.info3 = (struct spoolss_AddDriverInfo3 *)
+                       (void *)&info->info3;
+               break;
+       default:
+               printf(_("unsupported info level: %d\n"), level);
+               return false;
+       }
+
+       /* addprinterdriver call */
+       status = rpccli_spoolss_AddPrinterDriver(pipe_hnd, mem_ctx,
+                                                pipe_hnd->srv_name_slash,
+                                                &info_ctr,
+                                                &result);
        /* be more verbose */
        if (W_ERROR_V(result) == W_ERROR_V(WERR_ACCESS_DENIED)) {
-               printf("You are not allowed to add drivers\n");
+               printf(_("You are not allowed to add drivers\n"));
                return false;
        }
        if (!W_ERROR_IS_OK(result)) {
-               printf("cannot add driver: %s\n", win_errstr(result));
+               printf(_("cannot add driver: %s\n"), win_errstr(result));
                return false;
        }
 
@@ -968,7 +1061,7 @@ static bool net_spoolss_addprinterdriver(struct rpc_pipe_client *pipe_hnd,
 }
 
 /**
- * abstraction function to get uint32 num_printers and PRINTER_INFO_CTR ctr
+ * abstraction function to get uint32_t num_printers and PRINTER_INFO_CTR ctr
  * for a single printer or for all printers depending on argc/argv
  **/
 
@@ -977,24 +1070,22 @@ static bool get_printer_info(struct rpc_pipe_client *pipe_hnd,
                        int level,
                        int argc,
                        const char **argv,
-                       uint32 *num_printers,
-                       PRINTER_INFO_CTR *ctr)
+                       uint32_t *num_printers,
+                       union spoolss_PrinterInfo **info_p)
 {
-
-       POLICY_HND hnd;
+       struct policy_handle hnd;
 
        /* no arguments given, enumerate all printers */
        if (argc == 0) {
 
                if (!net_spoolss_enum_printers(pipe_hnd, mem_ctx, NULL,
                                PRINTER_ENUM_LOCAL|PRINTER_ENUM_SHARED,
-                               level, num_printers, ctr))
+                               level, num_printers, info_p))
                        return false;
 
                goto out;
        }
 
-
        /* argument given, get a single printer by name */
        if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, argv[0],
                                         MAXIMUM_ALLOWED_ACCESS,
@@ -1002,7 +1093,7 @@ static bool get_printer_info(struct rpc_pipe_client *pipe_hnd,
                                         &hnd))
                return false;
 
-       if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, ctr)) {
+       if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, *info_p)) {
                rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd, NULL);
                return false;
        }
@@ -1036,7 +1127,7 @@ out:
  **/
 
 NTSTATUS rpc_printer_list_internals(struct net_context *c,
-                                       const DOM_SID *domain_sid,
+                                       const struct dom_sid *domain_sid,
                                        const char *domain_name,
                                        struct cli_state *cli,
                                        struct rpc_pipe_client *pipe_hnd,
@@ -1045,31 +1136,24 @@ NTSTATUS rpc_printer_list_internals(struct net_context *c,
                                        const char **argv)
 {
        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
-       uint32 i, num_printers;
-       uint32 level = 2;
-       char *printername, *sharename;
-       PRINTER_INFO_CTR ctr;
+       uint32_t i, num_printers;
+       uint32_t level = 2;
+       const char *printername, *sharename;
+       union spoolss_PrinterInfo *info;
 
        printf("listing printers\n");
 
-       if (!get_printer_info(pipe_hnd, mem_ctx, level, argc, argv, &num_printers, &ctr))
+       if (!get_printer_info(pipe_hnd, mem_ctx, level, argc, argv, &num_printers, &info))
                return nt_status;
 
        for (i = 0; i < num_printers; i++) {
+
                /* do some initialization */
-               rpcstr_pull_talloc(mem_ctx,
-                               &printername,
-                               ctr.printers_2[i].printername.buffer,
-                               -1,
-                               STR_TERMINATE);
-               rpcstr_pull_talloc(mem_ctx,
-                               &sharename,
-                               ctr.printers_2[i].sharename.buffer,
-                               -1,
-                               STR_TERMINATE);
+               printername = info[i].info2.printername;
+               sharename = info[i].info2.sharename;
 
                if (printername && sharename) {
-                       d_printf("printer %d: %s, shared as: %s\n",
+                       d_printf(_("printer %d: %s, shared as: %s\n"),
                                i+1, printername, sharename);
                }
        }
@@ -1095,7 +1179,7 @@ NTSTATUS rpc_printer_list_internals(struct net_context *c,
  **/
 
 NTSTATUS rpc_printer_driver_list_internals(struct net_context *c,
-                                               const DOM_SID *domain_sid,
+                                               const struct dom_sid *domain_sid,
                                                const char *domain_name,
                                                struct cli_state *cli,
                                                struct rpc_pipe_client *pipe_hnd,
@@ -1104,40 +1188,39 @@ NTSTATUS rpc_printer_driver_list_internals(struct net_context *c,
                                                const char **argv)
 {
        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
-       uint32 i;
-       uint32 level = 3;
-       PRINTER_DRIVER_CTR drv_ctr_enum;
+       uint32_t i;
+       uint32_t level = 3;
+       union spoolss_DriverInfo *info;
        int d;
 
-       ZERO_STRUCT(drv_ctr_enum);
-
-       printf("listing printer-drivers\n");
+       printf(_("listing printer-drivers\n"));
 
         for (i=0; archi_table[i].long_archi!=NULL; i++) {
 
-               uint32 num_drivers;
+               uint32_t num_drivers;
 
                /* enum remote drivers */
                if (!net_spoolss_enumprinterdrivers(pipe_hnd, mem_ctx, level,
                                archi_table[i].long_archi,
-                               &num_drivers, &drv_ctr_enum)) {
+                               &num_drivers, &info)) {
                        nt_status = NT_STATUS_UNSUCCESSFUL;
                        goto done;
                }
 
                if (num_drivers == 0) {
-                       d_printf ("no drivers found on server for architecture: [%s].\n",
+                       d_printf(_("no drivers found on server for "
+                                  "architecture: [%s].\n"),
                                archi_table[i].long_archi);
                        continue;
                }
 
-               d_printf("got %d printer-drivers for architecture: [%s]\n",
+               d_printf(_("got %d printer-drivers for architecture: [%s]\n"),
                        num_drivers, archi_table[i].long_archi);
 
 
                /* do something for all drivers for architecture */
                for (d = 0; d < num_drivers; d++) {
-                       display_print_driver_3(&(drv_ctr_enum.info3[d]));
+                       display_print_driver3(&info[d].info3);
                }
        }
 
@@ -1165,33 +1248,29 @@ static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_
                                        TALLOC_CTX *mem_ctx,
                                        int argc,
                                        const char **argv,
-                                       uint32 action)
+                                       uint32_t action)
 {
        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
-       uint32 i, num_printers;
-       uint32 level = 7;
-       char *printername, *sharename;
-       PRINTER_INFO_CTR ctr, ctr_pub;
-       POLICY_HND hnd;
-       bool got_hnd = false;
+       uint32_t i, num_printers;
+       uint32_t level = 7;
+       const char *printername, *sharename;
+       union spoolss_PrinterInfo *info_enum;
+       union spoolss_PrinterInfo info;
+       struct spoolss_SetPrinterInfoCtr info_ctr;
+       struct spoolss_DevmodeContainer devmode_ctr;
+       struct sec_desc_buf secdesc_ctr;
+       struct policy_handle hnd;
        WERROR result;
        const char *action_str;
 
-       if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &ctr))
+       if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &info_enum))
                return nt_status;
 
        for (i = 0; i < num_printers; i++) {
+
                /* do some initialization */
-               rpcstr_pull_talloc(mem_ctx,
-                               &printername,
-                               ctr.printers_2[i].printername.buffer,
-                               -1,
-                               STR_TERMINATE);
-               rpcstr_pull_talloc(mem_ctx,
-                               &sharename,
-                               ctr.printers_2[i].sharename.buffer,
-                               -1,
-                               STR_TERMINATE);
+               printername = info_enum[i].info2.printername;
+               sharename = info_enum[i].info2.sharename;
                if (!printername || !sharename) {
                        goto done;
                }
@@ -1201,51 +1280,64 @@ static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_
                        PRINTER_ALL_ACCESS, pipe_hnd->auth->user_name, &hnd))
                        goto done;
 
-               got_hnd = true;
-
                /* check for existing dst printer */
-               if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &ctr_pub))
+               if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &info))
                        goto done;
 
                /* check action and set string */
                switch (action) {
-               case SPOOL_DS_PUBLISH:
-                       action_str = "published";
+               case DSPRINT_PUBLISH:
+                       action_str = N_("published");
                        break;
-               case SPOOL_DS_UPDATE:
-                       action_str = "updated";
+               case DSPRINT_UPDATE:
+                       action_str = N_("updated");
                        break;
-               case SPOOL_DS_UNPUBLISH:
-                       action_str = "unpublished";
+               case DSPRINT_UNPUBLISH:
+                       action_str = N_("unpublished");
                        break;
                default:
-                       action_str = "unknown action";
-                       printf("unkown action: %d\n", action);
+                       action_str = N_("unknown action");
+                       printf(_("unkown action: %d\n"), action);
                        break;
                }
 
-               ctr_pub.printers_7->action = action;
+               info.info7.action = action;
+               info_ctr.level = 7;
+               info_ctr.info.info7 = (struct spoolss_SetPrinterInfo7 *)
+                       (void *)&info.info7;
+
+               ZERO_STRUCT(devmode_ctr);
+               ZERO_STRUCT(secdesc_ctr);
+
+               nt_status = rpccli_spoolss_SetPrinter(pipe_hnd, mem_ctx,
+                                                     &hnd,
+                                                     &info_ctr,
+                                                     &devmode_ctr,
+                                                     &secdesc_ctr,
+                                                     0, /* command */
+                                                     &result);
 
-               result = rpccli_spoolss_setprinter(pipe_hnd, mem_ctx, &hnd, level, &ctr_pub, 0);
                if (!W_ERROR_IS_OK(result) && (W_ERROR_V(result) != W_ERROR_V(WERR_IO_PENDING))) {
-                       printf("cannot set printer-info: %s\n", win_errstr(result));
+                       printf(_("cannot set printer-info: %s\n"),
+                              win_errstr(result));
                        goto done;
                }
 
-               printf("successfully %s printer %s in Active Directory\n", action_str, sharename);
+               printf(_("successfully %s printer %s in Active Directory\n"),
+                      action_str, sharename);
        }
 
        nt_status = NT_STATUS_OK;
 
 done:
-       if (got_hnd)
+       if (is_valid_policy_hnd(&hnd))
                rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd, NULL);
 
        return nt_status;
 }
 
 NTSTATUS rpc_printer_publish_publish_internals(struct net_context *c,
-                                               const DOM_SID *domain_sid,
+                                               const struct dom_sid *domain_sid,
                                                const char *domain_name,
                                                struct cli_state *cli,
                                                struct rpc_pipe_client *pipe_hnd,
@@ -1253,11 +1345,11 @@ NTSTATUS rpc_printer_publish_publish_internals(struct net_context *c,
                                                int argc,
                                                const char **argv)
 {
-       return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, SPOOL_DS_PUBLISH);
+       return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, DSPRINT_PUBLISH);
 }
 
 NTSTATUS rpc_printer_publish_unpublish_internals(struct net_context *c,
-                                               const DOM_SID *domain_sid,
+                                               const struct dom_sid *domain_sid,
                                                const char *domain_name,
                                                struct cli_state *cli,
                                                struct rpc_pipe_client *pipe_hnd,
@@ -1265,11 +1357,11 @@ NTSTATUS rpc_printer_publish_unpublish_internals(struct net_context *c,
                                                int argc,
                                                const char **argv)
 {
-       return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, SPOOL_DS_UNPUBLISH);
+       return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, DSPRINT_UNPUBLISH);
 }
 
 NTSTATUS rpc_printer_publish_update_internals(struct net_context *c,
-                                               const DOM_SID *domain_sid,
+                                               const struct dom_sid *domain_sid,
                                                const char *domain_name,
                                                struct cli_state *cli,
                                                struct rpc_pipe_client *pipe_hnd,
@@ -1277,7 +1369,7 @@ NTSTATUS rpc_printer_publish_update_internals(struct net_context *c,
                                                int argc,
                                                const char **argv)
 {
-       return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, SPOOL_DS_UPDATE);
+       return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, DSPRINT_UPDATE);
 }
 
 /**
@@ -1298,7 +1390,7 @@ NTSTATUS rpc_printer_publish_update_internals(struct net_context *c,
  **/
 
 NTSTATUS rpc_printer_publish_list_internals(struct net_context *c,
-                                               const DOM_SID *domain_sid,
+                                               const struct dom_sid *domain_sid,
                                                const char *domain_name,
                                                struct cli_state *cli,
                                                struct rpc_pipe_client *pipe_hnd,
@@ -1307,32 +1399,23 @@ NTSTATUS rpc_printer_publish_list_internals(struct net_context *c,
                                                const char **argv)
 {
        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
-       uint32 i, num_printers;
-       uint32 level = 7;
-       char *printername, *sharename;
-       char *guid;
-       PRINTER_INFO_CTR ctr, ctr_pub;
-       POLICY_HND hnd;
-       bool got_hnd = false;
+       uint32_t i, num_printers;
+       uint32_t level = 7;
+       const char *printername, *sharename;
+       union spoolss_PrinterInfo *info_enum;
+       union spoolss_PrinterInfo info;
+       struct policy_handle hnd;
        int state;
 
-       if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &ctr))
+       if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &info_enum))
                return nt_status;
 
        for (i = 0; i < num_printers; i++) {
-               ZERO_STRUCT(ctr_pub);
 
                /* do some initialization */
-               rpcstr_pull_talloc(mem_ctx,
-                               &printername,
-                               ctr.printers_2[i].printername.buffer,
-                               -1,
-                               STR_TERMINATE);
-               rpcstr_pull_talloc(mem_ctx,
-                               &sharename,
-                               ctr.printers_2[i].sharename.buffer,
-                               -1,
-                               STR_TERMINATE);
+               printername = info_enum[i].info2.printername;
+               sharename = info_enum[i].info2.sharename;
+
                if (!printername || !sharename) {
                        goto done;
                }
@@ -1342,36 +1425,32 @@ NTSTATUS rpc_printer_publish_list_internals(struct net_context *c,
                        PRINTER_ALL_ACCESS, cli->user_name, &hnd))
                        goto done;
 
-               got_hnd = true;
-
                /* check for existing dst printer */
-               if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &ctr_pub))
+               if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &info))
                        goto done;
 
-               rpcstr_pull_talloc(mem_ctx,
-                               &guid,
-                               ctr_pub.printers_7->guid.buffer,
-                               -1,
-                               STR_TERMINATE);
-               if (!guid) {
+               if (!info.info7.guid) {
                        goto done;
                }
-               state = ctr_pub.printers_7->action;
+               state = info.info7.action;
                switch (state) {
-                       case SPOOL_DS_PUBLISH:
-                               printf("printer [%s] is published", sharename);
+                       case DSPRINT_PUBLISH:
+                               printf(_("printer [%s] is published"),
+                                      sharename);
                                if (c->opt_verbose)
-                                       printf(", guid: %s", guid);
+                                       printf(_(", guid: %s"),info.info7.guid);
                                printf("\n");
                                break;
-                       case SPOOL_DS_UNPUBLISH:
-                               printf("printer [%s] is unpublished\n", sharename);
+                       case DSPRINT_UNPUBLISH:
+                               printf(_("printer [%s] is unpublished\n"),
+                                      sharename);
                                break;
-                       case SPOOL_DS_UPDATE:
-                               printf("printer [%s] is currently updating\n", sharename);
+                       case DSPRINT_UPDATE:
+                               printf(_("printer [%s] is currently updating\n"),
+                                      sharename);
                                break;
                        default:
-                               printf("unkown state: %d\n", state);
+                               printf(_("unkown state: %d\n"), state);
                                break;
                }
        }
@@ -1379,7 +1458,7 @@ NTSTATUS rpc_printer_publish_list_internals(struct net_context *c,
        nt_status = NT_STATUS_OK;
 
 done:
-       if (got_hnd)
+       if (is_valid_policy_hnd(&hnd))
                rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd, NULL);
 
        return nt_status;
@@ -1403,7 +1482,7 @@ done:
  **/
 
 NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c,
-                                               const DOM_SID *domain_sid,
+                                               const struct dom_sid *domain_sid,
                                                const char *domain_name,
                                                struct cli_state *cli,
                                                struct rpc_pipe_client *pipe_hnd,
@@ -1415,53 +1494,44 @@ NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c,
           convince jerry that we should add clientside setacls level 3 at least
        */
        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
-       uint32 i = 0;
-       uint32 num_printers;
-       uint32 level = 2;
-       char *printername, *sharename;
-       bool got_hnd_src = false;
-       bool got_hnd_dst = false;
+       uint32_t i = 0;
+       uint32_t num_printers;
+       uint32_t level = 2;
+       const char *printername, *sharename;
        struct rpc_pipe_client *pipe_hnd_dst = NULL;
-       POLICY_HND hnd_src, hnd_dst;
-       PRINTER_INFO_CTR ctr_src, ctr_dst, ctr_enum;
+       struct policy_handle hnd_src, hnd_dst;
+       union spoolss_PrinterInfo *info_enum;
        struct cli_state *cli_dst = NULL;
-
-       ZERO_STRUCT(ctr_src);
+       union spoolss_PrinterInfo info_src, info_dst;
 
        DEBUG(3,("copying printer ACLs\n"));
 
        /* connect destination PI_SPOOLSS */
        nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst,
-                                    &syntax_spoolss);
+                                    &ndr_table_spoolss.syntax_id);
        if (!NT_STATUS_IS_OK(nt_status))
                return nt_status;
 
 
        /* enum source printers */
-       if (!get_printer_info(pipe_hnd, mem_ctx, level, argc, argv, &num_printers, &ctr_enum)) {
+       if (!get_printer_info(pipe_hnd, mem_ctx, level, argc, argv, &num_printers, &info_enum)) {
                nt_status = NT_STATUS_UNSUCCESSFUL;
                goto done;
        }
 
        if (!num_printers) {
-               printf ("no printers found on server.\n");
+               printf (_("no printers found on server.\n"));
                nt_status = NT_STATUS_OK;
                goto done;
        }
 
        /* do something for all printers */
        for (i = 0; i < num_printers; i++) {
+
                /* do some initialization */
-               rpcstr_pull_talloc(mem_ctx,
-                               &printername,
-                               ctr_enum.printers_2[i].printername.buffer,
-                               -1,
-                               STR_TERMINATE);
-               rpcstr_pull_talloc(mem_ctx,
-                               &sharename,
-                               ctr_enum.printers_2[i].sharename.buffer,
-                               -1,
-                               STR_TERMINATE);
+               printername = info_enum[i].info2.printername;
+               sharename = info_enum[i].info2.sharename;
+
                if (!printername || !sharename) {
                        nt_status = NT_STATUS_UNSUCCESSFUL;
                        goto done;
@@ -1471,7 +1541,7 @@ NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c,
                   get any real NT_STATUS-codes anymore from now on */
                nt_status = NT_STATUS_UNSUCCESSFUL;
 
-               d_printf("migrating printer ACLs for:     [%s] / [%s]\n",
+               d_printf(_("migrating printer ACLs for:     [%s] / [%s]\n"),
                        printername, sharename);
 
                /* according to msdn you have specify these access-rights
@@ -1485,47 +1555,41 @@ NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c,
                        MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
                        goto done;
 
-               got_hnd_src = true;
-
                /* open dst printer handle */
                if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
                        PRINTER_ALL_ACCESS, cli_dst->user_name, &hnd_dst))
                        goto done;
 
-               got_hnd_dst = true;
-
                /* check for existing dst printer */
-               if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &ctr_dst))
+               if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &info_dst))
                        goto done;
 
                /* check for existing src printer */
-               if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd_src, 3, &ctr_src))
+               if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd_src, 3, &info_src))
                        goto done;
 
                /* Copy Security Descriptor */
 
                /* copy secdesc (info level 2) */
-               ctr_dst.printers_2->devmode = NULL;
-               ctr_dst.printers_2->secdesc = dup_sec_desc(mem_ctx, ctr_src.printers_3->secdesc);
+               info_dst.info2.devmode = NULL;
+               info_dst.info2.secdesc = dup_sec_desc(mem_ctx, info_src.info3.secdesc);
 
                if (c->opt_verbose)
-                       display_sec_desc(ctr_dst.printers_2->secdesc);
+                       display_sec_desc(info_dst.info2.secdesc);
 
-               if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &ctr_dst))
+               if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_dst))
                        goto done;
 
                DEBUGADD(1,("\tSetPrinter of SECDESC succeeded\n"));
 
 
                /* close printer handles here */
-               if (got_hnd_src) {
+               if (is_valid_policy_hnd(&hnd_src)) {
                        rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
-                       got_hnd_src = false;
                }
 
-               if (got_hnd_dst) {
+               if (is_valid_policy_hnd(&hnd_dst)) {
                        rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
-                       got_hnd_dst = false;
                }
 
        }
@@ -1534,11 +1598,11 @@ NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c,
 
 done:
 
-       if (got_hnd_src) {
+       if (is_valid_policy_hnd(&hnd_src)) {
                rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
        }
 
-       if (got_hnd_dst) {
+       if (is_valid_policy_hnd(&hnd_dst)) {
                rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
        }
 
@@ -1566,7 +1630,7 @@ done:
  **/
 
 NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
-                                               const DOM_SID *domain_sid,
+                                               const struct dom_sid *domain_sid,
                                                const char *domain_name,
                                                struct cli_state *cli,
                                                struct rpc_pipe_client *pipe_hnd,
@@ -1576,54 +1640,45 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
 {
        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
        WERROR result;
-       uint32 i, f;
-       uint32 num_printers;
-       uint32 level = 1;
-       char *printername, *sharename;
-       bool got_hnd_src = false;
-       bool got_hnd_dst = false;
+       uint32_t i, f;
+       uint32_t num_printers;
+       uint32_t level = 1;
+       const char *printername, *sharename;
        struct rpc_pipe_client *pipe_hnd_dst = NULL;
-       POLICY_HND hnd_src, hnd_dst;
-       PRINTER_INFO_CTR ctr_enum, ctr_dst;
-       uint32 num_forms;
-       FORM_1 *forms;
+       struct policy_handle hnd_src, hnd_dst;
+       union spoolss_PrinterInfo *info_enum;
+       union spoolss_PrinterInfo info_dst;
+       uint32_t num_forms;
+       union spoolss_FormInfo *forms;
        struct cli_state *cli_dst = NULL;
 
-       ZERO_STRUCT(ctr_enum);
-
        DEBUG(3,("copying forms\n"));
 
        /* connect destination PI_SPOOLSS */
        nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst,
-                                    &syntax_spoolss);
+                                    &ndr_table_spoolss.syntax_id);
        if (!NT_STATUS_IS_OK(nt_status))
                return nt_status;
 
        /* enum src printers */
-       if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &ctr_enum)) {
+       if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &info_enum)) {
                nt_status = NT_STATUS_UNSUCCESSFUL;
                goto done;
        }
 
        if (!num_printers) {
-               printf ("no printers found on server.\n");
+               printf (_("no printers found on server.\n"));
                nt_status = NT_STATUS_OK;
                goto done;
        }
 
        /* do something for all printers */
        for (i = 0; i < num_printers; i++) {
+
                /* do some initialization */
-               rpcstr_pull_talloc(mem_ctx,
-                               &printername,
-                               ctr_enum.printers_2[i].printername.buffer,
-                               -1,
-                               STR_TERMINATE);
-               rpcstr_pull_talloc(mem_ctx,
-                               &sharename,
-                               ctr_enum.printers_2[i].sharename.buffer,
-                               -1,
-                               STR_TERMINATE);
+               printername = info_enum[i].info2.printername;
+               sharename = info_enum[i].info2.sharename;
+
                if (!printername || !sharename) {
                        nt_status = NT_STATUS_UNSUCCESSFUL;
                        goto done;
@@ -1632,7 +1687,7 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
                   get any real NT_STATUS-codes anymore from now on */
                nt_status = NT_STATUS_UNSUCCESSFUL;
 
-               d_printf("migrating printer forms for:    [%s] / [%s]\n",
+               d_printf(_("migrating printer forms for:    [%s] / [%s]\n"),
                        printername, sharename);
 
 
@@ -1641,19 +1696,13 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
                        MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
                        goto done;
 
-               got_hnd_src = true;
-
-
                /* open dst printer handle */
                if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
                        PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst))
                        goto done;
 
-               got_hnd_dst = true;
-
-
                /* check for existing dst printer */
-               if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &ctr_dst))
+               if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &info_dst))
                        goto done;
 
                /* finally migrate forms */
@@ -1666,34 +1715,21 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
                for (f = 0; f < num_forms; f++) {
 
                        union spoolss_AddFormInfo info;
-                       struct spoolss_AddFormInfo1 info1;
-                       fstring form_name;
                        NTSTATUS status;
 
                        /* only migrate FORM_PRINTER types, according to jerry
                           FORM_BUILTIN-types are hard-coded in samba */
-                       if (forms[f].flag != FORM_PRINTER)
+                       if (forms[f].info1.flags != SPOOLSS_FORM_PRINTER)
                                continue;
 
-                       if (forms[f].name.buffer)
-                               rpcstr_pull(form_name, forms[f].name.buffer,
-                                       sizeof(form_name), -1, STR_TERMINATE);
-
                        if (c->opt_verbose)
-                               d_printf("\tmigrating form # %d [%s] of type [%d]\n",
-                                       f, form_name, forms[f].flag);
+                               d_printf(_("\tmigrating form # %d [%s] of type "
+                                          "[%d]\n"),
+                                       f, forms[f].info1.form_name,
+                                       forms[f].info1.flags);
 
-                       /* is there a more elegant way to do that ? */
-                       info1.flags             = FORM_PRINTER;
-                       info1.size.width        = forms[f].width;
-                       info1.size.height       = forms[f].length;
-                       info1.area.left         = forms[f].left;
-                       info1.area.top          = forms[f].top;
-                       info1.area.right        = forms[f].right;
-                       info1.area.bottom       = forms[f].bottom;
-                       info1.form_name         = form_name;
-
-                       info.info1 = &info1;
+                       info.info1 = (struct spoolss_AddFormInfo1 *)
+                               (void *)&forms[f].info1;
 
                        /* FIXME: there might be something wrong with samba's
                           builtin-forms */
@@ -1703,24 +1739,23 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
                                                        info,
                                                        &result);
                        if (!W_ERROR_IS_OK(result)) {
-                               d_printf("\tAddForm form %d: [%s] refused.\n",
-                                       f, form_name);
+                               d_printf(_("\tAddForm form %d: [%s] refused.\n"),
+                                       f, forms[f].info1.form_name);
                                continue;
                        }
 
-                       DEBUGADD(1,("\tAddForm of [%s] succeeded\n", form_name));
+                       DEBUGADD(1,("\tAddForm of [%s] succeeded\n",
+                               forms[f].info1.form_name));
                }
 
 
                /* close printer handles here */
-               if (got_hnd_src) {
+               if (is_valid_policy_hnd(&hnd_src)) {
                        rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
-                       got_hnd_src = false;
                }
 
-               if (got_hnd_dst) {
+               if (is_valid_policy_hnd(&hnd_dst)) {
                        rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
-                       got_hnd_dst = false;
                }
        }
 
@@ -1728,10 +1763,10 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
 
 done:
 
-       if (got_hnd_src)
+       if (is_valid_policy_hnd(&hnd_src))
                rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
 
-       if (got_hnd_dst)
+       if (is_valid_policy_hnd(&hnd_dst))
                rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
 
        if (cli_dst) {
@@ -1758,7 +1793,7 @@ done:
  **/
 
 NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
-                                               const DOM_SID *domain_sid,
+                                               const struct dom_sid *domain_sid,
                                                const char *domain_name,
                                                struct cli_state *cli,
                                                struct rpc_pipe_client *pipe_hnd,
@@ -1767,32 +1802,26 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
                                                const char **argv)
 {
        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
-       uint32 i, p;
-       uint32 num_printers;
-       uint32 level = 3;
-       char *printername, *sharename;
-       bool got_hnd_src = false;
-       bool got_hnd_dst = false;
+       uint32_t i, p;
+       uint32_t num_printers;
+       uint32_t level = 3;
+       const char *printername, *sharename;
        bool got_src_driver_share = false;
        bool got_dst_driver_share = false;
        struct rpc_pipe_client *pipe_hnd_dst = NULL;
-       POLICY_HND hnd_src, hnd_dst;
-       PRINTER_DRIVER_CTR drv_ctr_src, drv_ctr_dst;
-       PRINTER_INFO_CTR info_ctr_enum, info_ctr_dst;
+       struct policy_handle hnd_src, hnd_dst;
+       union spoolss_DriverInfo drv_info_src;
+       union spoolss_PrinterInfo *info_enum;
+       union spoolss_PrinterInfo info_dst;
        struct cli_state *cli_dst = NULL;
        struct cli_state *cli_share_src = NULL;
        struct cli_state *cli_share_dst = NULL;
-       fstring drivername = "";
-
-       ZERO_STRUCT(drv_ctr_src);
-       ZERO_STRUCT(drv_ctr_dst);
-       ZERO_STRUCT(info_ctr_enum);
-       ZERO_STRUCT(info_ctr_dst);
+       const char *drivername = NULL;
 
        DEBUG(3,("copying printer-drivers\n"));
 
        nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst,
-                                    &syntax_spoolss);
+                                    &ndr_table_spoolss.syntax_id);
        if (!NT_STATUS_IS_OK(nt_status))
                return nt_status;
 
@@ -1815,13 +1844,13 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
 
 
        /* enum src printers */
-       if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &info_ctr_enum)) {
+       if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &info_enum)) {
                nt_status = NT_STATUS_UNSUCCESSFUL;
                goto done;
        }
 
        if (num_printers == 0) {
-               printf ("no printers found on server.\n");
+               printf (_("no printers found on server.\n"));
                nt_status = NT_STATUS_OK;
                goto done;
        }
@@ -1829,17 +1858,11 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
 
        /* do something for all printers */
        for (p = 0; p < num_printers; p++) {
+
                /* do some initialization */
-               rpcstr_pull_talloc(mem_ctx,
-                               &printername,
-                               info_ctr_enum.printers_2[p].printername.buffer,
-                               -1,
-                               STR_TERMINATE);
-               rpcstr_pull_talloc(mem_ctx,
-                               &sharename,
-                               info_ctr_enum.printers_2[p].sharename.buffer,
-                               -1,
-                               STR_TERMINATE);
+               printername = info_enum[p].info2.printername;
+               sharename = info_enum[p].info2.sharename;
+
                if (!printername || !sharename) {
                        nt_status = NT_STATUS_UNSUCCESSFUL;
                        goto done;
@@ -1849,7 +1872,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
                   get any real NT_STATUS-codes anymore from now on */
                nt_status = NT_STATUS_UNSUCCESSFUL;
 
-               d_printf("migrating printer driver for:   [%s] / [%s]\n",
+               d_printf(_("migrating printer driver for:   [%s] / [%s]\n"),
                        printername, sharename);
 
                /* open dst printer handle */
@@ -1857,10 +1880,8 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
                        PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst))
                        goto done;
 
-               got_hnd_dst = true;
-
                /* check for existing dst printer */
-               if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_ctr_dst))
+               if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_dst))
                        goto done;
 
 
@@ -1871,9 +1892,6 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
                                                 &hnd_src))
                        goto done;
 
-               got_hnd_src = true;
-
-
                /* in a first step call getdriver for each shared printer (per arch)
                   to get a list of all files that have to be copied */
 
@@ -1882,15 +1900,13 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
                        /* getdriver src */
                        if (!net_spoolss_getprinterdriver(pipe_hnd, mem_ctx, &hnd_src,
                                        level, archi_table[i].long_archi,
-                                       archi_table[i].version, &drv_ctr_src))
+                                       archi_table[i].version, &drv_info_src))
                                continue;
 
-                       rpcstr_pull(drivername, drv_ctr_src.info3->name.buffer,
-                                       sizeof(drivername), -1, STR_TERMINATE);
+                       drivername = drv_info_src.info3.driver_name;
 
                        if (c->opt_verbose)
-                               display_print_driver_3(drv_ctr_src.info3);
-
+                               display_print_driver3(&drv_info_src.info3);
 
                        /* check arch dir */
                        nt_status = check_arch_dir(cli_share_dst, archi_table[i].short_archi);
@@ -1901,13 +1917,13 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
                        /* copy driver-files */
                        nt_status = copy_print_driver_3(c, mem_ctx, cli_share_src, cli_share_dst,
                                                        archi_table[i].short_archi,
-                                                       drv_ctr_src.info3);
+                                                       &drv_info_src.info3);
                        if (!NT_STATUS_IS_OK(nt_status))
                                goto done;
 
 
                        /* adddriver dst */
-                       if (!net_spoolss_addprinterdriver(pipe_hnd_dst, mem_ctx, level, &drv_ctr_src)) {
+                       if (!net_spoolss_addprinterdriver(pipe_hnd_dst, mem_ctx, level, &drv_info_src)) {
                                nt_status = NT_STATUS_UNSUCCESSFUL;
                                goto done;
                        }
@@ -1917,16 +1933,16 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
 
                }
 
-               if (strlen(drivername) == 0) {
+               if (!drivername || strlen(drivername) == 0) {
                        DEBUGADD(1,("Did not get driver for printer %s\n",
                                    printername));
                        goto done;
                }
 
                /* setdriver dst */
-               init_unistr(&info_ctr_dst.printers_2->drivername, drivername);
+               info_dst.info2.drivername = drivername;
 
-               if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_ctr_dst)) {
+               if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_dst)) {
                        nt_status = NT_STATUS_UNSUCCESSFUL;
                        goto done;
                }
@@ -1935,15 +1951,13 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
                        drivername, printername));
 
                /* close dst */
-               if (got_hnd_dst) {
+               if (is_valid_policy_hnd(&hnd_dst)) {
                        rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
-                       got_hnd_dst = false;
                }
 
                /* close src */
-               if (got_hnd_src) {
+               if (is_valid_policy_hnd(&hnd_src)) {
                        rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
-                       got_hnd_src = false;
                }
        }
 
@@ -1951,10 +1965,10 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
 
 done:
 
-       if (got_hnd_src)
+       if (is_valid_policy_hnd(&hnd_src))
                rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
 
-       if (got_hnd_dst)
+       if (is_valid_policy_hnd(&hnd_dst))
                rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
 
        if (cli_dst) {
@@ -1990,7 +2004,7 @@ done:
  **/
 
 NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
-                                               const DOM_SID *domain_sid,
+                                               const struct dom_sid *domain_sid,
                                                const char *domain_name,
                                                struct cli_state *cli,
                                                struct rpc_pipe_client *pipe_hnd,
@@ -2000,49 +2014,45 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
 {
        WERROR result;
        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
-       uint32 i = 0, num_printers;
-       uint32 level = 2;
-       PRINTER_INFO_CTR ctr_src, ctr_dst, ctr_enum;
+       uint32_t i = 0, num_printers;
+       uint32_t level = 2;
+       union spoolss_PrinterInfo info_dst, info_src;
+       union spoolss_PrinterInfo *info_enum;
        struct cli_state *cli_dst = NULL;
-       POLICY_HND hnd_dst, hnd_src;
-       char *printername, *sharename;
-       bool got_hnd_src = false;
-       bool got_hnd_dst = false;
+       struct policy_handle hnd_dst, hnd_src;
+       const char *printername, *sharename;
        struct rpc_pipe_client *pipe_hnd_dst = NULL;
+       struct spoolss_SetPrinterInfoCtr info_ctr;
 
        DEBUG(3,("copying printers\n"));
 
        /* connect destination PI_SPOOLSS */
        nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst,
-                                    &syntax_spoolss);
+                                    &ndr_table_spoolss.syntax_id);
        if (!NT_STATUS_IS_OK(nt_status))
                return nt_status;
 
        /* enum printers */
-       if (!get_printer_info(pipe_hnd, mem_ctx, level, argc, argv, &num_printers, &ctr_enum)) {
+       if (!get_printer_info(pipe_hnd, mem_ctx, level, argc, argv, &num_printers, &info_enum)) {
                nt_status = NT_STATUS_UNSUCCESSFUL;
                goto done;
        }
 
        if (!num_printers) {
-               printf ("no printers found on server.\n");
+               printf (_("no printers found on server.\n"));
                nt_status = NT_STATUS_OK;
                goto done;
        }
 
        /* do something for all printers */
        for (i = 0; i < num_printers; i++) {
+
+               struct spoolss_SetPrinterInfo2 info2;
+
                /* do some initialization */
-               rpcstr_pull_talloc(mem_ctx,
-                               &printername,
-                               ctr_enum.printers_2[i].printername.buffer,
-                               -1,
-                               STR_TERMINATE);
-               rpcstr_pull_talloc(mem_ctx,
-                               &sharename,
-                               ctr_enum.printers_2[i].sharename.buffer,
-                               -1,
-                               STR_TERMINATE);
+               printername = info_enum[i].info2.printername;
+               sharename = info_enum[i].info2.sharename;
+
                if (!printername || !sharename) {
                        nt_status = NT_STATUS_UNSUCCESSFUL;
                        goto done;
@@ -2051,7 +2061,7 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
                   get any real NT_STATUS-codes anymore from now on */
                nt_status = NT_STATUS_UNSUCCESSFUL;
 
-               d_printf("migrating printer queue for:    [%s] / [%s]\n",
+               d_printf(_("migrating printer queue for:    [%s] / [%s]\n"),
                        printername, sharename);
 
                /* open dst printer handle */
@@ -2059,19 +2069,16 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
                        PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst)) {
 
                        DEBUG(1,("could not open printer: %s\n", sharename));
-               } else {
-                       got_hnd_dst = true;
                }
 
                /* check for existing dst printer */
-               if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &ctr_dst)) {
-                       printf ("could not get printer, creating printer.\n");
+               if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &info_dst)) {
+                       printf (_("could not get printer, creating printer.\n"));
                } else {
                        DEBUG(1,("printer already exists: %s\n", sharename));
                        /* close printer handle here - dst only, not got src yet. */
-                       if (got_hnd_dst) {
+                       if (is_valid_policy_hnd(&hnd_dst)) {
                                rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
-                               got_hnd_dst = false;
                        }
                        continue;
                }
@@ -2084,45 +2091,51 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
                        MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
                        goto done;
 
-               got_hnd_src = true;
-
                /* getprinter on the src server */
-               if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd_src, level, &ctr_src))
+               if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd_src, level, &info_src))
                        goto done;
 
                /* copy each src printer to a dst printer 1:1,
                   maybe some values have to be changed though */
-               d_printf("creating printer: %s\n", printername);
-               result = rpccli_spoolss_addprinterex (pipe_hnd_dst, mem_ctx, level, &ctr_src);
+               d_printf(_("creating printer: %s\n"), printername);
+
+               info_ctr.level = level;
+               spoolss_printerinfo2_to_setprinterinfo2(&info_src.info2, &info2);
+               info_ctr.info.info2 = &info2;
+
+               result = rpccli_spoolss_addprinterex(pipe_hnd_dst,
+                                                    mem_ctx,
+                                                    &info_ctr);
 
                if (W_ERROR_IS_OK(result))
-                       d_printf ("printer [%s] successfully added.\n", printername);
+                       d_printf (_("printer [%s] successfully added.\n"),
+                                 printername);
                else if (W_ERROR_V(result) == W_ERROR_V(WERR_PRINTER_ALREADY_EXISTS))
-                       d_fprintf (stderr, "printer [%s] already exists.\n", printername);
+                       d_fprintf (stderr, _("printer [%s] already exists.\n"),
+                                  printername);
                else {
-                       d_fprintf (stderr, "could not create printer [%s]\n", printername);
+                       d_fprintf (stderr, _("could not create printer [%s]\n"),
+                                  printername);
                        goto done;
                }
 
                /* close printer handles here */
-               if (got_hnd_src) {
+               if (is_valid_policy_hnd(&hnd_src)) {
                        rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
-                       got_hnd_src = false;
                }
 
-               if (got_hnd_dst) {
+               if (is_valid_policy_hnd(&hnd_dst)) {
                        rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
-                       got_hnd_dst = false;
                }
        }
 
        nt_status = NT_STATUS_OK;
 
 done:
-       if (got_hnd_src)
+       if (is_valid_policy_hnd(&hnd_src))
                rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
 
-       if (got_hnd_dst)
+       if (is_valid_policy_hnd(&hnd_dst))
                rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
 
        if (cli_dst) {
@@ -2150,7 +2163,7 @@ done:
  **/
 
 NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
-                                               const DOM_SID *domain_sid,
+                                               const struct dom_sid *domain_sid,
                                                const char *domain_name,
                                                struct cli_state *cli,
                                                struct rpc_pipe_client *pipe_hnd,
@@ -2163,40 +2176,39 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
 
        WERROR result;
        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
-       uint32 i = 0, p = 0, j = 0;
-       uint32 num_printers, val_needed, data_needed;
-       uint32 level = 2;
-       char *printername, *sharename;
-       bool got_hnd_src = false;
-       bool got_hnd_dst = false;
+       uint32_t i = 0, p = 0, j = 0;
+       uint32_t num_printers;
+       uint32_t level = 2;
+       const char *printername, *sharename;
        struct rpc_pipe_client *pipe_hnd_dst = NULL;
-       POLICY_HND hnd_src, hnd_dst;
-       PRINTER_INFO_CTR ctr_enum, ctr_dst, ctr_dst_publish;
-       REGVAL_CTR *reg_ctr;
+       struct policy_handle hnd_src, hnd_dst;
+       union spoolss_PrinterInfo *info_enum;
+       union spoolss_PrinterInfo info_dst_publish;
+       union spoolss_PrinterInfo info_dst;
        struct cli_state *cli_dst = NULL;
        char *devicename = NULL, *unc_name = NULL, *url = NULL;
        const char *longname;
+       const char **keylist = NULL;
 
-       uint16 *keylist = NULL, *curkey;
-
-       ZERO_STRUCT(ctr_enum);
+       /* FIXME GD */
+       ZERO_STRUCT(info_dst_publish);
 
        DEBUG(3,("copying printer settings\n"));
 
        /* connect destination PI_SPOOLSS */
        nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst,
-                                    &syntax_spoolss);
+                                    &ndr_table_spoolss.syntax_id);
        if (!NT_STATUS_IS_OK(nt_status))
                return nt_status;
 
        /* enum src printers */
-       if (!get_printer_info(pipe_hnd, mem_ctx, level, argc, argv, &num_printers, &ctr_enum)) {
+       if (!get_printer_info(pipe_hnd, mem_ctx, level, argc, argv, &num_printers, &info_enum)) {
                nt_status = NT_STATUS_UNSUCCESSFUL;
                goto done;
        }
 
        if (!num_printers) {
-               printf ("no printers found on server.\n");
+               printf (_("no printers found on server.\n"));
                nt_status = NT_STATUS_OK;
                goto done;
        }
@@ -2211,17 +2223,17 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
 
        /* do something for all printers */
        for (i = 0; i < num_printers; i++) {
+
+               uint32_t value_offered = 0, value_needed;
+               uint32_t data_offered = 0, data_needed;
+               enum winreg_Type type;
+               uint8_t *buffer = NULL;
+               const char *value_name = NULL;
+
                /* do some initialization */
-               rpcstr_pull_talloc(mem_ctx,
-                               &printername,
-                               ctr_enum.printers_2[i].printername.buffer,
-                               -1,
-                               STR_TERMINATE);
-               rpcstr_pull_talloc(mem_ctx,
-                               &sharename,
-                               ctr_enum.printers_2[i].sharename.buffer,
-                               -1,
-                               STR_TERMINATE);
+               printername = info_enum[i].info2.printername;
+               sharename = info_enum[i].info2.sharename;
+
                if (!printername || !sharename) {
                        nt_status = NT_STATUS_UNSUCCESSFUL;
                        goto done;
@@ -2230,7 +2242,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
                   get any real NT_STATUS-codes anymore from now on */
                nt_status = NT_STATUS_UNSUCCESSFUL;
 
-               d_printf("migrating printer settings for: [%s] / [%s]\n",
+               d_printf(_("migrating printer settings for: [%s] / [%s]\n"),
                        printername, sharename);
 
 
@@ -2239,20 +2251,14 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
                        MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
                        goto done;
 
-               got_hnd_src = true;
-
-
                /* open dst printer handle */
                if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
                        PRINTER_ALL_ACCESS, cli_dst->user_name, &hnd_dst))
                        goto done;
 
-               got_hnd_dst = true;
-
-
                /* check for existing dst printer */
                if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst,
-                               level, &ctr_dst))
+                               level, &info_dst))
                        goto done;
 
 
@@ -2260,51 +2266,47 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
                           PRINTER_INFO_2-attributes
                */
 
-               ctr_dst.printers_2 = &ctr_enum.printers_2[i];
+               info_dst.info2 = info_enum[i].info2;
 
                /* why is the port always disconnected when the printer
                   is correctly installed (incl. driver ???) */
-               init_unistr( &ctr_dst.printers_2->portname, SAMBA_PRINTER_PORT_NAME);
+               info_dst.info2.portname = SAMBA_PRINTER_PORT_NAME;
 
                /* check if printer is published */
-               if (ctr_enum.printers_2[i].attributes & PRINTER_ATTRIBUTE_PUBLISHED) {
+               if (info_enum[i].info2.attributes & PRINTER_ATTRIBUTE_PUBLISHED) {
 
                        /* check for existing dst printer */
-                       if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 7, &ctr_dst_publish))
+                       if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 7, &info_dst_publish))
                                goto done;
 
-                       ctr_dst_publish.printers_7->action = SPOOL_DS_PUBLISH;
+                       info_dst_publish.info7.action = DSPRINT_PUBLISH;
 
                        /* ignore false from setprinter due to WERR_IO_PENDING */
-                       net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 7, &ctr_dst_publish);
+                       net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 7, &info_dst_publish);
 
                        DEBUG(3,("republished printer\n"));
                }
 
-               if (ctr_enum.printers_2[i].devmode != NULL) {
+               if (info_enum[i].info2.devmode != NULL) {
 
                        /* copy devmode (info level 2) */
-                       ctr_dst.printers_2->devmode = (DEVICEMODE *)
-                               TALLOC_MEMDUP(mem_ctx,
-                                             ctr_enum.printers_2[i].devmode,
-                                             sizeof(DEVICEMODE));
+                       info_dst.info2.devmode = info_enum[i].info2.devmode;
 
                        /* do not copy security descriptor (we have another
                         * command for that) */
-                       ctr_dst.printers_2->secdesc = NULL;
+                       info_dst.info2.secdesc = NULL;
 
 #if 0
-                       if (asprintf(&devicename, "\\\\%s\\%s", longname,
-                                    printername) < 0) {
+                       info_dst.info2.devmode.devicename =
+                               talloc_asprintf(mem_ctx, "\\\\%s\\%s",
+                                               longname, printername);
+                       if (!info_dst.info2.devmode.devicename) {
                                nt_status = NT_STATUS_NO_MEMORY;
                                goto done;
                        }
-
-                       init_unistr(&ctr_dst.printers_2->devmode->devicename,
-                                   devicename);
 #endif
                        if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst,
-                                                   level, &ctr_dst))
+                                                   level, &info_dst))
                                goto done;
 
                        DEBUGADD(1,("\tSetPrinter of DEVICEMODE succeeded\n"));
@@ -2319,32 +2321,66 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
                */
 
                /* enumerate data on src handle */
-               result = rpccli_spoolss_enumprinterdata(pipe_hnd, mem_ctx, &hnd_src, p, 0, 0,
-                       &val_needed, &data_needed, NULL);
+               nt_status = rpccli_spoolss_EnumPrinterData(pipe_hnd, mem_ctx,
+                                                          &hnd_src,
+                                                          p,
+                                                          value_name,
+                                                          value_offered,
+                                                          &value_needed,
+                                                          &type,
+                                                          buffer,
+                                                          data_offered,
+                                                          &data_needed,
+                                                          &result);
+
+               data_offered    = data_needed;
+               value_offered   = value_needed;
+               buffer          = talloc_zero_array(mem_ctx, uint8_t, data_needed);
+               value_name      = talloc_zero_array(mem_ctx, char, value_needed);
 
                /* loop for all printerdata of "PrinterDriverData" */
-               while (W_ERROR_IS_OK(result)) {
-
-                       REGISTRY_VALUE value;
-
-                       result = rpccli_spoolss_enumprinterdata(
-                               pipe_hnd, mem_ctx, &hnd_src, p++, val_needed,
-                               data_needed, 0, 0, &value);
-
+               while (NT_STATUS_IS_OK(nt_status) && W_ERROR_IS_OK(result)) {
+
+                       nt_status = rpccli_spoolss_EnumPrinterData(pipe_hnd, mem_ctx,
+                                                                  &hnd_src,
+                                                                  p++,
+                                                                  value_name,
+                                                                  value_offered,
+                                                                  &value_needed,
+                                                                  &type,
+                                                                  buffer,
+                                                                  data_offered,
+                                                                  &data_needed,
+                                                                  &result);
                        /* loop for all reg_keys */
-                       if (W_ERROR_IS_OK(result)) {
+                       if (NT_STATUS_IS_OK(nt_status) && W_ERROR_IS_OK(result)) {
 
                                /* display_value */
-                               if (c->opt_verbose)
-                                       display_reg_value(SPOOL_PRINTERDATA_KEY, value);
+                               if (c->opt_verbose) {
+                                       struct regval_blob *v;
+
+                                       v = regval_compose(talloc_tos(),
+                                                          value_name,
+                                                          type,
+                                                          buffer,
+                                                          data_offered);
+                                       if (v == NULL) {
+                                               nt_status = NT_STATUS_NO_MEMORY;
+                                               goto done;
+                                       }
+
+                                       display_reg_value(SPOOL_PRINTERDATA_KEY, v);
+                                       talloc_free(v);
+                               }
 
                                /* set_value */
                                if (!net_spoolss_setprinterdata(pipe_hnd_dst, mem_ctx,
-                                                               &hnd_dst, &value))
+                                                               &hnd_dst, value_name,
+                                                               type, buffer, data_offered))
                                        goto done;
 
                                DEBUGADD(1,("\tSetPrinterData of [%s] succeeded\n",
-                                       value.valuename));
+                                           value_name));
                        }
                }
 
@@ -2356,7 +2392,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
                   in case of an error */
 
                if (!net_spoolss_enumprinterkey(pipe_hnd, mem_ctx, &hnd_src, "", &keylist)) {
-                       printf("got no key-data\n");
+                       printf(_("got no key-data\n"));
                        continue;
                }
 
@@ -2368,61 +2404,51 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
                if (keylist == NULL)
                        continue;
 
-               curkey = keylist;
-               while (*curkey != 0) {
-                       char *subkey;
-                       rpcstr_pull_talloc(mem_ctx,
-                                       &subkey,
-                                       curkey,
-                                       -1,
-                                       STR_TERMINATE);
-                       if (!subkey) {
-                               return NT_STATUS_NO_MEMORY;
-                       }
-
-                       curkey += strlen(subkey) + 1;
+               for (i=0; keylist && keylist[i] != NULL; i++) {
 
-                       if ( !(reg_ctr = TALLOC_ZERO_P( mem_ctx, REGVAL_CTR )) )
-                               return NT_STATUS_NO_MEMORY;
+                       const char *subkey = keylist[i];
+                       uint32_t count;
+                       struct spoolss_PrinterEnumValues *info;
 
                        /* enumerate all src subkeys */
                        if (!net_spoolss_enumprinterdataex(pipe_hnd, mem_ctx, 0,
                                                           &hnd_src, subkey,
-                                                          reg_ctr))
+                                                          &count, &info)) {
                                goto done;
+                       }
+
+                       for (j=0; j < count; j++) {
 
-                       for (j=0; j < reg_ctr->num_values; j++) {
+                               struct regval_blob *value;
+                               DATA_BLOB blob;
 
-                               REGISTRY_VALUE value;
-                               UNISTR2 data;
+                               ZERO_STRUCT(blob);
 
                                /* although samba replies with sane data in most cases we
                                   should try to avoid writing wrong registry data */
 
-                               if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_PORTNAME) ||
-                                   strequal(reg_ctr->values[j]->valuename, SPOOL_REG_UNCNAME) ||
-                                   strequal(reg_ctr->values[j]->valuename, SPOOL_REG_URL) ||
-                                   strequal(reg_ctr->values[j]->valuename, SPOOL_REG_SHORTSERVERNAME) ||
-                                   strequal(reg_ctr->values[j]->valuename, SPOOL_REG_SERVERNAME)) {
+                               if (strequal(info[j].value_name, SPOOL_REG_PORTNAME) ||
+                                   strequal(info[j].value_name, SPOOL_REG_UNCNAME) ||
+                                   strequal(info[j].value_name, SPOOL_REG_URL) ||
+                                   strequal(info[j].value_name, SPOOL_REG_SHORTSERVERNAME) ||
+                                   strequal(info[j].value_name, SPOOL_REG_SERVERNAME)) {
 
-                                       if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_PORTNAME)) {
+                                       if (strequal(info[j].value_name, SPOOL_REG_PORTNAME)) {
 
                                                /* although windows uses a multi-sz, we use a sz */
-                                               init_unistr2(&data, SAMBA_PRINTER_PORT_NAME, UNI_STR_TERMINATE);
-                                               fstrcpy(value.valuename, SPOOL_REG_PORTNAME);
+                                               push_reg_sz(mem_ctx, &blob, SAMBA_PRINTER_PORT_NAME);
                                        }
 
-                                       if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_UNCNAME)) {
+                                       if (strequal(info[j].value_name, SPOOL_REG_UNCNAME)) {
 
                                                if (asprintf(&unc_name, "\\\\%s\\%s", longname, sharename) < 0) {
                                                        nt_status = NT_STATUS_NO_MEMORY;
                                                        goto done;
                                                }
-                                               init_unistr2(&data, unc_name, UNI_STR_TERMINATE);
-                                               fstrcpy(value.valuename, SPOOL_REG_UNCNAME);
+                                               push_reg_sz(mem_ctx, &blob, unc_name);
                                        }
 
-                                       if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_URL)) {
+                                       if (strequal(info[j].value_name, SPOOL_REG_URL)) {
 
                                                continue;
 
@@ -2432,29 +2458,29 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
                                                        nt_status = NT_STATUS_NO_MEMORY;
                                                        goto done;
                                                }
-                                               init_unistr2(&data, url, UNI_STR_TERMINATE);
+                                               push_reg_sz(mem_ctx, NULL, &blob, url);
                                                fstrcpy(value.valuename, SPOOL_REG_URL);
 #endif
                                        }
 
-                                       if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_SERVERNAME)) {
+                                       if (strequal(info[j].value_name, SPOOL_REG_SERVERNAME)) {
 
-                                               init_unistr2(&data, longname, UNI_STR_TERMINATE);
-                                               fstrcpy(value.valuename, SPOOL_REG_SERVERNAME);
+                                               push_reg_sz(mem_ctx, &blob, longname);
                                        }
 
-                                       if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_SHORTSERVERNAME)) {
+                                       if (strequal(info[j].value_name, SPOOL_REG_SHORTSERVERNAME)) {
 
-                                               init_unistr2(&data, global_myname(), UNI_STR_TERMINATE);
-                                               fstrcpy(value.valuename, SPOOL_REG_SHORTSERVERNAME);
+                                               push_reg_sz(mem_ctx, &blob, global_myname());
                                        }
 
-                                       value.type = REG_SZ;
-                                       value.size = data.uni_str_len * 2;
-                                       if (value.size) {
-                                               value.data_p = (uint8 *)TALLOC_MEMDUP(mem_ctx, data.buffer, value.size);
-                                       } else {
-                                               value.data_p = NULL;
+                                       value = regval_compose(talloc_tos(),
+                                                              info[j].value_name,
+                                                              REG_SZ,
+                                                              blob.length == 0 ? NULL : blob.data,
+                                                              blob.length);
+                                       if (value == NULL) {
+                                               nt_status = NT_STATUS_NO_MEMORY;
+                                               goto done;
                                        }
 
                                        if (c->opt_verbose)
@@ -2462,40 +2488,55 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
 
                                        /* here we have to set all subkeys on the dst server */
                                        if (!net_spoolss_setprinterdataex(pipe_hnd_dst, mem_ctx, &hnd_dst,
-                                                       subkey, &value))
+                                                       subkey, value))
+                                       {
+                                               talloc_free(value);
                                                goto done;
+                                       }
 
+                                       talloc_free(value);
                                } else {
 
-                                       if (c->opt_verbose)
-                                               display_reg_value(subkey, *(reg_ctr->values[j]));
+                                       struct regval_blob *v;
+
+                                       v = regval_compose(talloc_tos(),
+                                                          info[j].value_name,
+                                                          info[j].type,
+                                                          info[j].data->data,
+                                                          info[j].data->length);
+                                       if (v == NULL) {
+                                               nt_status = NT_STATUS_NO_MEMORY;
+                                               goto done;
+                                       }
+
+                                       if (c->opt_verbose) {
+                                               display_reg_value(subkey, v);
+                                       }
 
                                        /* here we have to set all subkeys on the dst server */
                                        if (!net_spoolss_setprinterdataex(pipe_hnd_dst, mem_ctx, &hnd_dst,
-                                                       subkey, reg_ctr->values[j]))
+                                                       subkey, v)) {
                                                goto done;
+                                       }
 
+                                       talloc_free(v);
                                }
 
                                DEBUGADD(1,("\tSetPrinterDataEx of key [%s\\%s] succeeded\n",
-                                               subkey, reg_ctr->values[j]->valuename));
+                                               subkey, info[j].value_name));
 
                        }
-
-                       TALLOC_FREE( reg_ctr );
                }
 
-               SAFE_FREE(keylist);
+               TALLOC_FREE(keylist);
 
                /* close printer handles here */
-               if (got_hnd_src) {
+               if (is_valid_policy_hnd(&hnd_src)) {
                        rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
-                       got_hnd_src = false;
                }
 
-               if (got_hnd_dst) {
+               if (is_valid_policy_hnd(&hnd_dst)) {
                        rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
-                       got_hnd_dst = false;
                }
 
        }
@@ -2507,10 +2548,10 @@ done:
        SAFE_FREE(url);
        SAFE_FREE(unc_name);
 
-       if (got_hnd_src)
+       if (is_valid_policy_hnd(&hnd_src))
                rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
 
-       if (got_hnd_dst)
+       if (is_valid_policy_hnd(&hnd_dst))
                rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
 
        if (cli_dst) {