summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-11-18 10:21:05 +0000
committerAndrew Tridgell <tridge@samba.org>2003-11-18 10:21:05 +0000
commitbdf0578621520ca52c7f6834fb337a761ada1dad (patch)
tree6057204bfa742e631887576e3c887901a0d623e9 /source4
parentd1667d5799a873d2fe55d9ba58dc776ddd0b90f5 (diff)
downloadsamba-bdf0578621520ca52c7f6834fb337a761ada1dad.tar.gz
samba-bdf0578621520ca52c7f6834fb337a761ada1dad.tar.bz2
samba-bdf0578621520ca52c7f6834fb337a761ada1dad.zip
added samr_CreateUser() samr_DeleteUser(). The test suite creates a
test user called "samrtorturetest" and then deletes it. The next step is to do all possible user operations on that temporary user. (This used to be commit 41fc922954bd8ec461a79a22cc903e63902c7401)
Diffstat (limited to 'source4')
-rw-r--r--source4/librpc/idl/samr.idl10
-rw-r--r--source4/librpc/ndr/ndr_samr.c55
-rw-r--r--source4/librpc/ndr/ndr_spoolss.c64
-rw-r--r--source4/librpc/ndr/ndr_spoolss.h12
-rw-r--r--source4/librpc/rpc/rpc_spoolss.c1
-rw-r--r--source4/torture/rpc/samr.c44
6 files changed, 70 insertions, 116 deletions
diff --git a/source4/librpc/idl/samr.idl b/source4/librpc/idl/samr.idl
index 2ff79c2fd3..60e6a98e0b 100644
--- a/source4/librpc/idl/samr.idl
+++ b/source4/librpc/idl/samr.idl
@@ -44,7 +44,7 @@
/* Function: 0x05 */
typedef struct {
[value(2*strlen_m(r->name))] uint16 name_len;
- [value(r->name_len)] uint16 name_size;
+ [value(2*strlen_m(r->name))] uint16 name_size;
unistr_noterm *name;
} samr_Name;
@@ -213,10 +213,10 @@
/* Function 0x0c */
NTSTATUS samr_CreateUser(
[in,ref] policy_handle *handle,
- [in] samr_Name *username,
+ [in,ref] samr_Name *username,
[in] uint32 access_mask,
- [out] policy_handle *acct_handle,
- [out] uint32 *rid
+ [out,ref] policy_handle *acct_handle,
+ [out,ref] uint32 *rid
);
/************************/
@@ -412,7 +412,7 @@
/************************/
/* Function 0x23 */
NTSTATUS samr_DeleteUser(
- [in,out] policy_handle *handle
+ [in,out,ref] policy_handle *handle
);
/************************/
diff --git a/source4/librpc/ndr/ndr_samr.c b/source4/librpc/ndr/ndr_samr.c
index 2cd69fb819..c98d47b573 100644
--- a/source4/librpc/ndr/ndr_samr.c
+++ b/source4/librpc/ndr/ndr_samr.c
@@ -46,7 +46,7 @@ NTSTATUS ndr_push_samr_Name(struct ndr_push *ndr, int ndr_flags, struct samr_Nam
NDR_CHECK(ndr_push_struct_start(ndr));
NDR_CHECK(ndr_push_align(ndr, 4));
NDR_CHECK(ndr_push_uint16(ndr, 2*strlen_m(r->name)));
- NDR_CHECK(ndr_push_uint16(ndr, r->name_len));
+ NDR_CHECK(ndr_push_uint16(ndr, 2*strlen_m(r->name)));
NDR_CHECK(ndr_push_ptr(ndr, r->name));
ndr_push_struct_end(ndr);
buffers:
@@ -116,10 +116,7 @@ NTSTATUS ndr_push_samr_EnumDomainGroups(struct ndr_push *ndr, struct samr_EnumDo
NTSTATUS ndr_push_samr_CreateUser(struct ndr_push *ndr, struct samr_CreateUser *r)
{
NDR_CHECK(ndr_push_policy_handle(ndr, r->in.handle));
- NDR_CHECK(ndr_push_ptr(ndr, r->in.username));
- if (r->in.username) {
- NDR_CHECK(ndr_push_samr_Name(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.username));
- }
+ NDR_CHECK(ndr_push_samr_Name(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.username));
NDR_CHECK(ndr_push_uint32(ndr, r->in.access_mask));
return NT_STATUS_OK;
@@ -302,10 +299,7 @@ NTSTATUS ndr_push_samr_OpenUser(struct ndr_push *ndr, struct samr_OpenUser *r)
NTSTATUS ndr_push_samr_DeleteUser(struct ndr_push *ndr, struct samr_DeleteUser *r)
{
- NDR_CHECK(ndr_push_ptr(ndr, r->in.handle));
- if (r->in.handle) {
- NDR_CHECK(ndr_push_policy_handle(ndr, r->in.handle));
- }
+ NDR_CHECK(ndr_push_policy_handle(ndr, r->in.handle));
return NT_STATUS_OK;
}
@@ -1050,26 +1044,8 @@ NTSTATUS ndr_pull_samr_EnumDomainGroups(struct ndr_pull *ndr, struct samr_EnumDo
NTSTATUS ndr_pull_samr_CreateUser(struct ndr_pull *ndr, struct samr_CreateUser *r)
{
- uint32 _ptr_acct_handle;
- uint32 _ptr_rid;
- NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_acct_handle));
- if (_ptr_acct_handle) {
- NDR_ALLOC(ndr, r->out.acct_handle);
- } else {
- r->out.acct_handle = NULL;
- }
- if (r->out.acct_handle) {
- NDR_CHECK(ndr_pull_policy_handle(ndr, r->out.acct_handle));
- }
- NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_rid));
- if (_ptr_rid) {
- NDR_ALLOC(ndr, r->out.rid);
- } else {
- r->out.rid = NULL;
- }
- if (r->out.rid) {
- NDR_CHECK(ndr_pull_uint32(ndr, r->out.rid));
- }
+ NDR_CHECK(ndr_pull_policy_handle(ndr, r->out.acct_handle));
+ NDR_CHECK(ndr_pull_uint32(ndr, r->out.rid));
NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result));
return NT_STATUS_OK;
@@ -1525,16 +1501,7 @@ NTSTATUS ndr_pull_samr_OpenUser(struct ndr_pull *ndr, struct samr_OpenUser *r)
NTSTATUS ndr_pull_samr_DeleteUser(struct ndr_pull *ndr, struct samr_DeleteUser *r)
{
- uint32 _ptr_handle;
- NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_handle));
- if (_ptr_handle) {
- NDR_ALLOC(ndr, r->out.handle);
- } else {
- r->out.handle = NULL;
- }
- if (r->out.handle) {
- NDR_CHECK(ndr_pull_policy_handle(ndr, r->out.handle));
- }
+ NDR_CHECK(ndr_pull_policy_handle(ndr, r->out.handle));
NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result));
return NT_STATUS_OK;
@@ -2975,9 +2942,7 @@ void ndr_print_samr_CreateUser(struct ndr_print *ndr, const char *name, int flag
ndr->depth--;
ndr_print_ptr(ndr, "username", r->in.username);
ndr->depth++;
- if (r->in.username) {
ndr_print_samr_Name(ndr, "username", r->in.username);
- }
ndr->depth--;
ndr_print_uint32(ndr, "access_mask", r->in.access_mask);
ndr->depth--;
@@ -2987,15 +2952,11 @@ void ndr_print_samr_CreateUser(struct ndr_print *ndr, const char *name, int flag
ndr->depth++;
ndr_print_ptr(ndr, "acct_handle", r->out.acct_handle);
ndr->depth++;
- if (r->out.acct_handle) {
ndr_print_policy_handle(ndr, "acct_handle", r->out.acct_handle);
- }
ndr->depth--;
ndr_print_ptr(ndr, "rid", r->out.rid);
ndr->depth++;
- if (r->out.rid) {
ndr_print_uint32(ndr, "rid", *r->out.rid);
- }
ndr->depth--;
ndr_print_NTSTATUS(ndr, "result", &r->out.result);
ndr->depth--;
@@ -3652,9 +3613,7 @@ void ndr_print_samr_DeleteUser(struct ndr_print *ndr, const char *name, int flag
ndr->depth++;
ndr_print_ptr(ndr, "handle", r->in.handle);
ndr->depth++;
- if (r->in.handle) {
ndr_print_policy_handle(ndr, "handle", r->in.handle);
- }
ndr->depth--;
ndr->depth--;
}
@@ -3663,9 +3622,7 @@ void ndr_print_samr_DeleteUser(struct ndr_print *ndr, const char *name, int flag
ndr->depth++;
ndr_print_ptr(ndr, "handle", r->out.handle);
ndr->depth++;
- if (r->out.handle) {
ndr_print_policy_handle(ndr, "handle", r->out.handle);
- }
ndr->depth--;
ndr_print_NTSTATUS(ndr, "result", &r->out.result);
ndr->depth--;
diff --git a/source4/librpc/ndr/ndr_spoolss.c b/source4/librpc/ndr/ndr_spoolss.c
index 285692a628..f88e12dd2c 100644
--- a/source4/librpc/ndr/ndr_spoolss.c
+++ b/source4/librpc/ndr/ndr_spoolss.c
@@ -852,11 +852,7 @@ NTSTATUS ndr_push_spoolss_EnumPrinterData(struct ndr_push *ndr, struct spoolss_E
NDR_CHECK(ndr_push_policy_handle(ndr, r->in.handle));
NDR_CHECK(ndr_push_uint32(ndr, r->in.enum_index));
NDR_CHECK(ndr_push_uint32(ndr, r->in.value_offered));
- NDR_CHECK(ndr_push_ptr(ndr, r->in.buffer));
- if (r->in.buffer) {
- NDR_CHECK(ndr_push_DATA_BLOB(ndr, *r->in.buffer));
- }
- NDR_CHECK(ndr_push_uint32(ndr, *r->in.buf_size));
+ NDR_CHECK(ndr_push_uint32(ndr, *r->in.data_size));
return NT_STATUS_OK;
}
@@ -1797,31 +1793,12 @@ NTSTATUS ndr_pull_spoolss_47(struct ndr_pull *ndr, struct spoolss_47 *r)
NTSTATUS ndr_pull_spoolss_EnumPrinterData(struct ndr_pull *ndr, struct spoolss_EnumPrinterData *r)
{
- uint32 _ptr_value_name;
- uint32 _ptr_buffer;
- NDR_CHECK(ndr_pull_uint32(ndr, &r->out.value_len));
- NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_value_name));
- if (_ptr_value_name) {
- NDR_ALLOC(ndr, r->out.value_name);
- } else {
- r->out.value_name = NULL;
- }
- if (r->out.value_name) {
- NDR_CHECK(ndr_pull_unistr(ndr, &r->out.value_name));
- }
+ NDR_CHECK(ndr_pull_DATA_BLOB(ndr, &r->out.value));
NDR_CHECK(ndr_pull_uint32(ndr, &r->out.value_needed));
NDR_CHECK(ndr_pull_uint32(ndr, &r->out.printerdata_type));
- NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_buffer));
- if (_ptr_buffer) {
- NDR_ALLOC(ndr, r->out.buffer);
- } else {
- r->out.buffer = NULL;
- }
- if (r->out.buffer) {
- NDR_CHECK(ndr_pull_DATA_BLOB(ndr, r->out.buffer));
- }
- NDR_CHECK(ndr_pull_uint32(ndr, r->out.buf_size));
- NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result));
+ NDR_CHECK(ndr_pull_DATA_BLOB(ndr, &r->out.data));
+ NDR_CHECK(ndr_pull_uint32(ndr, r->out.data_size));
+ NDR_CHECK(ndr_pull_WERROR(ndr, &r->out.result));
return NT_STATUS_OK;
}
@@ -3680,41 +3657,24 @@ void ndr_print_spoolss_EnumPrinterData(struct ndr_print *ndr, const char *name,
ndr->depth--;
ndr_print_uint32(ndr, "enum_index", r->in.enum_index);
ndr_print_uint32(ndr, "value_offered", r->in.value_offered);
- ndr_print_ptr(ndr, "buffer", r->in.buffer);
+ ndr_print_ptr(ndr, "data_size", r->in.data_size);
ndr->depth++;
- if (r->in.buffer) {
- ndr_print_DATA_BLOB(ndr, "buffer", *r->in.buffer);
- }
- ndr->depth--;
- ndr_print_ptr(ndr, "buf_size", r->in.buf_size);
- ndr->depth++;
- ndr_print_uint32(ndr, "buf_size", *r->in.buf_size);
+ ndr_print_uint32(ndr, "data_size", *r->in.data_size);
ndr->depth--;
ndr->depth--;
}
if (flags & NDR_OUT) {
ndr_print_struct(ndr, "out", "spoolss_EnumPrinterData");
ndr->depth++;
- ndr_print_uint32(ndr, "value_len", r->out.value_len);
- ndr_print_ptr(ndr, "value_name", r->out.value_name);
- ndr->depth++;
- if (r->out.value_name) {
- ndr_print_unistr(ndr, "value_name", r->out.value_name);
- }
- ndr->depth--;
+ ndr_print_DATA_BLOB(ndr, "value", r->out.value);
ndr_print_uint32(ndr, "value_needed", r->out.value_needed);
ndr_print_uint32(ndr, "printerdata_type", r->out.printerdata_type);
- ndr_print_ptr(ndr, "buffer", r->out.buffer);
- ndr->depth++;
- if (r->out.buffer) {
- ndr_print_DATA_BLOB(ndr, "buffer", *r->out.buffer);
- }
- ndr->depth--;
- ndr_print_ptr(ndr, "buf_size", r->out.buf_size);
+ ndr_print_DATA_BLOB(ndr, "data", r->out.data);
+ ndr_print_ptr(ndr, "data_size", r->out.data_size);
ndr->depth++;
- ndr_print_uint32(ndr, "buf_size", *r->out.buf_size);
+ ndr_print_uint32(ndr, "data_size", *r->out.data_size);
ndr->depth--;
- ndr_print_NTSTATUS(ndr, "result", &r->out.result);
+ ndr_print_WERROR(ndr, "result", &r->out.result);
ndr->depth--;
}
ndr->depth--;
diff --git a/source4/librpc/ndr/ndr_spoolss.h b/source4/librpc/ndr/ndr_spoolss.h
index 264ad3d442..6530375fc8 100644
--- a/source4/librpc/ndr/ndr_spoolss.h
+++ b/source4/librpc/ndr/ndr_spoolss.h
@@ -996,18 +996,16 @@ struct spoolss_EnumPrinterData {
struct policy_handle *handle;
uint32 enum_index;
uint32 value_offered;
- DATA_BLOB *buffer;
- uint32 *buf_size;
+ uint32 *data_size;
} in;
struct {
- uint32 value_len;
- const char *value_name;
+ DATA_BLOB value;
uint32 value_needed;
uint32 printerdata_type;
- DATA_BLOB *buffer;
- uint32 *buf_size;
- NTSTATUS result;
+ DATA_BLOB data;
+ uint32 *data_size;
+ WERROR result;
} out;
};
diff --git a/source4/librpc/rpc/rpc_spoolss.c b/source4/librpc/rpc/rpc_spoolss.c
index 19dd3be336..60645498ee 100644
--- a/source4/librpc/rpc/rpc_spoolss.c
+++ b/source4/librpc/rpc/rpc_spoolss.c
@@ -1526,7 +1526,6 @@ NTSTATUS dcerpc_spoolss_EnumPrinterData(struct dcerpc_pipe *p, TALLOC_CTX *mem_c
if (NT_STATUS_IS_OK(status) && (p->flags & DCERPC_DEBUG_PRINT_OUT)) {
NDR_PRINT_OUT_DEBUG(spoolss_EnumPrinterData, r);
}
- if (NT_STATUS_IS_OK(status)) status = r->out.result;
return status;
}
diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c
index 79f64005be..415f899947 100644
--- a/source4/torture/rpc/samr.c
+++ b/source4/torture/rpc/samr.c
@@ -59,6 +59,48 @@ static BOOL test_QuerySecurity(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
+static BOOL test_CreateUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle)
+{
+ NTSTATUS status;
+ struct samr_CreateUser r;
+ struct samr_DeleteUser d;
+ struct policy_handle acct_handle;
+ uint32 rid;
+ struct samr_Name name;
+
+ name.name = "samrtorturetest";
+
+ r.in.handle = handle;
+ r.in.username = &name;
+ r.in.access_mask = SEC_RIGHTS_MAXIMUM_ALLOWED;
+ r.out.acct_handle = &acct_handle;
+ r.out.rid = &rid;
+
+ printf("Testing CreateUser(%s)\n", r.in.username->name);
+
+ status = dcerpc_samr_CreateUser(p, mem_ctx, &r);
+ if (!NT_STATUS_IS_OK(status) &&
+ !NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
+ printf("CreateUser failed - %s\n", nt_errstr(status));
+ return False;
+ }
+
+
+ printf("Testing DeleteUser\n");
+
+ d.in.handle = &acct_handle;
+ d.out.handle = &acct_handle;
+
+ status = dcerpc_samr_DeleteUser(p, mem_ctx, &d);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("DeleteUser failed - %s\n", nt_errstr(status));
+ return False;
+ }
+
+ return True;
+}
+
static BOOL test_QueryAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle)
{
@@ -400,11 +442,9 @@ static BOOL test_OpenDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
return False;
}
-#if 0
if (!test_CreateUser(p, mem_ctx, &domain_handle)) {
ret = False;
}
-#endif
if (!test_QuerySecurity(p, mem_ctx, &domain_handle)) {
ret = False;