summaryrefslogtreecommitdiff
path: root/source4/winbind/wb_async_helpers.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/winbind/wb_async_helpers.c')
-rw-r--r--source4/winbind/wb_async_helpers.c135
1 files changed, 0 insertions, 135 deletions
diff --git a/source4/winbind/wb_async_helpers.c b/source4/winbind/wb_async_helpers.c
index e89c27000b..f4de7d4284 100644
--- a/source4/winbind/wb_async_helpers.c
+++ b/source4/winbind/wb_async_helpers.c
@@ -29,141 +29,6 @@
#include "librpc/gen_ndr/ndr_irpc.h"
#include "libcli/auth/credentials.h"
-struct finddcs_state {
- struct composite_context *ctx;
- struct messaging_context *msg_ctx;
-
- const char *domain_name;
- const struct dom_sid *domain_sid;
-
- struct nbtd_getdcname r;
-
- int num_dcs;
- struct nbt_dc_name *dcs;
-};
-
-static void finddcs_resolve(struct composite_context *ctx);
-static void finddcs_getdc(struct irpc_request *ireq);
-
-struct composite_context *wb_finddcs_send(TALLOC_CTX *mem_ctx,
- const char *domain_name,
- const struct dom_sid *domain_sid,
- struct event_context *event_ctx,
- struct messaging_context *msg_ctx)
-{
- struct composite_context *result, *ctx;
- struct finddcs_state *state;
- struct nbt_name name;
-
- result = talloc(mem_ctx, struct composite_context);
- if (result == NULL) goto failed;
- result->state = COMPOSITE_STATE_IN_PROGRESS;
- result->async.fn = NULL;
- result->event_ctx = event_ctx;
-
- state = talloc(result, struct finddcs_state);
- if (state == NULL) goto failed;
- state->ctx = result;
- result->private_data = state;
-
- state->domain_name = talloc_strdup(state, domain_name);
- if (state->domain_name == NULL) goto failed;
- state->domain_sid = dom_sid_dup(state, domain_sid);
- if (state->domain_sid == NULL) goto failed;
- state->msg_ctx = msg_ctx;
-
- make_nbt_name(&name, state->domain_name, 0x1c);
- ctx = resolve_name_send(&name, result->event_ctx,
- lp_name_resolve_order());
-
- if (ctx == NULL) goto failed;
- ctx->async.fn = finddcs_resolve;
- ctx->async.private_data = state;
-
- return result;
-
-failed:
- talloc_free(result);
- return NULL;
-}
-
-static void finddcs_resolve(struct composite_context *ctx)
-{
- struct finddcs_state *state =
- talloc_get_type(ctx->async.private_data, struct finddcs_state);
- struct irpc_request *ireq;
- uint32_t *nbt_servers;
- const char *address;
-
- state->ctx->status = resolve_name_recv(ctx, state, &address);
- if (!composite_is_ok(state->ctx)) return;
-
- state->num_dcs = 1;
- state->dcs = talloc_array(state, struct nbt_dc_name, state->num_dcs);
- if (composite_nomem(state->dcs, state->ctx)) return;
-
- state->dcs[0].address = talloc_steal(state->dcs, address);
-
- nbt_servers = irpc_servers_byname(state->msg_ctx, "nbt_server");
- if ((nbt_servers == NULL) || (nbt_servers[0] == 0)) {
- composite_error(state->ctx, NT_STATUS_NO_LOGON_SERVERS);
- return;
- }
-
- state->r.in.domainname = state->domain_name;
- state->r.in.ip_address = state->dcs[0].address;
- state->r.in.my_computername = lp_netbios_name();
- state->r.in.my_accountname = talloc_asprintf(state, "%s$",
- lp_netbios_name());
- if (composite_nomem(state->r.in.my_accountname, state->ctx)) return;
- state->r.in.account_control = ACB_WSTRUST;
- state->r.in.domain_sid = dom_sid_dup(state, state->domain_sid);
- if (composite_nomem(state->r.in.domain_sid, state->ctx)) return;
-
- ireq = irpc_call_send(state->msg_ctx, nbt_servers[0],
- &dcerpc_table_irpc, DCERPC_NBTD_GETDCNAME,
- &state->r, state);
- composite_continue_irpc(state->ctx, ireq, finddcs_getdc, state);
-}
-
-static void finddcs_getdc(struct irpc_request *ireq)
-{
- struct finddcs_state *state =
- talloc_get_type(ireq->async.private, struct finddcs_state);
-
- state->ctx->status = irpc_call_recv(ireq);
- if (!composite_is_ok(state->ctx)) return;
-
- state->dcs[0].name = talloc_steal(state->dcs, state->r.out.dcname);
- composite_done(state->ctx);
-}
-
-NTSTATUS wb_finddcs_recv(struct composite_context *c, TALLOC_CTX *mem_ctx,
- int *num_dcs, struct nbt_dc_name **dcs)
-{
- NTSTATUS status = composite_wait(c);
- if (NT_STATUS_IS_OK(status)) {
- struct finddcs_state *state =
- talloc_get_type(c->private_data, struct finddcs_state);
- *num_dcs = state->num_dcs;
- *dcs = talloc_steal(mem_ctx, state->dcs);
- }
- talloc_free(c);
- return status;
-}
-
-NTSTATUS wb_finddcs(TALLOC_CTX *mem_ctx,
- const char *domain_name, const struct dom_sid *domain_sid,
- struct event_context *event_ctx,
- struct messaging_context *msg_ctx,
- int *num_dcs, struct nbt_dc_name **dcs)
-{
- struct composite_context *c = wb_finddcs_send(mem_ctx,
- domain_name, domain_sid,
- event_ctx, msg_ctx);
- return wb_finddcs_recv(c, mem_ctx, num_dcs, dcs);
-}
-
struct get_schannel_creds_state {
struct cli_credentials *wks_creds;
struct dcerpc_pipe *p;