diff options
Diffstat (limited to 'source4/winbind/wb_samba3_cmd.c')
-rw-r--r-- | source4/winbind/wb_samba3_cmd.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/source4/winbind/wb_samba3_cmd.c b/source4/winbind/wb_samba3_cmd.c index 14e9ac9e6d..4ff54e25b4 100644 --- a/source4/winbind/wb_samba3_cmd.c +++ b/source4/winbind/wb_samba3_cmd.c @@ -26,6 +26,10 @@ #include "nsswitch/winbindd_nss.h" #include "winbind/wb_server.h" #include "winbind/wb_samba3_protocol.h" +#include "winbind/wb_async_helpers.h" +#include "librpc/gen_ndr/nbt.h" +#include "libcli/raw/libcliraw.h" +#include "libcli/composite/composite.h" NTSTATUS wbsrv_samba3_interface_version(struct wbsrv_samba3_call *s3call) { @@ -48,3 +52,63 @@ NTSTATUS wbsrv_samba3_ping(struct wbsrv_samba3_call *s3call) s3call->response.result = WINBINDD_OK; return NT_STATUS_OK; } + +struct check_machacc_state { + struct wb_finddcs *io; +}; + +static void wbsrv_samba3_check_machacc_reply(struct composite_context *action) +{ + struct wbsrv_samba3_call *s3call = + talloc_get_type(action->async.private, + struct wbsrv_samba3_call); + struct check_machacc_state *state = + talloc_get_type(s3call->private_data, + struct check_machacc_state); + NTSTATUS status; + + status = wb_finddcs_recv(action, s3call); + if (NT_STATUS_IS_OK(status)) { + DEBUG(10, ("Got name %s\n", state->io->out.dcs[0].name)); + s3call->response.result = WINBINDD_OK; + } else { + DEBUG(10, ("Got no addr: %s\n", nt_errstr(status))); + s3call->response.result = WINBINDD_ERROR; + } + + status = wbsrv_send_reply(s3call->call); + if (!NT_STATUS_IS_OK(status)) { + wbsrv_terminate_connection(s3call->call->wbconn, + "wbsrv_queue_reply() failed"); + return; + } +} + +NTSTATUS wbsrv_samba3_check_machacc(struct wbsrv_samba3_call *s3call) +{ + struct composite_context *resolve_req; + struct check_machacc_state *state; + + DEBUG(5, ("check_machacc called\n")); + + state = talloc(s3call, struct check_machacc_state); + NT_STATUS_HAVE_NO_MEMORY(state); + + state->io = talloc(s3call, struct wb_finddcs); + NT_STATUS_HAVE_NO_MEMORY(state->io); + s3call->private_data = state; + + state->io->in.msg_ctx = s3call->call->wbconn->conn->msg_ctx; + state->io->in.domain = lp_workgroup(); + + resolve_req = wb_finddcs_send(state->io, s3call->call->event_ctx); + NT_STATUS_HAVE_NO_MEMORY(resolve_req); + + /* setup the callbacks */ + resolve_req->async.fn = wbsrv_samba3_check_machacc_reply; + resolve_req->async.private = s3call; + + /* tell the caller we reply later */ + s3call->call->flags |= WBSRV_CALL_FLAGS_REPLY_ASYNC; + return NT_STATUS_OK; +} |