From fced9dfc1ea45f902e9281679f479ae18d229c17 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 22 Aug 2009 15:29:03 +0200 Subject: s3:winbind: Fallback to the forest root for lookupname Thanks to Steven Danneman for watching me closely :-) --- source3/winbindd/wb_lookupname.c | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'source3/winbindd') diff --git a/source3/winbindd/wb_lookupname.c b/source3/winbindd/wb_lookupname.c index d4e9b9ae6c..12e1babcda 100644 --- a/source3/winbindd/wb_lookupname.c +++ b/source3/winbindd/wb_lookupname.c @@ -22,11 +22,16 @@ #include "librpc/gen_ndr/cli_wbint.h" struct wb_lookupname_state { + struct tevent_context *ev; + const char *dom_name; + const char *name; + uint32_t flags; struct dom_sid sid; enum lsa_SidType type; }; static void wb_lookupname_done(struct tevent_req *subreq); +static void wb_lookupname_root_done(struct tevent_req *subreq); struct tevent_req *wb_lookupname_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, @@ -42,6 +47,10 @@ struct tevent_req *wb_lookupname_send(TALLOC_CTX *mem_ctx, if (req == NULL) { return NULL; } + state->ev = ev; + state->dom_name = dom_name; + state->name = name; + state->flags = flags; domain = find_lookup_domain_from_name(dom_name); if (domain == NULL) { @@ -68,6 +77,46 @@ struct tevent_req *wb_lookupname_send(TALLOC_CTX *mem_ctx, } static void wb_lookupname_done(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_lookupname_state *state = tevent_req_data( + req, struct wb_lookupname_state); + struct winbindd_domain *root_domain; + NTSTATUS status, result; + + status = rpccli_wbint_LookupName_recv(subreq, state, &result); + TALLOC_FREE(subreq); + if (!NT_STATUS_IS_OK(status)) { + tevent_req_nterror(req, status); + return; + } + if (NT_STATUS_IS_OK(result)) { + tevent_req_done(req); + return; + } + + /* + * "our" DC did not find it, lets retry with the forest root + * domain + */ + + root_domain = find_root_domain(); + if (root_domain == NULL) { + tevent_req_nterror(req, result); + return; + } + + subreq = rpccli_wbint_LookupName_send( + state, state->ev, root_domain->child.rpccli, state->dom_name, + state->name, state->flags, &state->type, &state->sid); + if (tevent_req_nomem(subreq, req)) { + return; + } + tevent_req_set_callback(subreq, wb_lookupname_root_done, req); +} + +static void wb_lookupname_root_done(struct tevent_req *subreq) { struct tevent_req *req = tevent_req_callback_data( subreq, struct tevent_req); -- cgit