mirror of
https://github.com/samba-team/samba.git
synced 2025-03-01 04:58:35 +03:00
s4:libcli/finddcs: use irpc_binding_handle_by_name()
metze
This commit is contained in:
parent
f2422a0faa
commit
3c4150522c
@ -21,8 +21,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "include/includes.h"
|
#include "include/includes.h"
|
||||||
|
#include <tevent.h>
|
||||||
#include "lib/messaging/irpc.h"
|
#include "lib/messaging/irpc.h"
|
||||||
#include "librpc/gen_ndr/ndr_irpc.h"
|
#include "librpc/gen_ndr/ndr_irpc_c.h"
|
||||||
#include "librpc/gen_ndr/samr.h"
|
#include "librpc/gen_ndr/samr.h"
|
||||||
#include "libcli/composite/composite.h"
|
#include "libcli/composite/composite.h"
|
||||||
#include "libcli/libcli.h"
|
#include "libcli/libcli.h"
|
||||||
@ -46,7 +47,7 @@ struct finddcs_state {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void finddcs_name_resolved(struct composite_context *ctx);
|
static void finddcs_name_resolved(struct composite_context *ctx);
|
||||||
static void finddcs_getdc_replied(struct irpc_request *ireq);
|
static void finddcs_getdc_replied(struct tevent_req *subreq);
|
||||||
static void fallback_node_status(struct finddcs_state *state);
|
static void fallback_node_status(struct finddcs_state *state);
|
||||||
static void fallback_node_status_replied(struct nbt_name_request *name_req);
|
static void fallback_node_status_replied(struct nbt_name_request *name_req);
|
||||||
|
|
||||||
@ -116,8 +117,8 @@ static void finddcs_name_resolved(struct composite_context *ctx)
|
|||||||
{
|
{
|
||||||
struct finddcs_state *state =
|
struct finddcs_state *state =
|
||||||
talloc_get_type(ctx->async.private_data, struct finddcs_state);
|
talloc_get_type(ctx->async.private_data, struct finddcs_state);
|
||||||
struct irpc_request *ireq;
|
struct tevent_req *subreq;
|
||||||
struct server_id *nbt_servers;
|
struct dcerpc_binding_handle *irpc_handle;
|
||||||
const char *address;
|
const char *address;
|
||||||
|
|
||||||
state->ctx->status = resolve_name_recv(ctx, state, &address);
|
state->ctx->status = resolve_name_recv(ctx, state, &address);
|
||||||
@ -141,8 +142,9 @@ static void finddcs_name_resolved(struct composite_context *ctx)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nbt_servers = irpc_servers_byname(state->msg_ctx, state, "nbt_server");
|
irpc_handle = irpc_binding_handle_by_name(state, state->msg_ctx,
|
||||||
if ((nbt_servers == NULL) || (nbt_servers[0].id == 0)) {
|
"nbt_server", &ndr_table_irpc);
|
||||||
|
if (irpc_handle == NULL) {
|
||||||
fallback_node_status(state);
|
fallback_node_status(state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -158,25 +160,25 @@ static void finddcs_name_resolved(struct composite_context *ctx)
|
|||||||
state->r.in.domain_sid = talloc_zero(state, struct dom_sid);
|
state->r.in.domain_sid = talloc_zero(state, struct dom_sid);
|
||||||
}
|
}
|
||||||
|
|
||||||
ireq = irpc_call_send(state->msg_ctx, nbt_servers[0],
|
subreq = dcerpc_nbtd_getdcname_r_send(state, state->ctx->event_ctx,
|
||||||
&ndr_table_irpc, NDR_NBTD_GETDCNAME,
|
irpc_handle, &state->r);
|
||||||
&state->r, state);
|
if (composite_nomem(subreq, state->ctx)) return;
|
||||||
if (!ireq) {
|
tevent_req_set_callback(subreq, finddcs_getdc_replied, state);
|
||||||
fallback_node_status(state);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
composite_continue_irpc(state->ctx, ireq, finddcs_getdc_replied, state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called when the GetDC request returns */
|
/* Called when the GetDC request returns */
|
||||||
static void finddcs_getdc_replied(struct irpc_request *ireq)
|
static void finddcs_getdc_replied(struct tevent_req *subreq)
|
||||||
{
|
{
|
||||||
struct finddcs_state *state =
|
struct finddcs_state *state =
|
||||||
talloc_get_type(ireq->async.private_data, struct finddcs_state);
|
tevent_req_callback_data(subreq,
|
||||||
|
struct finddcs_state);
|
||||||
|
NTSTATUS status;
|
||||||
|
|
||||||
state->ctx->status = irpc_call_recv(ireq);
|
status = dcerpc_nbtd_getdcname_r_recv(subreq, state);
|
||||||
if (!composite_is_ok(state->ctx)) return;
|
TALLOC_FREE(subreq);
|
||||||
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
|
fallback_node_status(state);
|
||||||
|
}
|
||||||
|
|
||||||
state->dcs[0].name = talloc_steal(state->dcs, state->r.out.dcname);
|
state->dcs[0].name = talloc_steal(state->dcs, state->r.out.dcname);
|
||||||
composite_done(state->ctx);
|
composite_done(state->ctx);
|
||||||
|
@ -71,7 +71,7 @@ bld.SAMBA_SUBSYSTEM('LP_RESOLVE',
|
|||||||
bld.SAMBA_SUBSYSTEM('LIBCLI_FINDDCS',
|
bld.SAMBA_SUBSYSTEM('LIBCLI_FINDDCS',
|
||||||
source='finddcs.c',
|
source='finddcs.c',
|
||||||
autoproto='finddcs.h',
|
autoproto='finddcs.h',
|
||||||
public_deps='LIBCLI_NBT MESSAGING'
|
public_deps='LIBCLI_NBT MESSAGING RPC_NDR_IRPC'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user