idmap_tdb: If one SID fails to map, try the rest
[bbaumbach/samba-autobuild/.git] / source3 / winbindd / wb_lookupsid.c
index 2ab3917ceb718de1d13a16a949b42a6465efffd4..3db4e3266594cba2ca0bbe7136f87bcf5e04b835 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "includes.h"
 #include "winbindd.h"
-#include "librpc/gen_ndr/ndr_wbint_c.h"
+#include "librpc/gen_ndr/ndr_winbind_c.h"
 #include "../libcli/security/security.h"
 
 struct wb_lookupsid_state {
@@ -49,8 +49,9 @@ struct tevent_req *wb_lookupsid_send(TALLOC_CTX *mem_ctx,
 
        state->lookup_domain = find_lookup_domain_from_sid(sid);
        if (state->lookup_domain == NULL) {
+               struct dom_sid_buf buf;
                DEBUG(5, ("Could not find domain for sid %s\n",
-                         sid_string_dbg(sid)));
+                         dom_sid_str_buf(sid, &buf)));
                tevent_req_nterror(req, NT_STATUS_NONE_MAPPED);
                return tevent_req_post(req, ev);
        }
@@ -71,36 +72,15 @@ static void wb_lookupsid_done(struct tevent_req *subreq)
                subreq, struct tevent_req);
        struct wb_lookupsid_state *state = tevent_req_data(
                req, struct wb_lookupsid_state);
-       struct winbindd_domain *forest_root;
        NTSTATUS status, result;
 
        status = dcerpc_wbint_LookupSid_recv(subreq, state, &result);
        TALLOC_FREE(subreq);
-       if (tevent_req_nterror(req, status)) {
+       if (any_nt_status_not_ok(status, result, &status)) {
+               tevent_req_nterror(req, status);
                return;
        }
-       if (NT_STATUS_IS_OK(result)) {
-               tevent_req_done(req);
-               return;
-       }
-
-       /*
-        * Let's try the forest root
-        */
-       forest_root = find_root_domain();
-       if ((forest_root == NULL) || (forest_root == state->lookup_domain)) {
-               tevent_req_nterror(req, result);
-               return;
-       }
-       state->lookup_domain = forest_root;
-
-       subreq = dcerpc_wbint_LookupSid_send(
-               state, state->ev, dom_child_handle(state->lookup_domain),
-               &state->sid, &state->type, &state->domname, &state->name);
-       if (tevent_req_nomem(subreq, req)) {
-               return;
-       }
-       tevent_req_set_callback(subreq, wb_lookupsid_done, req);
+       tevent_req_done(req);
 }
 
 NTSTATUS wb_lookupsid_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,