Fix the wbinfo test on the LDAP backend.
[metze/samba/wip.git] / source / winbind / wb_init_domain.c
index fbc2c0c80a4fa80d6d347d8a7521fc761fe0d3c7..c6dee825a904b481bdfede3025149234914c33fe 100644 (file)
@@ -76,7 +76,6 @@ static void init_domain_recv_netlogonpipe(struct composite_context *ctx);
 static void init_domain_recv_lsa_pipe(struct composite_context *ctx);
 static void init_domain_recv_lsa_policy(struct rpc_request *req);
 static void init_domain_recv_queryinfo(struct rpc_request *req);
-static void init_domain_recv_ldapconn(struct composite_context *ctx);
 static void init_domain_recv_samr(struct composite_context *ctx);
 
 static struct dcerpc_binding *init_domain_binding(struct init_domain_state *state, 
@@ -101,7 +100,8 @@ static struct dcerpc_binding *init_domain_binding(struct init_domain_state *stat
        binding->host = state->domain->dc_address;
 
        /* This shouldn't make a network call, as the mappings for named pipes are well known */
-       status = dcerpc_epm_map_binding(binding, binding, table, state->service->task->event_ctx);
+       status = dcerpc_epm_map_binding(binding, binding, table, state->service->task->event_ctx,
+                                       state->service->task->lp_ctx);
        if (!NT_STATUS_IS_OK(status)) {
                return NULL;
        }
@@ -143,19 +143,18 @@ 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);
+       state->domain->libnet_ctx = libnet_context_init(service->task->event_ctx, 
+                                                       service->task->lp_ctx);
 
        /* Create a credentials structure */
        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->libnet_ctx->cred, service->task->event_ctx);
-
        cli_credentials_set_conf(state->domain->libnet_ctx->cred, service->task->lp_ctx);
 
        /* Connect the machine account to the credentials */
        state->ctx->status =
-               cli_credentials_set_machine_account(state->domain->libnet_ctx->cred);
+               cli_credentials_set_machine_account(state->domain->libnet_ctx->cred, state->domain->libnet_ctx->lp_ctx);
        if (!NT_STATUS_IS_OK(state->ctx->status)) goto failed;
 
        state->domain->netlogon_binding = init_domain_binding(state, &ndr_table_netlogon);
@@ -182,7 +181,8 @@ struct composite_context *wb_init_domain_send(TALLOC_CTX *mem_ctx,
        ctx = dcerpc_pipe_connect_b_send(state, state->domain->netlogon_binding, 
                                         &ndr_table_netlogon,
                                         state->domain->libnet_ctx->cred,
-                                        service->task->event_ctx);
+                                        service->task->event_ctx,
+                                        service->task->lp_ctx);
        
        if (composite_nomem(ctx, state->ctx)) {
                goto failed;
@@ -208,7 +208,6 @@ static void init_domain_recv_netlogonpipe(struct composite_context *ctx)
                                                   &state->domain->netlogon_pipe);
        
        if (!composite_is_ok(state->ctx)) {
-               talloc_free(state->domain->netlogon_binding);
                return;
        }
        talloc_steal(state->domain->netlogon_pipe, state->domain->netlogon_binding);
@@ -229,7 +228,8 @@ static void init_domain_recv_netlogonpipe(struct composite_context *ctx)
        ctx = dcerpc_secondary_auth_connection_send(state->domain->netlogon_pipe,
                                                    state->domain->lsa_binding,
                                                    &ndr_table_lsarpc,
-                                                   state->domain->libnet_ctx->cred
+                                                   state->domain->libnet_ctx->cred,
+                                                   state->domain->libnet_ctx->lp_ctx
                );
        composite_continue(state->ctx, ctx, init_domain_recv_lsa_pipe, state);
 }
@@ -255,7 +255,8 @@ static bool retry_with_schannel(struct init_domain_state *state,
                ctx = dcerpc_secondary_auth_connection_send(state->domain->netlogon_pipe,
                                                            binding,
                                                            table, 
-                                                           state->domain->libnet_ctx->cred);
+                                                           state->domain->libnet_ctx->cred,
+                                                           state->domain->libnet_ctx->lp_ctx);
                composite_continue(state->ctx, ctx, continuation, state);               
                return true;
        } else {
@@ -399,36 +400,6 @@ static void init_domain_recv_samr(struct composite_context *ctx)
        state->domain->libnet_ctx->samr.name = state->domain->info->name;
        state->domain->libnet_ctx->samr.sid = state->domain->info->sid;
 
-       state->domain->ldap_conn =
-               ldap4_new_connection(state->domain, state->ctx->event_ctx);
-       composite_nomem(state->domain->ldap_conn, state->ctx);
-
-       ldap_url = talloc_asprintf(state, "ldap://%s/",
-                                  state->domain->dc_address);
-       composite_nomem(ldap_url, state->ctx);
-
-       ctx = ldap_connect_send(state->domain->ldap_conn, ldap_url);
-       composite_continue(state->ctx, ctx, init_domain_recv_ldapconn, state);
-}
-
-static void init_domain_recv_ldapconn(struct composite_context *ctx)
-{
-       struct init_domain_state *state =
-               talloc_get_type(ctx->async.private_data,
-                               struct init_domain_state);
-
-       state->ctx->status = ldap_connect_recv(ctx);
-       if (NT_STATUS_IS_OK(state->ctx->status)) {
-               state->domain->ldap_conn->host =
-                       talloc_strdup(state->domain->ldap_conn,
-                                     state->domain->dc_name);
-               state->ctx->status =
-                       ldap_bind_sasl(state->domain->ldap_conn,
-                                      state->domain->libnet_ctx->cred);
-               DEBUG(0, ("ldap_bind returned %s\n",
-                         nt_errstr(state->ctx->status)));
-       }
-
        composite_done(state->ctx);
 }