summaryrefslogtreecommitdiff
path: root/source4/rpc_server/spoolss
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2004-06-27 12:03:57 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:56:47 -0500
commit674414c5b80ca7f2e4052486f892b34ec93140f9 (patch)
tree73acff9502f14867de850e7b3463e61593359e37 /source4/rpc_server/spoolss
parentd2ac885df05ef9e726ae25100eb6e848ededb0c5 (diff)
downloadsamba-674414c5b80ca7f2e4052486f892b34ec93140f9.tar.gz
samba-674414c5b80ca7f2e4052486f892b34ec93140f9.tar.bz2
samba-674414c5b80ca7f2e4052486f892b34ec93140f9.zip
r1271: Return spoolss enumprinters info level1 from spoolss.ldb - woot!
(This used to be commit 60e48790dc7ee8a98be1914ff4a2c335d25639a8)
Diffstat (limited to 'source4/rpc_server/spoolss')
-rw-r--r--source4/rpc_server/spoolss/dcesrv_spoolss.c44
-rw-r--r--source4/rpc_server/spoolss/spoolssdb.c22
2 files changed, 47 insertions, 19 deletions
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;
+}
+