summaryrefslogtreecommitdiffstats
path: root/source3/winbindd/wb_lookupname.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-08-22 15:29:03 +0200
committerVolker Lendecke <vl@samba.org>2009-08-23 10:19:32 +0200
commitfced9dfc1ea45f902e9281679f479ae18d229c17 (patch)
treeec0e9ac41a09e4ed9ed405258159e50d1ee0c300 /source3/winbindd/wb_lookupname.c
parent1603c608c9c8c6b42a18dd5545c5d15fc2f0af48 (diff)
downloadsamba-fced9dfc1ea45f902e9281679f479ae18d229c17.tar.gz
samba-fced9dfc1ea45f902e9281679f479ae18d229c17.tar.xz
samba-fced9dfc1ea45f902e9281679f479ae18d229c17.zip
s3:winbind: Fallback to the forest root for lookupname
Thanks to Steven Danneman for watching me closely :-)
Diffstat (limited to 'source3/winbindd/wb_lookupname.c')
-rw-r--r--source3/winbindd/wb_lookupname.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/source3/winbindd/wb_lookupname.c b/source3/winbindd/wb_lookupname.c
index d4e9b9ae6cc..12e1babcda8 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) {
@@ -73,6 +82,46 @@ static void wb_lookupname_done(struct tevent_req *subreq)
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);
+ struct wb_lookupname_state *state = tevent_req_data(
+ req, struct wb_lookupname_state);
NTSTATUS status, result;
status = rpccli_wbint_LookupName_recv(subreq, state, &result);