diff options
author | Rafal Szczesniak <mimir@samba.org> | 2005-06-07 23:24:10 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:17:48 -0500 |
commit | 7b47fad5d61a63f46314e29e797709eb0c860e9b (patch) | |
tree | 928474e6a7fa9850f710f4d6c1d2db9d1e1d340b /source4 | |
parent | ae6907c5c8695ef34ef16be3cad67a0d28ac5dfd (diff) | |
download | samba-7b47fad5d61a63f46314e29e797709eb0c860e9b.tar.gz samba-7b47fad5d61a63f46314e29e797709eb0c860e9b.tar.bz2 samba-7b47fad5d61a63f46314e29e797709eb0c860e9b.zip |
r7380: Mistakenly put one file twice in command line. Here's source of
CreateUser call. It serves one level of call by now. Once any
more is needed it can be placed, of course.
rafal
(This used to be commit 80e2f04ce154338fb0208c60b5fab4e96253bb04)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/libnet/libnet_user.c | 69 |
1 files changed, 36 insertions, 33 deletions
diff --git a/source4/libnet/libnet_user.c b/source4/libnet/libnet_user.c index f65e846648..23560ea7e6 100644 --- a/source4/libnet/libnet_user.c +++ b/source4/libnet/libnet_user.c @@ -21,35 +21,22 @@ #include "includes.h" #include "libnet/libnet.h" +#include "libnet/composite.h" #include "librpc/gen_ndr/ndr_samr.h" -static NTSTATUS libnet_CreateUser_generic(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, union libnet_CreateUser *r) -{ - NTSTATUS status; - union libnet_CreateUser r2; - - r2.samr.level = LIBNET_CREATE_USER_SAMR; - r2.samr.in.user_name = r->generic.in.user_name; - r2.samr.in.domain_name = r->generic.in.domain_name; - - status = libnet_CreateUser(ctx, mem_ctx, &r2); - - r->generic.out.error_string = r2.samr.out.error_string; - - return status; -} - - -static NTSTATUS libnet_CreateUser_samr(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, union libnet_CreateUser *r) +NTSTATUS libnet_CreateUser(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, struct libnet_CreateUser *r) { NTSTATUS status; union libnet_rpc_connect cn; union libnet_find_pdc fp; + struct dcerpc_pipe *pipe; + struct rpc_composite_domain_open dom_io; + struct rpc_composite_useradd user_io; /* find domain pdc */ fp.generic.level = LIBNET_FIND_PDC_GENERIC; - fp.generic.in.domain_name = r->samr.in.domain_name; + fp.generic.in.domain_name = r->in.domain_name; status = libnet_find_pdc(ctx, mem_ctx, &fp); if (!NT_STATUS_IS_OK(status)) return status; @@ -63,25 +50,41 @@ static NTSTATUS libnet_CreateUser_samr(struct libnet_context *ctx, TALLOC_CTX *m status = libnet_rpc_connect(ctx, mem_ctx, &cn); if (!NT_STATUS_IS_OK(status)) { - r->samr.out.error_string = talloc_asprintf(mem_ctx, - "Connection to SAMR pipe domain '%s' PDC failed: %s\n", - r->samr.in.domain_name, nt_errstr(status)); + r->out.error_string = talloc_asprintf(mem_ctx, + "Connection to SAMR pipe domain '%s' PDC failed: %s\n", + r->in.domain_name, nt_errstr(status)); return status; } - /* create user via samr call (to be continued) */ - return status; -} + ctx->samr = cn.pdc.out.dcerpc_pipe; + /* open connected domain */ + dom_io.in.domain_name = r->in.domain_name; + dom_io.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + + status = rpc_composite_domain_open(ctx->samr, mem_ctx, &dom_io); + if (!NT_STATUS_IS_OK(status)) { + r->out.error_string = talloc_asprintf(mem_ctx, + "Creating user account failed: %s\n", + nt_errstr(status)); + return status; + } -NTSTATUS libnet_CreateUser(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, union libnet_CreateUser *r) -{ - switch (r->generic.level) { - case LIBNET_CREATE_USER_GENERIC: - return libnet_CreateUser_generic(ctx, mem_ctx, r); - case LIBNET_CREATE_USER_SAMR: - return libnet_CreateUser_samr(ctx, mem_ctx, r); + ctx->domain_handle = dom_io.out.domain_handle; + + /* create user */ + user_io.in.username = r->in.user_name; + user_io.in.domain_handle = dom_io.out.domain_handle; + + status = rpc_composite_useradd(ctx->samr, mem_ctx, &user_io); + if (!NT_STATUS_IS_OK(status)) { + r->out.error_string = talloc_asprintf(mem_ctx, + "Creating user account failed: %s\n", + nt_errstr(status)); + return status; } - return NT_STATUS_INVALID_LEVEL; + ctx->user_handle = user_io.out.user_handle; + + return status; } |