diff options
-rw-r--r-- | source4/libnet/libnet.c | 11 | ||||
-rw-r--r-- | source4/libnet/libnet.h | 16 | ||||
-rw-r--r-- | source4/libnet/libnet_domain.c | 466 | ||||
-rw-r--r-- | source4/libnet/libnet_domain.h | 15 | ||||
-rw-r--r-- | source4/libnet/libnet_rpc.c | 18 | ||||
-rw-r--r-- | source4/libnet/libnet_user.c | 34 |
6 files changed, 495 insertions, 65 deletions
diff --git a/source4/libnet/libnet.c b/source4/libnet/libnet.c index 0dca57926d..6626e94b6f 100644 --- a/source4/libnet/libnet.c +++ b/source4/libnet/libnet.c @@ -45,16 +45,15 @@ struct libnet_context *libnet_context_init(struct event_context *ev) /* name resolution methods */ ctx->name_res_methods = str_list_copy(ctx, lp_name_resolve_order()); - /* connected domain params */ - ZERO_STRUCT(ctx->domain); + /* connected services' params */ + ZERO_STRUCT(ctx->samr); + ZERO_STRUCT(ctx->lsa); /* currently opened user */ ZERO_STRUCT(ctx->user_handle); - /* init pipe pointers */ - ctx->samr_pipe = NULL; - ctx->lsa_pipe = NULL; - ctx->pipe = NULL; + /* init pipe pointer */ + ctx->pipe = NULL; return ctx; } diff --git a/source4/libnet/libnet.h b/source4/libnet/libnet.h index 293e4e6505..e394c1c88e 100644 --- a/source4/libnet/libnet.h +++ b/source4/libnet/libnet.h @@ -26,20 +26,26 @@ struct libnet_context { */ struct cli_credentials *cred; - /* pipes */ struct dcerpc_pipe *pipe; - struct dcerpc_pipe *lsa_pipe; - struct dcerpc_pipe *samr_pipe; - /* opened handles and related properties */ + /* samr connection parameters - opened handles and related properties */ struct { + struct dcerpc_pipe *pipe; const char *name; uint32_t access_mask; struct policy_handle handle; - } domain; + } samr; struct policy_handle user_handle; + /* lsa connection parameters - opened handles and related properties */ + struct { + struct dcerpc_pipe *pipe; + const char *name; + uint32_t access_mask; + struct policy_handle handle; + } lsa; + /* name resolution methods */ const char **name_res_methods; diff --git a/source4/libnet/libnet_domain.c b/source4/libnet/libnet_domain.c index 3c157b6d16..ca9ed85227 100644 --- a/source4/libnet/libnet_domain.c +++ b/source4/libnet/libnet_domain.c @@ -26,13 +26,14 @@ #include "libcli/composite/composite.h" #include "libnet/libnet.h" #include "librpc/gen_ndr/ndr_samr_c.h" +#include "librpc/gen_ndr/ndr_lsa_c.h" static void domain_open_handler(struct rpc_request*); enum domain_open_stage { DOMOPEN_CONNECT, DOMOPEN_LOOKUP, DOMOPEN_OPEN, DOMOPEN_CLOSE_EXISTING, DOMOPEN_RPC_CONNECT }; -struct domain_open_state { +struct domain_open_samr_state { enum domain_open_stage stage; struct libnet_context *ctx; struct dcerpc_pipe *pipe; @@ -56,10 +57,10 @@ struct domain_open_state { static void domain_open_rpc_connect(struct composite_context *ctx) { struct composite_context *c; - struct domain_open_state *s; + struct domain_open_samr_state *s; c = talloc_get_type(ctx->async.private_data, struct composite_context); - s = talloc_get_type(c->private_data, struct domain_open_state); + s = talloc_get_type(c->private_data, struct domain_open_samr_state); c->status = libnet_RpcConnect_recv(ctx, s->ctx, c, &s->rpcconn); if (!composite_is_ok(c)) return; @@ -87,16 +88,16 @@ static void domain_open_rpc_connect(struct composite_context *ctx) * handle */ static NTSTATUS domain_open_close(struct composite_context *c, - struct domain_open_state *s) + struct domain_open_samr_state *s) { /* receive samr_Close reply */ c->status = dcerpc_ndr_request_recv(s->req); NT_STATUS_NOT_OK_RETURN(c->status); /* reset domain handle and associated data in libnet_context */ - s->ctx->domain.name = NULL; - s->ctx->domain.access_mask = 0; - ZERO_STRUCT(s->ctx->domain.handle); + s->ctx->samr.name = NULL; + s->ctx->samr.access_mask = 0; + ZERO_STRUCT(s->ctx->samr.handle); /* preparing parameters for samr_Connect rpc call */ s->connect.in.system_name = 0; @@ -120,7 +121,7 @@ static NTSTATUS domain_open_close(struct composite_context *c, * Stage 1: Connect to SAM server. */ static NTSTATUS domain_open_connect(struct composite_context *c, - struct domain_open_state *s) + struct domain_open_samr_state *s) { struct samr_LookupDomain *r = &s->lookup; @@ -150,7 +151,7 @@ failure: * Stage 2: Lookup domain by name. */ static NTSTATUS domain_open_lookup(struct composite_context *c, - struct domain_open_state *s) + struct domain_open_samr_state *s) { struct samr_OpenDomain *r = &s->open; @@ -182,7 +183,7 @@ failure: * Stage 3: Open domain. */ static NTSTATUS domain_open_open(struct composite_context *c, - struct domain_open_state *s) + struct domain_open_samr_state *s) { /* receive samr_OpenDomain reply */ c->status = dcerpc_ndr_request_recv(s->req); @@ -203,7 +204,8 @@ static NTSTATUS domain_open_open(struct composite_context *c, static void domain_open_handler(struct rpc_request *req) { struct composite_context *c = req->async.private; - struct domain_open_state *s = talloc_get_type(c->private_data, struct domain_open_state); + struct domain_open_samr_state *s = talloc_get_type(c->private_data, + struct domain_open_samr_state); /* Stages of the call */ switch (s->stage) { @@ -243,17 +245,17 @@ static void domain_open_handler(struct rpc_request *req) * @param monitor pointer to monitor function that is passed monitor message */ -struct composite_context *libnet_DomainOpen_send(struct libnet_context *ctx, - struct libnet_DomainOpen *io, - void (*monitor)(struct monitor_msg*)) +struct composite_context *libnet_DomainOpenSamr_send(struct libnet_context *ctx, + struct libnet_DomainOpen *io, + void (*monitor)(struct monitor_msg*)) { struct composite_context *c; - struct domain_open_state *s; + struct domain_open_samr_state *s; c = talloc_zero(ctx, struct composite_context); if (c == NULL) return NULL; - s = talloc_zero(c, struct domain_open_state); + s = talloc_zero(c, struct domain_open_samr_state); if (composite_nomem(s, c)) return c; c->state = COMPOSITE_STATE_IN_PROGRESS; @@ -261,11 +263,11 @@ struct composite_context *libnet_DomainOpen_send(struct libnet_context *ctx, c->event_ctx = ctx->event_ctx; s->ctx = ctx; - s->pipe = ctx->samr_pipe; + s->pipe = ctx->samr.pipe; s->access_mask = io->in.access_mask; s->domain_name.string = io->in.domain_name; - if (ctx->samr_pipe == NULL) { + if (ctx->samr.pipe == NULL) { s->rpcconn.level = LIBNET_RPC_CONNECT_DC; s->rpcconn.in.name = io->in.domain_name; s->rpcconn.in.dcerpc_iface = &dcerpc_table_samr; @@ -282,9 +284,9 @@ struct composite_context *libnet_DomainOpen_send(struct libnet_context *ctx, /* libnet context's domain handle is not empty, so check out what was opened first, before doing anything */ - if (!policy_handle_empty(&ctx->domain.handle)) { - if (strequal(ctx->domain.name, io->in.domain_name) && - ctx->domain.access_mask == io->in.access_mask) { + if (!policy_handle_empty(&ctx->samr.handle)) { + if (strequal(ctx->samr.name, io->in.domain_name) && + ctx->samr.access_mask == io->in.access_mask) { /* this domain is already opened */ composite_done(c); @@ -293,7 +295,7 @@ struct composite_context *libnet_DomainOpen_send(struct libnet_context *ctx, } else { /* another domain or access rights have been requested - close the existing handle first */ - s->close.in.handle = &ctx->domain.handle; + s->close.in.handle = &ctx->samr.handle; /* send request to close domain handle */ s->req = dcerpc_samr_Close_send(s->pipe, c, &s->close); @@ -336,24 +338,173 @@ struct composite_context *libnet_DomainOpen_send(struct libnet_context *ctx, * @return nt status code of execution */ -NTSTATUS libnet_DomainOpen_recv(struct composite_context *c, struct libnet_context *ctx, - TALLOC_CTX *mem_ctx, struct libnet_DomainOpen *io) +NTSTATUS libnet_DomainOpenSamr_recv(struct composite_context *c, struct libnet_context *ctx, + TALLOC_CTX *mem_ctx, struct libnet_DomainOpen *io) { NTSTATUS status; - struct domain_open_state *s; + struct domain_open_samr_state *s; /* wait for results of sending request */ status = composite_wait(c); if (NT_STATUS_IS_OK(status) && io) { - s = talloc_get_type(c->private_data, struct domain_open_state); + s = talloc_get_type(c->private_data, struct domain_open_samr_state); io->out.domain_handle = s->domain_handle; /* store the resulting handle and related data for use by other libnet functions */ - ctx->domain.handle = s->domain_handle; - ctx->domain.name = talloc_strdup(ctx, s->domain_name.string); - ctx->domain.access_mask = s->access_mask; + ctx->samr.handle = s->domain_handle; + ctx->samr.name = talloc_strdup(ctx, s->domain_name.string); + ctx->samr.access_mask = s->access_mask; + } + + talloc_free(c); + return status; +} + + +struct domain_open_lsa_state { + const char *name; + uint32_t access_mask; + struct libnet_context *ctx; + struct libnet_RpcConnect rpcconn; + struct lsa_OpenPolicy2 openpol; + struct policy_handle handle; + struct dcerpc_pipe *pipe; +}; + + +static void continue_rpc_connect_lsa(struct composite_context *ctx); +static void continue_lsa_policy_open(struct rpc_request *req); + + +struct composite_context* libnet_DomainOpenLsa_send(struct libnet_context *ctx, + struct libnet_DomainOpen *io, + void (*monitor)(struct monitor_msg*)) +{ + struct composite_context *c; + struct domain_open_lsa_state *s; + struct composite_context *rpcconn_req; + struct rpc_request *openpol_req; + struct lsa_QosInfo *qos; + + c = composite_create(ctx, ctx->event_ctx); + if (c == NULL) return c; + + s = talloc_zero(c, struct domain_open_lsa_state); + if (composite_nomem(s, c)) return c; + + c->private_data = s; + + s->name = talloc_strdup(c, io->in.domain_name); + s->access_mask = io->in.access_mask; + s->ctx = ctx; + + if (ctx->lsa.pipe == NULL) { + s->rpcconn.level = LIBNET_RPC_CONNECT_DC; + s->rpcconn.in.name = talloc_strdup(c, io->in.domain_name); + s->rpcconn.in.dcerpc_iface = &dcerpc_table_lsarpc; + + rpcconn_req = libnet_RpcConnect_send(ctx, c, &s->rpcconn); + if (composite_nomem(rpcconn_req, c)) return c; + + composite_continue(c, rpcconn_req, continue_rpc_connect_lsa, c); + return c; + } + + s->pipe = ctx->lsa.pipe; + + s->openpol.in.system_name = s->name; + s->openpol.in.access_mask = s->access_mask; + s->openpol.in.attr = talloc_zero(c, struct lsa_ObjectAttribute); + + qos = talloc_zero(c, struct lsa_QosInfo); + qos->len = 0; + qos->impersonation_level = 2; + qos->context_mode = 1; + qos->effective_only = 0; + + s->openpol.in.attr->sec_qos = qos; + s->openpol.out.handle = &s->handle; + + openpol_req = dcerpc_lsa_OpenPolicy2_send(s->pipe, c, &s->openpol); + if (composite_nomem(openpol_req, c)) return c; + + composite_continue_rpc(c, openpol_req, continue_lsa_policy_open, c); + return c; +} + + +static void continue_rpc_connect_lsa(struct composite_context *ctx) +{ + struct composite_context *c; + struct domain_open_lsa_state *s; + struct lsa_QosInfo *qos; + struct rpc_request *openpol_req; + + c = talloc_get_type(ctx->async.private_data, struct composite_context); + s = talloc_get_type(c->private_data, struct domain_open_lsa_state); + + c->status = libnet_RpcConnect_recv(ctx, s->ctx, c, &s->rpcconn); + if (!composite_is_ok(c)) return; + + s->pipe = s->ctx->lsa.pipe; + + s->openpol.in.system_name = s->name; + s->openpol.in.access_mask = s->access_mask; + s->openpol.in.attr = talloc_zero(c, struct lsa_ObjectAttribute); + + qos = talloc_zero(c, struct lsa_QosInfo); + qos->len = 0; + qos->impersonation_level = 2; + qos->context_mode = 1; + qos->effective_only = 0; + + s->openpol.in.attr->sec_qos = qos; + s->openpol.out.handle = &s->handle; + + openpol_req = dcerpc_lsa_OpenPolicy2_send(s->pipe, c, &s->openpol); + if (composite_nomem(openpol_req, c)) return; + + composite_continue_rpc(c, openpol_req, continue_lsa_policy_open, c); +} + + +static void continue_lsa_policy_open(struct rpc_request *req) +{ + struct composite_context *c; + struct domain_open_lsa_state *s; + + c = talloc_get_type(req->async.private, struct composite_context); + s = talloc_get_type(c->private_data, struct domain_open_lsa_state); + + c->status = dcerpc_ndr_request_recv(req); + if (!composite_is_ok(c)) return; + + composite_done(c); +} + + +NTSTATUS libnet_DomainOpenLsa_recv(struct composite_context *c, struct libnet_context *ctx, + TALLOC_CTX *mem_ctx, struct libnet_DomainOpen *io) +{ + NTSTATUS status; + struct domain_open_lsa_state *s; + + status = composite_wait(c); + + if (NT_STATUS_IS_OK(status) && io) { + s = talloc_get_type(c->private_data, struct domain_open_lsa_state); + io->out.domain_handle = s->handle; + + ctx->lsa.handle = s->handle; + ctx->lsa.name = talloc_strdup(ctx, s->name); + ctx->lsa.access_mask = s->access_mask; + + } else if (!NT_STATUS_IS_OK(status)) { + io->out.error_string = talloc_asprintf(mem_ctx, + "Failed to open domain: %s", + nt_errstr(status)); } talloc_free(c); @@ -361,6 +512,47 @@ NTSTATUS libnet_DomainOpen_recv(struct composite_context *c, struct libnet_conte } +struct composite_context* libnet_DomainOpen_send(struct libnet_context *ctx, + struct libnet_DomainOpen *io, + void (*monitor)(struct monitor_msg*)) +{ + struct composite_context *c; + + switch (io->in.type) { + case DOMAIN_LSA: + c = libnet_DomainOpenLsa_send(ctx, io, monitor); + break; + + case DOMAIN_SAMR: + default: + c = libnet_DomainOpenSamr_send(ctx, io, monitor); + break; + } + + return c; +} + + +NTSTATUS libnet_DomainOpen_recv(struct composite_context *c, struct libnet_context *ctx, + TALLOC_CTX *mem_ctx, struct libnet_DomainOpen *io) +{ + NTSTATUS status; + + switch (io->in.type) { + case DOMAIN_LSA: + status = libnet_DomainOpenLsa_recv(c, ctx, mem_ctx, io); + break; + + case DOMAIN_SAMR: + default: + status = libnet_DomainOpenSamr_recv(c, ctx, mem_ctx, io); + break; + } + + return status; +} + + /** * Synchronous version of DomainOpen call * @@ -377,3 +569,219 @@ NTSTATUS libnet_DomainOpen(struct libnet_context *ctx, struct composite_context *c = libnet_DomainOpen_send(ctx, io, NULL); return libnet_DomainOpen_recv(c, ctx, mem_ctx, io); } + + +struct domain_close_lsa_state { + struct dcerpc_pipe *pipe; + struct lsa_Close close; + struct policy_handle handle; + + void (*monitor_fn)(struct monitor_msg*); +}; + + +static void continue_lsa_close(struct rpc_request *req); + + +struct composite_context* libnet_DomainCloseLsa_send(struct libnet_context *ctx, + struct libnet_DomainClose *io, + void (*monitor)(struct monitor_msg*)) +{ + struct composite_context *c; + struct domain_close_lsa_state *s; + struct rpc_request *close_req; + + c = composite_create(ctx, ctx->event_ctx); + if (c == NULL) return c; + + s = talloc_zero(c, struct domain_close_lsa_state); + if (composite_nomem(s, c)) return c; + + c->private_data = s; + s->monitor_fn = monitor; + + /* TODO: check if lsa pipe pointer is non-null */ + + if (!strequal(ctx->lsa.name, io->in.domain_name)) { + composite_error(c, NT_STATUS_INVALID_PARAMETER); + return c; + } + + s->pipe = ctx->lsa.pipe; + + s->close.in.handle = &ctx->lsa.handle; + s->close.out.handle = &s->handle; + + close_req = dcerpc_lsa_Close_send(s->pipe, c, &s->close); + if (composite_nomem(close_req, c)) return c; + + composite_continue_rpc(c, close_req, continue_lsa_close, c); + return c; +} + + +static void continue_lsa_close(struct rpc_request *req) +{ + struct composite_context *c; + struct domain_close_lsa_state *s; + + c = talloc_get_type(req->async.private, struct composite_context); + s = talloc_get_type(c->private_data, struct domain_close_lsa_state); + + c->status = dcerpc_ndr_request_recv(req); + if (!composite_is_ok(c)) return; + + composite_done(c); +} + + +NTSTATUS libnet_DomainCloseLsa_recv(struct composite_context *c, struct libnet_context *ctx, + TALLOC_CTX *mem_ctx, struct libnet_DomainClose *io) +{ + NTSTATUS status; + + status = composite_wait(c); + + if (NT_STATUS_IS_OK(status) && io) { + ctx->lsa.name = NULL; + ZERO_STRUCT(ctx->lsa.handle); + io->out.error_string = talloc_asprintf(mem_ctx, "Success"); + + } else if (!NT_STATUS_IS_OK(status)) { + io->out.error_string = talloc_asprintf(mem_ctx, "Error: %s", nt_errstr(status)); + } + + talloc_free(c); + return status; +} + + +struct domain_close_samr_state { + struct samr_Close close; + + void (*monitor_fn)(struct monitor_msg*); +}; + + +static void continue_samr_close(struct rpc_request *req); + + +struct composite_context* libnet_DomainCloseSamr_send(struct libnet_context *ctx, + struct libnet_DomainClose *io, + void (*monitor)(struct monitor_msg*)) +{ + struct composite_context *c; + struct domain_close_samr_state *s; + struct rpc_request *close_req; + + c = composite_create(ctx, ctx->event_ctx); + if (c == NULL) return c; + + s = talloc_zero(c, struct domain_close_samr_state); + if (composite_nomem(s, c)) return c; + + c->private_data = s; + s->monitor_fn = monitor; + + /* TODO: check if samr pipe pointer is non-null */ + + if (!strequal(ctx->samr.name, io->in.domain_name)) { + composite_error(c, NT_STATUS_INVALID_PARAMETER); + return c; + } + + s->close.in.handle = &ctx->samr.handle; + + close_req = dcerpc_samr_Close_send(ctx->samr.pipe, ctx, &s->close); + if (composite_nomem(close_req, c)) return c; + + composite_continue_rpc(c, close_req, continue_samr_close, c); + return c; +} + + +static void continue_samr_close(struct rpc_request *req) +{ + struct composite_context *c; + struct domain_close_samr_state *s; + + c = talloc_get_type(req->async.private, struct composite_context); + s = talloc_get_type(c->private_data, struct domain_close_samr_state); + + c->status = dcerpc_ndr_request_recv(req); + if (!composite_is_ok(c)) return; + + composite_done(c); +} + + +NTSTATUS libnet_DomainCloseSamr_recv(struct composite_context *c, struct libnet_context *ctx, + TALLOC_CTX *mem_ctx, struct libnet_DomainClose *io) +{ + NTSTATUS status; + + status = composite_wait(c); + + if (NT_STATUS_IS_OK(status) && io) { + ZERO_STRUCT(ctx->samr.handle); + ctx->samr.name = NULL; + io->out.error_string = talloc_asprintf(mem_ctx, "Success"); + + } else if (!NT_STATUS_IS_OK(status)) { + io->out.error_string = talloc_asprintf(mem_ctx, "Error: %s", nt_errstr(status)); + } + + talloc_free(c); + return status; +} + + +struct composite_context* libnet_DomainClose_send(struct libnet_context *ctx, + struct libnet_DomainClose *io, + void (*monitor)(struct monitor_msg*)) +{ + struct composite_context *c; + + switch (io->in.type) { + case DOMAIN_LSA: + c = libnet_DomainCloseLsa_send(ctx, io, monitor); + break; + + case DOMAIN_SAMR: + default: + c = libnet_DomainCloseSamr_send(ctx, io, monitor); + break; + } + + return c; +} + + +NTSTATUS libnet_DomainClose_recv(struct composite_context *c, struct libnet_context *ctx, + TALLOC_CTX *mem_ctx, struct libnet_DomainClose *io) +{ + NTSTATUS status; + + switch (io->in.type) { + case DOMAIN_LSA: + status = libnet_DomainCloseLsa_recv(c, ctx, mem_ctx, io); + break; + + case DOMAIN_SAMR: + default: + status = libnet_DomainCloseSamr_recv(c, ctx, mem_ctx, io); + break; + } + + return status; +} + + +NTSTATUS libnet_DomainClose(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, + struct libnet_DomainClose *io) +{ + struct composite_context *c; + + c = libnet_DomainClose_send(ctx, io, NULL); + return libnet_DomainClose_recv(c, ctx, mem_ctx, io); +} diff --git a/source4/libnet/libnet_domain.h b/source4/libnet/libnet_domain.h index 6dc4ed3f45..e9b1b87c66 100644 --- a/source4/libnet/libnet_domain.h +++ b/source4/libnet/libnet_domain.h @@ -19,16 +19,31 @@ */ +enum service_type { DOMAIN_SAMR, DOMAIN_LSA }; + /* * struct definition for opening a domain */ struct libnet_DomainOpen { struct { + enum service_type type; const char *domain_name; uint32_t access_mask; } in; struct { struct policy_handle domain_handle; + const char *error_string; + } out; +}; + + +struct libnet_DomainClose { + struct { + enum service_type type; + const char *domain_name; + } in; + struct { + const char *error_string; } out; }; diff --git a/source4/libnet/libnet_rpc.c b/source4/libnet/libnet_rpc.c index eedef7989d..53c8ba86a1 100644 --- a/source4/libnet/libnet_rpc.c +++ b/source4/libnet/libnet_rpc.c @@ -148,10 +148,10 @@ static NTSTATUS libnet_RpcConnectSrv_recv(struct composite_context *c, so that it can be used by other api functions even after short-term mem_ctx is freed */ if (r->in.dcerpc_iface == &dcerpc_table_samr) { - ctx->samr_pipe = talloc_reference(ctx, r->out.dcerpc_pipe); + ctx->samr.pipe = talloc_reference(ctx, r->out.dcerpc_pipe); } else if (r->in.dcerpc_iface == &dcerpc_table_lsarpc) { - ctx->lsa_pipe = talloc_reference(ctx, r->out.dcerpc_pipe); + ctx->lsa.pipe = talloc_reference(ctx, r->out.dcerpc_pipe); } } else { r->out.error_string = talloc_steal(mem_ctx, s->r.out.error_string); @@ -361,14 +361,16 @@ static NTSTATUS libnet_RpcConnectDC_recv(struct composite_context *c, so that it can be used by other api functions even after short-term mem_ctx is freed */ if (r->in.dcerpc_iface == &dcerpc_table_samr) { - ctx->samr_pipe = talloc_reference(ctx, r->out.dcerpc_pipe); + ctx->samr.pipe = talloc_reference(ctx, r->out.dcerpc_pipe); } else if (r->in.dcerpc_iface == &dcerpc_table_lsarpc) { - ctx->lsa_pipe = talloc_reference(ctx, r->out.dcerpc_pipe); + ctx->lsa.pipe = talloc_reference(ctx, r->out.dcerpc_pipe); } } else { - r->out.error_string = talloc_steal(mem_ctx, s->r.out.error_string); + r->out.error_string = talloc_asprintf(mem_ctx, + "Failed to rpc connect: %s", + nt_errstr(status)); } talloc_free(c); @@ -475,7 +477,7 @@ static void continue_dci_rpc_connect(struct composite_context *ctx) } /* prepare to open a policy handle on lsa pipe */ - s->lsa_pipe = s->ctx->lsa_pipe; + s->lsa_pipe = s->ctx->lsa.pipe; s->qos.len = 0; s->qos.impersonation_level = 2; @@ -726,10 +728,10 @@ static NTSTATUS libnet_RpcConnectDCInfo_recv(struct composite_context *c, struct so that it can be used by other api functions even after short-term mem_ctx is freed */ if (r->in.dcerpc_iface == &dcerpc_table_samr) { - ctx->samr_pipe = talloc_reference(ctx, r->out.dcerpc_pipe); + ctx->samr.pipe = talloc_reference(ctx, r->out.dcerpc_pipe); } else if (r->in.dcerpc_iface == &dcerpc_table_lsarpc) { - ctx->lsa_pipe = talloc_reference(ctx, r->out.dcerpc_pipe); + ctx->lsa.pipe = talloc_reference(ctx, r->out.dcerpc_pipe); } } else { diff --git a/source4/libnet/libnet_user.c b/source4/libnet/libnet_user.c index 947fc3dcb3..0bf324e19b 100644 --- a/source4/libnet/libnet_user.c +++ b/source4/libnet/libnet_user.c @@ -49,7 +49,7 @@ static struct composite_context* domain_opened(struct libnet_context *ctx, * if it's not been explicitly specified. */ - if (policy_handle_empty(&ctx->domain.handle)) { + if (policy_handle_empty(&ctx->samr.handle)) { domain_open->in.domain_name = cli_credentials_get_domain(ctx->cred); domain_open->in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; @@ -65,8 +65,8 @@ static struct composite_context* domain_opened(struct libnet_context *ctx, * opening a new domain otherwise. */ - if (policy_handle_empty(&ctx->domain.handle) || - !strequal(domain_name, ctx->domain.name)) { + if (policy_handle_empty(&ctx->samr.handle) || + !strequal(domain_name, ctx->samr.name)) { domain_open->in.domain_name = domain_name; domain_open->in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; @@ -143,10 +143,10 @@ struct composite_context* libnet_CreateUser_send(struct libnet_context *ctx, /* prepare arguments for useradd call */ s->user_add.in.username = r->in.user_name; - s->user_add.in.domain_handle = ctx->domain.handle; + s->user_add.in.domain_handle = ctx->samr.handle; /* send the request */ - create_req = libnet_rpc_useradd_send(ctx->samr_pipe, &s->user_add, monitor); + create_req = libnet_rpc_useradd_send(ctx->samr.pipe, &s->user_add, monitor); if (composite_nomem(create_req, c)) return c; /* set the next stage */ @@ -178,10 +178,10 @@ static void continue_domain_open_create(struct composite_context *ctx) /* prepare arguments for useradd call */ s->user_add.in.username = s->r.in.user_name; - s->user_add.in.domain_handle = s->ctx->domain.handle; + s->user_add.in.domain_handle = s->ctx->samr.handle; /* send the request */ - create_req = libnet_rpc_useradd_send(s->ctx->samr_pipe, &s->user_add, s->monitor_fn); + create_req = libnet_rpc_useradd_send(s->ctx->samr.pipe, &s->user_add, s->monitor_fn); if (composite_nomem(create_req, c)) return; /* set the next stage */ @@ -314,10 +314,10 @@ struct composite_context *libnet_DeleteUser_send(struct libnet_context *ctx, /* prepare arguments for userdel call */ s->user_del.in.username = r->in.user_name; - s->user_del.in.domain_handle = ctx->domain.handle; + s->user_del.in.domain_handle = ctx->samr.handle; /* send request */ - delete_req = libnet_rpc_userdel_send(ctx->samr_pipe, &s->user_del, monitor); + delete_req = libnet_rpc_userdel_send(ctx->samr.pipe, &s->user_del, monitor); if (composite_nomem(delete_req, c)) return c; /* set the next stage */ @@ -349,10 +349,10 @@ static void continue_domain_open_delete(struct composite_context *ctx) /* prepare arguments for userdel call */ s->user_del.in.username = s->r.in.user_name; - s->user_del.in.domain_handle = s->ctx->domain.handle; + s->user_del.in.domain_handle = s->ctx->samr.handle; /* send request */ - delete_req = libnet_rpc_userdel_send(s->ctx->samr_pipe, &s->user_del, s->monitor_fn); + delete_req = libnet_rpc_userdel_send(s->ctx->samr.pipe, &s->user_del, s->monitor_fn); if (composite_nomem(delete_req, c)) return; /* set the next stage */ @@ -470,9 +470,9 @@ struct composite_context *libnet_ModifyUser_send(struct libnet_context *ctx, if (prereq_ctx) return prereq_ctx; s->user_mod.in.username = r->in.user_name; - s->user_mod.in.domain_handle = ctx->domain.handle; + s->user_mod.in.domain_handle = ctx->samr.handle; - userinfo_req = libnet_rpc_userinfo_send(ctx->samr_pipe, &s->user_info, monitor); + userinfo_req = libnet_rpc_userinfo_send(ctx->samr.pipe, &s->user_info, monitor); if (composite_nomem(userinfo_req, c)) return c; composite_continue(c, userinfo_req, continue_rpc_userinfo, c); @@ -496,11 +496,11 @@ static void continue_domain_open_modify(struct composite_context *ctx) if (s->monitor_fn) s->monitor_fn(&msg); - s->user_info.in.domain_handle = s->ctx->domain.handle; + s->user_info.in.domain_handle = s->ctx->samr.handle; s->user_info.in.username = s->r.in.user_name; s->user_info.in.level = level; - userinfo_req = libnet_rpc_userinfo_send(s->ctx->samr_pipe, &s->user_info, s->monitor_fn); + userinfo_req = libnet_rpc_userinfo_send(s->ctx->samr.pipe, &s->user_info, s->monitor_fn); if (composite_nomem(userinfo_req, c)) return; composite_continue(c, userinfo_req, continue_rpc_userinfo, c); @@ -519,12 +519,12 @@ static void continue_rpc_userinfo(struct composite_context *ctx) c->status = libnet_rpc_userinfo_recv(ctx, c, &s->user_info); if (!composite_is_ok(c)) return; - s->user_mod.in.domain_handle = s->ctx->domain.handle; + s->user_mod.in.domain_handle = s->ctx->samr.handle; s->user_mod.in.username = s->r.in.user_name; c->status = set_user_changes(c, &s->user_mod.in.change, &s->user_info, &s->r); - usermod_req = libnet_rpc_usermod_send(s->ctx->samr_pipe, &s->user_mod, s->monitor_fn); + usermod_req = libnet_rpc_usermod_send(s->ctx->samr.pipe, &s->user_mod, s->monitor_fn); if (composite_nomem(usermod_req, c)) return; composite_continue(c, usermod_req, continue_rpc_usermod, c); |