diff options
Diffstat (limited to 'source4/winbind/wb_init_domain.c')
-rw-r--r-- | source4/winbind/wb_init_domain.c | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/source4/winbind/wb_init_domain.c b/source4/winbind/wb_init_domain.c index cdc1491f2b..eabb23dd45 100644 --- a/source4/winbind/wb_init_domain.c +++ b/source4/winbind/wb_init_domain.c @@ -142,25 +142,26 @@ struct composite_context *wb_init_domain_send(TALLOC_CTX *mem_ctx, state->domain->dc_name = dom_info->dcs[0].name; state->domain->dc_address = dom_info->dcs[0].address; + state->domain->libnet_ctx = libnet_context_init(service->task->event_ctx); + /* Create a credentials structure */ - state->domain->schannel_creds = cli_credentials_init(state->domain); - if (state->domain->schannel_creds == NULL) goto failed; + state->domain->libnet_ctx->cred = cli_credentials_init(state->domain); + if (state->domain->libnet_ctx->cred == NULL) goto failed; - cli_credentials_set_event_context(state->domain->schannel_creds, service->task->event_ctx); + cli_credentials_set_event_context(state->domain->libnet_ctx->cred, service->task->event_ctx); - cli_credentials_set_conf(state->domain->schannel_creds); + cli_credentials_set_conf(state->domain->libnet_ctx->cred); /* Connect the machine account to the credentials */ state->ctx->status = - cli_credentials_set_machine_account(state->domain-> - schannel_creds); + cli_credentials_set_machine_account(state->domain->libnet_ctx->cred); if (!NT_STATUS_IS_OK(state->ctx->status)) goto failed; state->domain->netlogon_binding = init_domain_binding(state, &dcerpc_table_netlogon); state->domain->netlogon_pipe = NULL; - if ((!cli_credentials_is_anonymous(state->domain->schannel_creds)) && + if ((!cli_credentials_is_anonymous(state->domain->libnet_ctx->cred)) && ((lp_server_role() == ROLE_DOMAIN_MEMBER) || (lp_server_role() == ROLE_DOMAIN_CONTROLLER)) && (dom_sid_equal(state->domain->info->sid, @@ -179,7 +180,7 @@ struct composite_context *wb_init_domain_send(TALLOC_CTX *mem_ctx, ctx = dcerpc_pipe_connect_b_send(state, state->domain->netlogon_binding, &dcerpc_table_netlogon, - state->domain->schannel_creds, + state->domain->libnet_ctx->cred, service->task->event_ctx); if (composite_nomem(ctx, state->ctx)) { @@ -220,14 +221,14 @@ static void init_domain_recv_netlogonpipe(struct composite_context *ctx) state->domain->lsa_binding->flags |= (DCERPC_SIGN); } - state->domain->lsa_pipe = NULL; + state->domain->libnet_ctx->lsa.pipe = NULL; /* this will make the secondary connection on the same IPC$ share, secured with SPNEGO or NTLMSSP */ ctx = dcerpc_secondary_auth_connection_send(state->domain->netlogon_pipe, state->domain->lsa_binding, &dcerpc_table_lsarpc, - state->domain->schannel_creds + state->domain->libnet_ctx->cred ); composite_continue(state->ctx, ctx, init_domain_recv_lsa_pipe, state); } @@ -253,7 +254,7 @@ static bool retry_with_schannel(struct init_domain_state *state, ctx = dcerpc_secondary_auth_connection_send(state->domain->netlogon_pipe, binding, table, - state->domain->schannel_creds); + state->domain->libnet_ctx->cred); composite_continue(state->ctx, ctx, continuation, state); return true; } else { @@ -271,7 +272,7 @@ static void init_domain_recv_lsa_pipe(struct composite_context *ctx) struct init_domain_state); state->ctx->status = dcerpc_secondary_auth_connection_recv(ctx, state->domain, - &state->domain->lsa_pipe); + &state->domain->libnet_ctx->lsa.pipe); if (NT_STATUS_EQUAL(state->ctx->status, NT_STATUS_LOGON_FAILURE)) { if (retry_with_schannel(state, state->domain->lsa_binding, &dcerpc_table_lsarpc, @@ -281,21 +282,19 @@ static void init_domain_recv_lsa_pipe(struct composite_context *ctx) } if (!composite_is_ok(state->ctx)) return; - talloc_steal(state->domain, state->domain->lsa_pipe); - talloc_steal(state->domain->lsa_pipe, state->domain->lsa_binding); - - state->domain->lsa_policy_handle = talloc(state, struct policy_handle); - if (composite_nomem(state->domain->lsa_policy_handle, state->ctx)) return; + talloc_steal(state->domain->libnet_ctx, state->domain->libnet_ctx->lsa.pipe); + talloc_steal(state->domain->libnet_ctx->lsa.pipe, state->domain->lsa_binding); + ZERO_STRUCT(state->domain->libnet_ctx->lsa.handle); state->lsa_openpolicy.in.system_name = talloc_asprintf(state, "\\\\%s", - dcerpc_server_name(state->domain->lsa_pipe)); + dcerpc_server_name(state->domain->libnet_ctx->lsa.pipe)); ZERO_STRUCT(state->objectattr); state->lsa_openpolicy.in.attr = &state->objectattr; state->lsa_openpolicy.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - state->lsa_openpolicy.out.handle = state->domain->lsa_policy_handle; + state->lsa_openpolicy.out.handle = &state->domain->libnet_ctx->lsa.handle; - req = dcerpc_lsa_OpenPolicy2_send(state->domain->lsa_pipe, state, + req = dcerpc_lsa_OpenPolicy2_send(state->domain->libnet_ctx->lsa.pipe, state, &state->lsa_openpolicy); composite_continue_rpc(state->ctx, req, init_domain_recv_lsa_policy, state); @@ -323,10 +322,10 @@ static void init_domain_recv_lsa_policy(struct rpc_request *req) state->ctx->status = state->lsa_openpolicy.out.result; if (!composite_is_ok(state->ctx)) return; - state->queryinfo.in.handle = state->domain->lsa_policy_handle; + state->queryinfo.in.handle = &state->domain->libnet_ctx->lsa.handle; state->queryinfo.in.level = LSA_POLICY_INFO_ACCOUNT_DOMAIN; - req = dcerpc_lsa_QueryInfoPolicy_send(state->domain->lsa_pipe, state, + req = dcerpc_lsa_QueryInfoPolicy_send(state->domain->libnet_ctx->lsa.pipe, state, &state->queryinfo); composite_continue_rpc(state->ctx, req, init_domain_recv_queryinfo, state); @@ -349,7 +348,7 @@ static void init_domain_recv_queryinfo(struct rpc_request *req) if (strcasecmp(state->domain->info->name, dominfo->name.string) != 0) { DEBUG(2, ("Expected domain name %s, DC %s said %s\n", state->domain->info->name, - dcerpc_server_name(state->domain->lsa_pipe), + dcerpc_server_name(state->domain->libnet_ctx->lsa.pipe), dominfo->name.string)); composite_error(state->ctx, NT_STATUS_INVALID_DOMAIN_STATE); return; @@ -358,7 +357,7 @@ static void init_domain_recv_queryinfo(struct rpc_request *req) if (!dom_sid_equal(state->domain->info->sid, dominfo->sid)) { DEBUG(2, ("Expected domain sid %s, DC %s said %s\n", dom_sid_string(state, state->domain->info->sid), - dcerpc_server_name(state->domain->lsa_pipe), + dcerpc_server_name(state->domain->libnet_ctx->lsa.pipe), dom_sid_string(state, dominfo->sid))); composite_error(state->ctx, NT_STATUS_INVALID_DOMAIN_STATE); return; @@ -370,7 +369,7 @@ static void init_domain_recv_queryinfo(struct rpc_request *req) * it needed schannel, then we need that here too) */ state->domain->samr_binding->flags = state->domain->lsa_binding->flags; - state->domain->samr_pipe = NULL; + state->domain->libnet_ctx->samr.pipe = NULL; ctx = wb_connect_samr_send(state, state->domain); composite_continue(state->ctx, ctx, init_domain_recv_samr, state); @@ -387,12 +386,12 @@ static void init_domain_recv_samr(struct composite_context *ctx) state->ctx->status = wb_connect_samr_recv( ctx, state->domain, - &state->domain->samr_pipe, - &state->domain->samr_handle, - &state->domain->domain_handle); + &state->domain->libnet_ctx->samr.pipe, + &state->domain->libnet_ctx->samr.handle, + &state->domain->libnet_ctx->samr.handle); if (!composite_is_ok(state->ctx)) return; - talloc_steal(state->domain->samr_pipe, state->domain->samr_binding); + talloc_steal(state->domain->libnet_ctx->samr.pipe, state->domain->samr_binding); state->domain->ldap_conn = ldap4_new_connection(state->domain, state->ctx->event_ctx); @@ -419,7 +418,7 @@ static void init_domain_recv_ldapconn(struct composite_context *ctx) state->domain->dc_name); state->ctx->status = ldap_bind_sasl(state->domain->ldap_conn, - state->domain->schannel_creds); + state->domain->libnet_ctx->cred); DEBUG(0, ("ldap_bind returned %s\n", nt_errstr(state->ctx->status))); } |