mirror of
https://github.com/samba-team/samba.git
synced 2025-01-10 01:18:15 +03:00
r1271: Return spoolss enumprinters info level1 from spoolss.ldb - woot!
(This used to be commit 60e48790dc
)
This commit is contained in:
parent
d2ac885df0
commit
674414c5b8
@ -5,7 +5,8 @@
|
|||||||
[SUBSYSTEM::DCERPC_COMMON]
|
[SUBSYSTEM::DCERPC_COMMON]
|
||||||
ADD_OBJ_FILES = \
|
ADD_OBJ_FILES = \
|
||||||
rpc_server/common/server_info.o \
|
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
|
# End SUBSYSTEM DCERPC_COMMON
|
||||||
################################################
|
################################################
|
||||||
@ -122,7 +123,6 @@ INIT_OBJ_FILES = \
|
|||||||
rpc_server/spoolss/dcesrv_spoolss.o \
|
rpc_server/spoolss/dcesrv_spoolss.o \
|
||||||
rpc_server/spoolss/spoolssdb.o
|
rpc_server/spoolss/spoolssdb.o
|
||||||
REQUIRED_SUBSYSTEMS = \
|
REQUIRED_SUBSYSTEMS = \
|
||||||
SAMDB \
|
|
||||||
DCERPC_COMMON
|
DCERPC_COMMON
|
||||||
# End MODULE dcerpc_lsa
|
# End MODULE dcerpc_lsa
|
||||||
################################################
|
################################################
|
||||||
|
@ -24,28 +24,29 @@
|
|||||||
#include "rpc_server/common/common.h"
|
#include "rpc_server/common/common.h"
|
||||||
#include "rpc_server/spoolss/dcesrv_spoolss.h"
|
#include "rpc_server/spoolss/dcesrv_spoolss.h"
|
||||||
|
|
||||||
|
static WERROR spoolss_EnumPrinters1(TALLOC_CTX *mem_ctx,
|
||||||
static WERROR spoolss_EnumPrinters1(TALLOC_CTX *mem_ctx, void *spoolss_ctx,
|
struct ldb_message **msgs, int num_msgs,
|
||||||
struct ndr_push *ndr, uint32_t *count)
|
struct ndr_push *ndr)
|
||||||
{
|
{
|
||||||
struct spoolss_PrinterInfo1 info[2];
|
struct spoolss_PrinterInfo1 *info;
|
||||||
|
int i;
|
||||||
|
|
||||||
info[0].flags = 0x80;
|
info = talloc(mem_ctx, num_msgs * sizeof(struct spoolss_PrinterInfo1));
|
||||||
info[0].name = "p";
|
|
||||||
info[0].description = "a printer";
|
|
||||||
info[0].comment = "a comment";
|
|
||||||
|
|
||||||
info[1].flags = 0x80;
|
if (!info)
|
||||||
info[1].name = "p2";
|
return WERR_NOMEM;
|
||||||
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,
|
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);
|
(ndr_push_flags_fn_t)ndr_push_spoolss_PrinterInfo1);
|
||||||
|
|
||||||
*count = 2;
|
|
||||||
|
|
||||||
return WERR_OK;
|
return WERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,22 +59,27 @@ static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CT
|
|||||||
struct ndr_push *ndr;
|
struct ndr_push *ndr;
|
||||||
void *spoolss_ctx;
|
void *spoolss_ctx;
|
||||||
WERROR result;
|
WERROR result;
|
||||||
|
struct ldb_message **msgs;
|
||||||
|
int ret;
|
||||||
|
|
||||||
spoolss_ctx = spoolssdb_connect();
|
spoolss_ctx = spoolssdb_connect();
|
||||||
if (spoolss_ctx == NULL)
|
if (spoolss_ctx == NULL)
|
||||||
return WERR_NOMEM;
|
return WERR_NOMEM;
|
||||||
|
|
||||||
|
ret = spoolssdb_search(spoolss_ctx, mem_ctx, NULL, &msgs, NULL,
|
||||||
|
"(&(objectclass=printer))");
|
||||||
|
|
||||||
ndr = ndr_push_init();
|
ndr = ndr_push_init();
|
||||||
|
|
||||||
|
r->out.count = 0;
|
||||||
|
*r->out.buf_size = 0;
|
||||||
|
|
||||||
switch(r->in.level) {
|
switch(r->in.level) {
|
||||||
case 1:
|
case 1:
|
||||||
result = spoolss_EnumPrinters1(
|
result = spoolss_EnumPrinters1(mem_ctx, msgs, ret, ndr);
|
||||||
mem_ctx, spoolss_ctx, ndr, &r->out.count);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
r->out.buffer = NULL;
|
r->out.buffer = NULL;
|
||||||
*r->out.buf_size = 0;
|
|
||||||
r->out.count = 0;
|
|
||||||
result = WERR_INVALID_PARAM;
|
result = WERR_INVALID_PARAM;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -87,3 +87,25 @@ void spoolssdb_close(void *ctx)
|
|||||||
spoolss_ctx->ldb = NULL;
|
spoolss_ctx->ldb = NULL;
|
||||||
free(spoolss_ctx);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user