summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-08-25 22:13:34 +0200
committerVolker Lendecke <vl@samba.org>2009-08-29 19:42:26 +0200
commit7579f0fb175d9e9484465d54cbc933283c26005e (patch)
treec8b6d4e0f2f71a733cf8cf1e781bad834f3b53ff /source3
parent9c30a8dc6fffd592592a108f3d9d93769ba74417 (diff)
downloadsamba-7579f0fb175d9e9484465d54cbc933283c26005e.tar.gz
samba-7579f0fb175d9e9484465d54cbc933283c26005e.tar.bz2
samba-7579f0fb175d9e9484465d54cbc933283c26005e.zip
s3:winbind: Add an async dsgetdcname call
Diffstat (limited to 'source3')
-rw-r--r--source3/librpc/gen_ndr/cli_wbint.c173
-rw-r--r--source3/librpc/gen_ndr/cli_wbint.h18
-rw-r--r--source3/librpc/gen_ndr/ndr_wbint.c170
-rw-r--r--source3/librpc/gen_ndr/ndr_wbint.h5
-rw-r--r--source3/librpc/gen_ndr/srv_wbint.c95
-rw-r--r--source3/librpc/gen_ndr/srv_wbint.h2
-rw-r--r--source3/librpc/gen_ndr/wbint.h16
-rw-r--r--source3/librpc/idl/wbint.idl8
-rw-r--r--source3/winbindd/winbindd_dual_srv.c81
9 files changed, 565 insertions, 3 deletions
diff --git a/source3/librpc/gen_ndr/cli_wbint.c b/source3/librpc/gen_ndr/cli_wbint.c
index a13565c96f..3b38a4d43d 100644
--- a/source3/librpc/gen_ndr/cli_wbint.c
+++ b/source3/librpc/gen_ndr/cli_wbint.c
@@ -2124,3 +2124,176 @@ NTSTATUS rpccli_wbint_QueryUserList(struct rpc_pipe_client *cli,
return r.out.result;
}
+struct rpccli_wbint_DsGetDcName_state {
+ struct wbint_DsGetDcName orig;
+ struct wbint_DsGetDcName tmp;
+ TALLOC_CTX *out_mem_ctx;
+ NTSTATUS (*dispatch_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx);
+};
+
+static void rpccli_wbint_DsGetDcName_done(struct tevent_req *subreq);
+
+struct tevent_req *rpccli_wbint_DsGetDcName_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct rpc_pipe_client *cli,
+ const char *_domain_name /* [in] [ref,charset(UTF8)] */,
+ struct GUID *_domain_guid /* [in] [unique] */,
+ const char *_site_name /* [in] [unique,charset(UTF8)] */,
+ uint32_t _flags /* [in] */,
+ struct netr_DsRGetDCNameInfo **_dc_info /* [out] [ref] */)
+{
+ struct tevent_req *req;
+ struct rpccli_wbint_DsGetDcName_state *state;
+ struct tevent_req *subreq;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct rpccli_wbint_DsGetDcName_state);
+ if (req == NULL) {
+ return NULL;
+ }
+ state->out_mem_ctx = NULL;
+ state->dispatch_recv = cli->dispatch_recv;
+
+ /* In parameters */
+ state->orig.in.domain_name = _domain_name;
+ state->orig.in.domain_guid = _domain_guid;
+ state->orig.in.site_name = _site_name;
+ state->orig.in.flags = _flags;
+
+ /* Out parameters */
+ state->orig.out.dc_info = _dc_info;
+
+ /* Result */
+ ZERO_STRUCT(state->orig.out.result);
+
+ if (DEBUGLEVEL >= 10) {
+ NDR_PRINT_IN_DEBUG(wbint_DsGetDcName, &state->orig);
+ }
+
+ state->out_mem_ctx = talloc_named_const(state, 0,
+ "rpccli_wbint_DsGetDcName_out_memory");
+ if (tevent_req_nomem(state->out_mem_ctx, req)) {
+ return tevent_req_post(req, ev);
+ }
+
+ /* make a temporary copy, that we pass to the dispatch function */
+ state->tmp = state->orig;
+
+ subreq = cli->dispatch_send(state, ev, cli,
+ &ndr_table_wbint,
+ NDR_WBINT_DSGETDCNAME,
+ &state->tmp);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, rpccli_wbint_DsGetDcName_done, req);
+ return req;
+}
+
+static void rpccli_wbint_DsGetDcName_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct rpccli_wbint_DsGetDcName_state *state = tevent_req_data(
+ req, struct rpccli_wbint_DsGetDcName_state);
+ NTSTATUS status;
+ TALLOC_CTX *mem_ctx;
+
+ if (state->out_mem_ctx) {
+ mem_ctx = state->out_mem_ctx;
+ } else {
+ mem_ctx = state;
+ }
+
+ status = state->dispatch_recv(subreq, mem_ctx);
+ TALLOC_FREE(subreq);
+ if (!NT_STATUS_IS_OK(status)) {
+ tevent_req_nterror(req, status);
+ return;
+ }
+
+ /* Copy out parameters */
+ *state->orig.out.dc_info = *state->tmp.out.dc_info;
+
+ /* Copy result */
+ state->orig.out.result = state->tmp.out.result;
+
+ /* Reset temporary structure */
+ ZERO_STRUCT(state->tmp);
+
+ if (DEBUGLEVEL >= 10) {
+ NDR_PRINT_OUT_DEBUG(wbint_DsGetDcName, &state->orig);
+ }
+
+ tevent_req_done(req);
+}
+
+NTSTATUS rpccli_wbint_DsGetDcName_recv(struct tevent_req *req,
+ TALLOC_CTX *mem_ctx,
+ NTSTATUS *result)
+{
+ struct rpccli_wbint_DsGetDcName_state *state = tevent_req_data(
+ req, struct rpccli_wbint_DsGetDcName_state);
+ NTSTATUS status;
+
+ if (tevent_req_is_nterror(req, &status)) {
+ tevent_req_received(req);
+ return status;
+ }
+
+ /* Steal possbile out parameters to the callers context */
+ talloc_steal(mem_ctx, state->out_mem_ctx);
+
+ /* Return result */
+ *result = state->orig.out.result;
+
+ tevent_req_received(req);
+ return NT_STATUS_OK;
+}
+
+NTSTATUS rpccli_wbint_DsGetDcName(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ const char *domain_name /* [in] [ref,charset(UTF8)] */,
+ struct GUID *domain_guid /* [in] [unique] */,
+ const char *site_name /* [in] [unique,charset(UTF8)] */,
+ uint32_t flags /* [in] */,
+ struct netr_DsRGetDCNameInfo **dc_info /* [out] [ref] */)
+{
+ struct wbint_DsGetDcName r;
+ NTSTATUS status;
+
+ /* In parameters */
+ r.in.domain_name = domain_name;
+ r.in.domain_guid = domain_guid;
+ r.in.site_name = site_name;
+ r.in.flags = flags;
+
+ if (DEBUGLEVEL >= 10) {
+ NDR_PRINT_IN_DEBUG(wbint_DsGetDcName, &r);
+ }
+
+ status = cli->dispatch(cli,
+ mem_ctx,
+ &ndr_table_wbint,
+ NDR_WBINT_DSGETDCNAME,
+ &r);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ if (DEBUGLEVEL >= 10) {
+ NDR_PRINT_OUT_DEBUG(wbint_DsGetDcName, &r);
+ }
+
+ if (NT_STATUS_IS_ERR(status)) {
+ return status;
+ }
+
+ /* Return variables */
+ *dc_info = *r.out.dc_info;
+
+ /* Return result */
+ return r.out.result;
+}
+
diff --git a/source3/librpc/gen_ndr/cli_wbint.h b/source3/librpc/gen_ndr/cli_wbint.h
index 9aa2f41a89..148870dcf0 100644
--- a/source3/librpc/gen_ndr/cli_wbint.h
+++ b/source3/librpc/gen_ndr/cli_wbint.h
@@ -172,4 +172,22 @@ NTSTATUS rpccli_wbint_QueryUserList_recv(struct tevent_req *req,
NTSTATUS rpccli_wbint_QueryUserList(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct wbint_userinfos *users /* [out] [ref] */);
+struct tevent_req *rpccli_wbint_DsGetDcName_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct rpc_pipe_client *cli,
+ const char *_domain_name /* [in] [ref,charset(UTF8)] */,
+ struct GUID *_domain_guid /* [in] [unique] */,
+ const char *_site_name /* [in] [unique,charset(UTF8)] */,
+ uint32_t _flags /* [in] */,
+ struct netr_DsRGetDCNameInfo **_dc_info /* [out] [ref] */);
+NTSTATUS rpccli_wbint_DsGetDcName_recv(struct tevent_req *req,
+ TALLOC_CTX *mem_ctx,
+ NTSTATUS *result);
+NTSTATUS rpccli_wbint_DsGetDcName(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ const char *domain_name /* [in] [ref,charset(UTF8)] */,
+ struct GUID *domain_guid /* [in] [unique] */,
+ const char *site_name /* [in] [unique,charset(UTF8)] */,
+ uint32_t flags /* [in] */,
+ struct netr_DsRGetDCNameInfo **dc_info /* [out] [ref] */);
#endif /* __CLI_WBINT__ */
diff --git a/source3/librpc/gen_ndr/ndr_wbint.c b/source3/librpc/gen_ndr/ndr_wbint.c
index 2c2676f069..8f07349d7a 100644
--- a/source3/librpc/gen_ndr/ndr_wbint.c
+++ b/source3/librpc/gen_ndr/ndr_wbint.c
@@ -1691,6 +1691,166 @@ _PUBLIC_ void ndr_print_wbint_QueryUserList(struct ndr_print *ndr, const char *n
ndr->depth--;
}
+static enum ndr_err_code ndr_push_wbint_DsGetDcName(struct ndr_push *ndr, int flags, const struct wbint_DsGetDcName *r)
+{
+ if (flags & NDR_IN) {
+ if (r->in.domain_name == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.domain_name, CH_UTF8)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.domain_name, CH_UTF8)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.domain_name, ndr_charset_length(r->in.domain_name, CH_UTF8), sizeof(uint8_t), CH_UTF8));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.domain_guid));
+ if (r->in.domain_guid) {
+ NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, r->in.domain_guid));
+ }
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.site_name));
+ if (r->in.site_name) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.site_name, CH_UTF8)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->in.site_name, CH_UTF8)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.site_name, ndr_charset_length(r->in.site_name, CH_UTF8), sizeof(uint8_t), CH_UTF8));
+ }
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.flags));
+ }
+ if (flags & NDR_OUT) {
+ if (r->out.dc_info == NULL) {
+ return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+ }
+ NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.dc_info));
+ if (*r->out.dc_info) {
+ NDR_CHECK(ndr_push_netr_DsRGetDCNameInfo(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.dc_info));
+ }
+ NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->out.result));
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_wbint_DsGetDcName(struct ndr_pull *ndr, int flags, struct wbint_DsGetDcName *r)
+{
+ uint32_t _ptr_domain_guid;
+ uint32_t _ptr_site_name;
+ uint32_t _ptr_dc_info;
+ TALLOC_CTX *_mem_save_domain_guid_0;
+ TALLOC_CTX *_mem_save_site_name_0;
+ TALLOC_CTX *_mem_save_dc_info_0;
+ TALLOC_CTX *_mem_save_dc_info_1;
+ if (flags & NDR_IN) {
+ ZERO_STRUCT(r->out);
+
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->in.domain_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->in.domain_name));
+ if (ndr_get_array_length(ndr, &r->in.domain_name) > ndr_get_array_size(ndr, &r->in.domain_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.domain_name), ndr_get_array_length(ndr, &r->in.domain_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.domain_name), sizeof(uint8_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.domain_name, ndr_get_array_length(ndr, &r->in.domain_name), sizeof(uint8_t), CH_UTF8));
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_domain_guid));
+ if (_ptr_domain_guid) {
+ NDR_PULL_ALLOC(ndr, r->in.domain_guid);
+ } else {
+ r->in.domain_guid = NULL;
+ }
+ if (r->in.domain_guid) {
+ _mem_save_domain_guid_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->in.domain_guid, 0);
+ NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, r->in.domain_guid));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domain_guid_0, 0);
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_site_name));
+ if (_ptr_site_name) {
+ NDR_PULL_ALLOC(ndr, r->in.site_name);
+ } else {
+ r->in.site_name = NULL;
+ }
+ if (r->in.site_name) {
+ _mem_save_site_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->in.site_name, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->in.site_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->in.site_name));
+ if (ndr_get_array_length(ndr, &r->in.site_name) > ndr_get_array_size(ndr, &r->in.site_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->in.site_name), ndr_get_array_length(ndr, &r->in.site_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.site_name), sizeof(uint8_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.site_name, ndr_get_array_length(ndr, &r->in.site_name), sizeof(uint8_t), CH_UTF8));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_site_name_0, 0);
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.flags));
+ NDR_PULL_ALLOC(ndr, r->out.dc_info);
+ ZERO_STRUCTP(r->out.dc_info);
+ }
+ if (flags & NDR_OUT) {
+ if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+ NDR_PULL_ALLOC(ndr, r->out.dc_info);
+ }
+ _mem_save_dc_info_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->out.dc_info, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_dc_info));
+ if (_ptr_dc_info) {
+ NDR_PULL_ALLOC(ndr, *r->out.dc_info);
+ } else {
+ *r->out.dc_info = NULL;
+ }
+ if (*r->out.dc_info) {
+ _mem_save_dc_info_1 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, *r->out.dc_info, 0);
+ NDR_CHECK(ndr_pull_netr_DsRGetDCNameInfo(ndr, NDR_SCALARS|NDR_BUFFERS, *r->out.dc_info));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_dc_info_1, 0);
+ }
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_dc_info_0, LIBNDR_FLAG_REF_ALLOC);
+ NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->out.result));
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_wbint_DsGetDcName(struct ndr_print *ndr, const char *name, int flags, const struct wbint_DsGetDcName *r)
+{
+ ndr_print_struct(ndr, name, "wbint_DsGetDcName");
+ ndr->depth++;
+ if (flags & NDR_SET_VALUES) {
+ ndr->flags |= LIBNDR_PRINT_SET_VALUES;
+ }
+ if (flags & NDR_IN) {
+ ndr_print_struct(ndr, "in", "wbint_DsGetDcName");
+ ndr->depth++;
+ ndr_print_ptr(ndr, "domain_name", r->in.domain_name);
+ ndr->depth++;
+ ndr_print_string(ndr, "domain_name", r->in.domain_name);
+ ndr->depth--;
+ ndr_print_ptr(ndr, "domain_guid", r->in.domain_guid);
+ ndr->depth++;
+ if (r->in.domain_guid) {
+ ndr_print_GUID(ndr, "domain_guid", r->in.domain_guid);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "site_name", r->in.site_name);
+ ndr->depth++;
+ if (r->in.site_name) {
+ ndr_print_string(ndr, "site_name", r->in.site_name);
+ }
+ ndr->depth--;
+ ndr_print_uint32(ndr, "flags", r->in.flags);
+ ndr->depth--;
+ }
+ if (flags & NDR_OUT) {
+ ndr_print_struct(ndr, "out", "wbint_DsGetDcName");
+ ndr->depth++;
+ ndr_print_ptr(ndr, "dc_info", r->out.dc_info);
+ ndr->depth++;
+ ndr_print_ptr(ndr, "dc_info", *r->out.dc_info);
+ ndr->depth++;
+ if (*r->out.dc_info) {
+ ndr_print_netr_DsRGetDCNameInfo(ndr, "dc_info", *r->out.dc_info);
+ }
+ ndr->depth--;
+ ndr->depth--;
+ ndr_print_NTSTATUS(ndr, "result", r->out.result);
+ ndr->depth--;
+ }
+ ndr->depth--;
+}
+
static const struct ndr_interface_call wbint_calls[] = {
{
"wbint_Ping",
@@ -1796,6 +1956,14 @@ static const struct ndr_interface_call wbint_calls[] = {
(ndr_print_function_t) ndr_print_wbint_QueryUserList,
false,
},
+ {
+ "wbint_DsGetDcName",
+ sizeof(struct wbint_DsGetDcName),
+ (ndr_push_flags_fn_t) ndr_push_wbint_DsGetDcName,
+ (ndr_pull_flags_fn_t) ndr_pull_wbint_DsGetDcName,
+ (ndr_print_function_t) ndr_print_wbint_DsGetDcName,
+ false,
+ },
{ NULL, 0, NULL, NULL, NULL, false }
};
@@ -1825,7 +1993,7 @@ const struct ndr_interface_table ndr_table_wbint = {
NDR_WBINT_VERSION
},
.helpstring = NDR_WBINT_HELPSTRING,
- .num_calls = 13,
+ .num_calls = 14,
.calls = wbint_calls,
.endpoints = &wbint_endpoints,
.authservices = &wbint_authservices
diff --git a/source3/librpc/gen_ndr/ndr_wbint.h b/source3/librpc/gen_ndr/ndr_wbint.h
index 5a838f9dd4..4b3096cb57 100644
--- a/source3/librpc/gen_ndr/ndr_wbint.h
+++ b/source3/librpc/gen_ndr/ndr_wbint.h
@@ -37,7 +37,9 @@ extern const struct ndr_interface_table ndr_table_wbint;
#define NDR_WBINT_QUERYUSERLIST (0x0c)
-#define NDR_WBINT_CALL_COUNT (13)
+#define NDR_WBINT_DSGETDCNAME (0x0d)
+
+#define NDR_WBINT_CALL_COUNT (14)
enum ndr_err_code ndr_push_wbint_userinfo(struct ndr_push *ndr, int ndr_flags, const struct wbint_userinfo *r);
enum ndr_err_code ndr_pull_wbint_userinfo(struct ndr_pull *ndr, int ndr_flags, struct wbint_userinfo *r);
void ndr_print_wbint_userinfo(struct ndr_print *ndr, const char *name, const struct wbint_userinfo *r);
@@ -69,4 +71,5 @@ void ndr_print_wbint_LookupUserGroups(struct ndr_print *ndr, const char *name, i
void ndr_print_wbint_QuerySequenceNumber(struct ndr_print *ndr, const char *name, int flags, const struct wbint_QuerySequenceNumber *r);
void ndr_print_wbint_LookupGroupMembers(struct ndr_print *ndr, const char *name, int flags, const struct wbint_LookupGroupMembers *r);
void ndr_print_wbint_QueryUserList(struct ndr_print *ndr, const char *name, int flags, const struct wbint_QueryUserList *r);
+void ndr_print_wbint_DsGetDcName(struct ndr_print *ndr, const char *name, int flags, const struct wbint_DsGetDcName *r);
#endif /* _HEADER_NDR_wbint */
diff --git a/source3/librpc/gen_ndr/srv_wbint.c b/source3/librpc/gen_ndr/srv_wbint.c
index 579164b13f..5dbd6474b6 100644
--- a/source3/librpc/gen_ndr/srv_wbint.c
+++ b/source3/librpc/gen_ndr/srv_wbint.c
@@ -1064,9 +1064,89 @@ static bool api_wbint_QueryUserList(pipes_struct *p)
return true;
}
+static bool api_wbint_DsGetDcName(pipes_struct *p)
+{
+ const struct ndr_interface_call *call;
+ struct ndr_pull *pull;
+ struct ndr_push *push;
+ enum ndr_err_code ndr_err;
+ DATA_BLOB blob;
+ struct wbint_DsGetDcName *r;
+
+ call = &ndr_table_wbint.calls[NDR_WBINT_DSGETDCNAME];
+
+ r = talloc(talloc_tos(), struct wbint_DsGetDcName);
+ if (r == NULL) {
+ return false;
+ }
+
+ if (!prs_data_blob(&p->in_data.data, &blob, r)) {
+ talloc_free(r);
+ return false;
+ }
+
+ pull = ndr_pull_init_blob(&blob, r, NULL);
+ if (pull == NULL) {
+ talloc_free(r);
+ return false;
+ }
+
+ pull->flags |= LIBNDR_FLAG_REF_ALLOC;
+ ndr_err = call->ndr_pull(pull, NDR_IN, r);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ talloc_free(r);
+ return false;
+ }
+
+ if (DEBUGLEVEL >= 10) {
+ NDR_PRINT_IN_DEBUG(wbint_DsGetDcName, r);
+ }
+
+ ZERO_STRUCT(r->out);
+ r->out.dc_info = talloc_zero(r, struct netr_DsRGetDCNameInfo *);
+ if (r->out.dc_info == NULL) {
+ talloc_free(r);
+ return false;
+ }
+
+ r->out.result = _wbint_DsGetDcName(p, r);
+
+ if (p->rng_fault_state) {
+ talloc_free(r);
+ /* Return true here, srv_pipe_hnd.c will take care */
+ return true;
+ }
+
+ if (DEBUGLEVEL >= 10) {
+ NDR_PRINT_OUT_DEBUG(wbint_DsGetDcName, r);
+ }
+
+ push = ndr_push_init_ctx(r, NULL);
+ if (push == NULL) {
+ talloc_free(r);
+ return false;
+ }
+
+ ndr_err = call->ndr_push(push, NDR_OUT, r);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ talloc_free(r);
+ return false;
+ }
+
+ blob = ndr_push_blob(push);
+ if (!prs_copy_data_in(&p->out_data.rdata, (const char *)blob.data, (uint32_t)blob.length)) {
+ talloc_free(r);
+ return false;
+ }
+
+ talloc_free(r);
+
+ return true;
+}
+
/* Tables */
-static struct api_struct api_wbint_cmds[] =
+static struct api_struct api_wbint_cmds[] =
{
{"WBINT_PING", NDR_WBINT_PING, api_wbint_Ping},
{"WBINT_LOOKUPSID", NDR_WBINT_LOOKUPSID, api_wbint_LookupSid},
@@ -1081,6 +1161,7 @@ static struct api_struct api_wbint_cmds[] =
{"WBINT_QUERYSEQUENCENUMBER", NDR_WBINT_QUERYSEQUENCENUMBER, api_wbint_QuerySequenceNumber},
{"WBINT_LOOKUPGROUPMEMBERS", NDR_WBINT_LOOKUPGROUPMEMBERS, api_wbint_LookupGroupMembers},
{"WBINT_QUERYUSERLIST", NDR_WBINT_QUERYUSERLIST, api_wbint_QueryUserList},
+ {"WBINT_DSGETDCNAME", NDR_WBINT_DSGETDCNAME, api_wbint_DsGetDcName},
};
void wbint_get_pipe_fns(struct api_struct **fns, int *n_fns)
@@ -1268,6 +1349,18 @@ NTSTATUS rpc_wbint_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, co
return NT_STATUS_OK;
}
+ case NDR_WBINT_DSGETDCNAME: {
+ struct wbint_DsGetDcName *r = (struct wbint_DsGetDcName *)_r;
+ ZERO_STRUCT(r->out);
+ r->out.dc_info = talloc_zero(mem_ctx, struct netr_DsRGetDCNameInfo *);
+ if (r->out.dc_info == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ r->out.result = _wbint_DsGetDcName(cli->pipes_struct, r);
+ return NT_STATUS_OK;
+ }
+
default:
return NT_STATUS_NOT_IMPLEMENTED;
}
diff --git a/source3/librpc/gen_ndr/srv_wbint.h b/source3/librpc/gen_ndr/srv_wbint.h
index 46bdd8bb61..a6dbd40265 100644
--- a/source3/librpc/gen_ndr/srv_wbint.h
+++ b/source3/librpc/gen_ndr/srv_wbint.h
@@ -14,6 +14,7 @@ NTSTATUS _wbint_LookupUserGroups(pipes_struct *p, struct wbint_LookupUserGroups
NTSTATUS _wbint_QuerySequenceNumber(pipes_struct *p, struct wbint_QuerySequenceNumber *r);
NTSTATUS _wbint_LookupGroupMembers(pipes_struct *p, struct wbint_LookupGroupMembers *r);
NTSTATUS _wbint_QueryUserList(pipes_struct *p, struct wbint_QueryUserList *r);
+NTSTATUS _wbint_DsGetDcName(pipes_struct *p, struct wbint_DsGetDcName *r);
void wbint_get_pipe_fns(struct api_struct **fns, int *n_fns);
NTSTATUS rpc_wbint_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const struct ndr_interface_table *table, uint32_t opnum, void *r);
void _wbint_Ping(pipes_struct *p, struct wbint_Ping *r);
@@ -29,5 +30,6 @@ NTSTATUS _wbint_LookupUserGroups(pipes_struct *p, struct wbint_LookupUserGroups
NTSTATUS _wbint_QuerySequenceNumber(pipes_struct *p, struct wbint_QuerySequenceNumber *r);
NTSTATUS _wbint_LookupGroupMembers(pipes_struct *p, struct wbint_LookupGroupMembers *r);
NTSTATUS _wbint_QueryUserList(pipes_struct *p, struct wbint_QueryUserList *r);
+NTSTATUS _wbint_DsGetDcName(pipes_struct *p, struct wbint_DsGetDcName *r);
NTSTATUS rpc_wbint_init(void);
#endif /* __SRV_WBINT__ */
diff --git a/source3/librpc/gen_ndr/wbint.h b/source3/librpc/gen_ndr/wbint.h
index 0b942d1968..31eaae2645 100644
--- a/source3/librpc/gen_ndr/wbint.h
+++ b/source3/librpc/gen_ndr/wbint.h
@@ -214,4 +214,20 @@ struct wbint_QueryUserList {
};
+
+struct wbint_DsGetDcName {
+ struct {
+ const char *domain_name;/* [ref,charset(UTF8)] */
+ struct GUID *domain_guid;/* [unique] */
+ const char *site_name;/* [unique,charset(UTF8)] */
+ uint32_t flags;
+ } in;
+
+ struct {
+ struct netr_DsRGetDCNameInfo **dc_info;/* [ref] */
+ NTSTATUS result;
+ } out;
+
+};
+
#endif /* _HEADER_wbint */
diff --git a/source3/librpc/idl/wbint.idl b/source3/librpc/idl/wbint.idl
index 1e3ef9e988..fbbe5ef118 100644
--- a/source3/librpc/idl/wbint.idl
+++ b/source3/librpc/idl/wbint.idl
@@ -118,4 +118,12 @@ interface wbint
NTSTATUS wbint_QueryUserList(
[out] wbint_userinfos *users
);
+
+ NTSTATUS wbint_DsGetDcName(
+ [in,string,charset(UTF8)] char *domain_name,
+ [in,unique] GUID *domain_guid,
+ [in,string,unique,charset(UTF8)] char *site_name,
+ [in] uint32 flags,
+ [out] netr_DsRGetDCNameInfo **dc_info
+ );
} \ No newline at end of file
diff --git a/source3/winbindd/winbindd_dual_srv.c b/source3/winbindd/winbindd_dual_srv.c
index f430b16451..6b1a4b3615 100644
--- a/source3/winbindd/winbindd_dual_srv.c
+++ b/source3/winbindd/winbindd_dual_srv.c
@@ -208,3 +208,84 @@ NTSTATUS _wbint_QueryUserList(pipes_struct *p, struct wbint_QueryUserList *r)
domain, p->mem_ctx, &r->out.users->num_userinfos,
&r->out.users->userinfos);
}
+
+NTSTATUS _wbint_DsGetDcName(pipes_struct *p, struct wbint_DsGetDcName *r)
+{
+ struct winbindd_domain *domain = wb_child_domain();
+ struct rpc_pipe_client *netlogon_pipe;
+ struct netr_DsRGetDCNameInfo *dc_info;
+ NTSTATUS status;
+ WERROR werr;
+ unsigned int orig_timeout;
+
+ if (domain == NULL) {
+ return dsgetdcname(p->mem_ctx, winbind_messaging_context(),
+ r->in.domain_name, r->in.domain_guid,
+ r->in.site_name ? r->in.site_name : "",
+ r->in.flags,
+ r->out.dc_info);
+ }
+
+ status = cm_connect_netlogon(domain, &netlogon_pipe);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(10, ("Can't contact the NETLOGON pipe\n"));
+ return status;
+ }
+
+ /* This call can take a long time - allow the server to time out.
+ 35 seconds should do it. */
+
+ orig_timeout = rpccli_set_timeout(netlogon_pipe, 35000);
+
+ if (domain->active_directory) {
+ status = rpccli_netr_DsRGetDCName(
+ netlogon_pipe, p->mem_ctx, domain->dcname,
+ r->in.domain_name, NULL, r->in.domain_guid,
+ r->in.flags, r->out.dc_info, &werr);
+ if (NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+ }
+
+ /*
+ * Fallback to less capable methods
+ */
+
+ dc_info = talloc_zero(r->out.dc_info, struct netr_DsRGetDCNameInfo);
+ if (dc_info == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ if (r->in.flags & DS_PDC_REQUIRED) {
+ status = rpccli_netr_GetDcName(
+ netlogon_pipe, p->mem_ctx, domain->dcname,
+ r->in.domain_name, &dc_info->dc_unc, &werr);
+ } else {
+ status = rpccli_netr_GetAnyDCName(
+ netlogon_pipe, p->mem_ctx, domain->dcname,
+ r->in.domain_name, &dc_info->dc_unc, &werr);
+ }
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(10, ("rpccli_netr_Get[Any]DCName failed: %s\n",
+ nt_errstr(status)));
+ goto done;
+ }
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(10, ("rpccli_netr_Get[Any]DCName failed: %s\n",
+ win_errstr(werr)));
+ status = werror_to_ntstatus(werr);
+ goto done;
+ }
+
+ *r->out.dc_info = dc_info;
+ status = NT_STATUS_OK;
+
+done:
+ /* And restore our original timeout. */
+ rpccli_set_timeout(netlogon_pipe, orig_timeout);
+
+ return status;
+}