summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/rpc_server/config.mk4
-rw-r--r--source4/rpc_server/spoolss/dcesrv_spoolss.c44
-rw-r--r--source4/rpc_server/spoolss/spoolssdb.c22
3 files changed, 49 insertions, 21 deletions
diff --git a/source4/rpc_server/config.mk b/source4/rpc_server/config.mk
index beef89f23f..9d9f12d9aa 100644
--- a/source4/rpc_server/config.mk
+++ b/source4/rpc_server/config.mk
@@ -5,7 +5,8 @@
[SUBSYSTEM::DCERPC_COMMON]
ADD_OBJ_FILES = \
rpc_server/common/server_info.o \
- rpc_server/common/share_info.o
+ rpc_server/common/share_info.o \
+ rpc_server/common/gendb.o
#
# End SUBSYSTEM DCERPC_COMMON
################################################
@@ -122,7 +123,6 @@ INIT_OBJ_FILES = \
rpc_server/spoolss/dcesrv_spoolss.o \
rpc_server/spoolss/spoolssdb.o
REQUIRED_SUBSYSTEMS = \
- SAMDB \
DCERPC_COMMON
# End MODULE dcerpc_lsa
################################################
diff --git a/source4/rpc_server/spoolss/dcesrv_spoolss.c b/source4/rpc_server/spoolss/dcesrv_spoolss.c
index 0916ddf081..7c14975106 100644
--- a/source4/rpc_server/spoolss/dcesrv_spoolss.c
+++ b/source4/rpc_server/spoolss/dcesrv_spoolss.c
@@ -24,28 +24,29 @@
#include "rpc_server/common/common.h"
#include "rpc_server/spoolss/dcesrv_spoolss.h"
-
-static WERROR spoolss_EnumPrinters1(TALLOC_CTX *mem_ctx, void *spoolss_ctx,
- struct ndr_push *ndr, uint32_t *count)
+static WERROR spoolss_EnumPrinters1(TALLOC_CTX *mem_ctx,
+ struct ldb_message **msgs, int num_msgs,
+ struct ndr_push *ndr)
{
- struct spoolss_PrinterInfo1 info[2];
+ struct spoolss_PrinterInfo1 *info;
+ int i;
+
+ info = talloc(mem_ctx, num_msgs * sizeof(struct spoolss_PrinterInfo1));
- info[0].flags = 0x80;
- info[0].name = "p";
- info[0].description = "a printer";
- info[0].comment = "a comment";
+ if (!info)
+ return WERR_NOMEM;
- info[1].flags = 0x80;
- info[1].name = "p2";
- info[1].description = "spottyfoot";
- info[1].comment = "the doggy";
+ for (i = 0; i < num_msgs; i++) {
+ info[i].flags = samdb_result_uint(msgs[i], "flags", 0);
+ info[i].name = samdb_result_string(msgs[i], "name", "");
+ info[i].description = samdb_result_string(msgs[i], "description", "");
+ info[i].comment = samdb_result_string(msgs[i], "comment", "");
+ }
ndr_push_array(ndr, NDR_SCALARS|NDR_BUFFERS, info,
- sizeof(struct spoolss_PrinterInfo1), 2,
+ sizeof(struct spoolss_PrinterInfo1), num_msgs,
(ndr_push_flags_fn_t)ndr_push_spoolss_PrinterInfo1);
- *count = 2;
-
return WERR_OK;
}
@@ -58,22 +59,27 @@ static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CT
struct ndr_push *ndr;
void *spoolss_ctx;
WERROR result;
+ struct ldb_message **msgs;
+ int ret;
spoolss_ctx = spoolssdb_connect();
if (spoolss_ctx == NULL)
return WERR_NOMEM;
+ ret = spoolssdb_search(spoolss_ctx, mem_ctx, NULL, &msgs, NULL,
+ "(&(objectclass=printer))");
+
ndr = ndr_push_init();
+ r->out.count = 0;
+ *r->out.buf_size = 0;
+
switch(r->in.level) {
case 1:
- result = spoolss_EnumPrinters1(
- mem_ctx, spoolss_ctx, ndr, &r->out.count);
+ result = spoolss_EnumPrinters1(mem_ctx, msgs, ret, ndr);
break;
default:
r->out.buffer = NULL;
- *r->out.buf_size = 0;
- r->out.count = 0;
result = WERR_INVALID_PARAM;
goto done;
}
diff --git a/source4/rpc_server/spoolss/spoolssdb.c b/source4/rpc_server/spoolss/spoolssdb.c
index f4180af0ef..94f91b4f16 100644
--- a/source4/rpc_server/spoolss/spoolssdb.c
+++ b/source4/rpc_server/spoolss/spoolssdb.c
@@ -87,3 +87,25 @@ void spoolssdb_close(void *ctx)
spoolss_ctx->ldb = NULL;
free(spoolss_ctx);
}
+
+/*
+ search the db for the specified attributes - varargs variant
+*/
+int spoolssdb_search(void *ctx,
+ TALLOC_CTX *mem_ctx,
+ const char *basedn,
+ struct ldb_message ***res,
+ const char * const *attrs,
+ const char *format, ...) _PRINTF_ATTRIBUTE(6,7)
+{
+ struct spoolssdb_context *spoolss_ctx = ctx;
+ va_list ap;
+ int count;
+
+ va_start(ap, format);
+ count = gendb_search_v(spoolss_ctx->ldb, mem_ctx, basedn, res, attrs, format, ap);
+ va_end(ap);
+
+ return count;
+}
+