s4-dsdb: change samdb_replace() to dsdb_replace() and allow for dsdb_flags
[ira/wip.git] / source4 / ntptr / simple_ldb / ntptr_simple_ldb.c
index 459babce0ee5d1d344bf70a7b0089c3678a49d9b..33632aa0fcee6ee9df75e8d1ea35b0d8adc40c2c 100644 (file)
@@ -44,8 +44,8 @@
  */
 static struct ldb_context *sptr_db_connect(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx, struct loadparm_context *lp_ctx)
 {
-       return ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx, lp_spoolss_url(lp_ctx), system_session(mem_ctx, lp_ctx), 
-                               NULL, 0, NULL);
+       return ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx, lp_spoolss_url(lp_ctx), system_session(lp_ctx), 
+                               NULL, 0);
 }
 
 static int sptr_db_search(struct ldb_context *ldb,
@@ -127,44 +127,44 @@ static WERROR sptr_GetPrintServerData(struct ntptr_GenericHandle *server, TALLOC
 {
        struct dcerpc_server_info *server_info = lp_dcerpc_server_info(mem_ctx, server->ntptr->lp_ctx);
        if (strcmp("W3SvcInstalled", r->in.value_name) == 0) {
-               *r->out.type            = SPOOLSS_PRINTER_DATA_TYPE_UINT32;
-               r->out.data.value       = 0;
+               *r->out.type            = REG_DWORD;
+               r->out.data->value      = 0;
                return WERR_OK;
        } else if (strcmp("BeepEnabled", r->in.value_name) == 0) {
-               *r->out.type            = SPOOLSS_PRINTER_DATA_TYPE_UINT32;
-               r->out.data.value       = 0;
+               *r->out.type            = REG_DWORD;
+               r->out.data->value      = 0;
                return WERR_OK;
        } else if (strcmp("EventLog", r->in.value_name) == 0) {
-               *r->out.type            = SPOOLSS_PRINTER_DATA_TYPE_UINT32;
-               r->out.data.value       = 0;
+               *r->out.type            = REG_DWORD;
+               r->out.data->value      = 0;
                return WERR_OK;
        } else if (strcmp("NetPopup", r->in.value_name) == 0) {
-               *r->out.type            = SPOOLSS_PRINTER_DATA_TYPE_UINT32;
-               r->out.data.value       = 0;
+               *r->out.type            = REG_DWORD;
+               r->out.data->value      = 0;
                return WERR_OK;
        } else if (strcmp("NetPopupToComputer", r->in.value_name) == 0) {
-               *r->out.type            = SPOOLSS_PRINTER_DATA_TYPE_UINT32;
-               r->out.data.value       = 0;
+               *r->out.type            = REG_DWORD;
+               r->out.data->value      = 0;
                return  WERR_OK;
        } else if (strcmp("MajorVersion", r->in.value_name) == 0) {
-               *r->out.type            = SPOOLSS_PRINTER_DATA_TYPE_UINT32;
-               r->out.data.value       = 3;
+               *r->out.type            = REG_DWORD;
+               r->out.data->value      = 3;
                return WERR_OK;
        } else if (strcmp("MinorVersion", r->in.value_name) == 0) {
-               *r->out.type            = SPOOLSS_PRINTER_DATA_TYPE_UINT32;
-               r->out.data.value       = 0;
+               *r->out.type            = REG_DWORD;
+               r->out.data->value      = 0;
                return WERR_OK;
        } else if (strcmp("DefaultSpoolDirectory", r->in.value_name) == 0) {
-               *r->out.type            = SPOOLSS_PRINTER_DATA_TYPE_STRING;
-               r->out.data.string      = "C:\\PRINTERS";
+               *r->out.type            = REG_SZ;
+               r->out.data->string     = "C:\\PRINTERS";
                return  WERR_OK;
        } else if (strcmp("Architecture", r->in.value_name) == 0) {
-               *r->out.type            = SPOOLSS_PRINTER_DATA_TYPE_STRING;
-               r->out.data.string      = SPOOLSS_ARCHITECTURE_NT_X86;
+               *r->out.type            = REG_SZ;
+               r->out.data->string     = SPOOLSS_ARCHITECTURE_NT_X86;
                return  WERR_OK;
        } else if (strcmp("DsPresent", r->in.value_name) == 0) {
-               *r->out.type            = SPOOLSS_PRINTER_DATA_TYPE_UINT32;
-               r->out.data.value       = 1;
+               *r->out.type            = REG_DWORD;
+               r->out.data->value      = 1;
                return WERR_OK;
        } else if (strcmp("OSVersion", r->in.value_name) == 0) {
                DATA_BLOB blob;
@@ -181,8 +181,8 @@ static WERROR sptr_GetPrintServerData(struct ntptr_GenericHandle *server, TALLOC
                        return WERR_GENERAL_FAILURE;
                }
 
-               *r->out.type            = SPOOLSS_PRINTER_DATA_TYPE_BINARY;
-               r->out.data.binary      = blob;
+               *r->out.type            = REG_BINARY;
+               r->out.data->binary     = blob;
                return WERR_OK;
        } else if (strcmp("OSVersionEx", r->in.value_name) == 0) {
                DATA_BLOB blob;
@@ -192,26 +192,31 @@ static WERROR sptr_GetPrintServerData(struct ntptr_GenericHandle *server, TALLOC
                os_ex.major             = server_info->version_major;
                os_ex.minor             = server_info->version_minor;
                os_ex.build             = server_info->version_build;
-               os_ex.extra_string              = "";
-               os_ex.unknown2          = 0;
-               os_ex.unknown3          = 0;
+               os_ex.extra_string      = "";
+               os_ex.service_pack_major= 0;
+               os_ex.service_pack_minor= 0;
+               os_ex.suite_mask        = 0;
+               os_ex.product_type      = 0;
+               os_ex.reserved          = 0;
 
                ndr_err = ndr_push_struct_blob(&blob, mem_ctx, lp_iconv_convenience(server->ntptr->lp_ctx), &os_ex, (ndr_push_flags_fn_t)ndr_push_spoolss_OSVersionEx);
                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                        return WERR_GENERAL_FAILURE;
                }
 
-               *r->out.type            = SPOOLSS_PRINTER_DATA_TYPE_BINARY;
-               r->out.data.binary      = blob;
+               *r->out.type            = REG_BINARY;
+               r->out.data->binary     = blob;
                return WERR_OK;
        } else if (strcmp("DNSMachineName", r->in.value_name) == 0) {
-               if (!lp_realm(server->ntptr->lp_ctx)) return WERR_INVALID_PARAM;
+               const char *dnsdomain = lp_dnsdomain(server->ntptr->lp_ctx);
 
-               *r->out.type            = SPOOLSS_PRINTER_DATA_TYPE_STRING;
-               r->out.data.string      = talloc_asprintf(mem_ctx, "%s.%s",
-                                                                  lp_netbios_name(server->ntptr->lp_ctx),
-                                                                  lp_realm(server->ntptr->lp_ctx));
-               W_ERROR_HAVE_NO_MEMORY(r->out.data.string);
+               if (dnsdomain == NULL) return WERR_INVALID_PARAM;
+
+               *r->out.type            = REG_SZ;
+               r->out.data->string     = talloc_asprintf(mem_ctx, "%s.%s",
+                                                         lp_netbios_name(server->ntptr->lp_ctx),
+                                                         dnsdomain);
+               W_ERROR_HAVE_NO_MEMORY(r->out.data->string);
                return WERR_OK;
        }
 
@@ -259,7 +264,7 @@ static WERROR sptr_EnumPrintServerForms(struct ntptr_GenericHandle *server, TALL
                return WERR_UNKNOWN_LEVEL;
        }
 
-       r->out.info     = info;
+       *r->out.info    = info;
        *r->out.count   = count;
        return WERR_OK;
 }
@@ -384,7 +389,7 @@ static WERROR sptr_SetPrintServerForm(struct ntptr_GenericHandle *server, TALLOC
                return WERR_UNKNOWN_LEVEL;
        }
 
-       ret = samdb_replace(sptr_db, mem_ctx, msg);
+       ret = dsdb_replace(sptr_db, msg, 0);
        if (ret != 0) {
                return WERR_FOOBAR;
        }
@@ -587,7 +592,7 @@ static WERROR sptr_EnumPrinters(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx
                return WERR_UNKNOWN_LEVEL;
        }
 
-       r->out.info     = info;
+       *r->out.info    = info;
        *r->out.count   = count;
        return WERR_OK;
 }
@@ -645,7 +650,7 @@ static WERROR sptr_EnumPorts(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx,
                return WERR_UNKNOWN_LEVEL;
        }
 
-       r->out.info     = info;
+       *r->out.info    = info;
        *r->out.count   = count;
        return WERR_OK;
 }
@@ -692,7 +697,7 @@ static WERROR sptr_EnumMonitors(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx
                return WERR_UNKNOWN_LEVEL;
        }
 
-       r->out.info     = info;
+       *r->out.info    = info;
        *r->out.count   = count;
        return WERR_OK;
 }