winbindd: find the domain based on the sid within wb_lookupusergroups_send()
authorStefan Metzmacher <metze@samba.org>
Mon, 6 Mar 2017 09:30:52 +0000 (10:30 +0100)
committerRalph Boehme <slow@samba.org>
Mon, 6 Mar 2017 14:09:18 +0000 (15:09 +0100)
That simplifies the potential caller.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12612

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/winbindd/wb_lookupusergroups.c
source3/winbindd/winbindd_proto.h

index 2d3969236faf3900a0e0643fe4b09049707be1d9..7647fbd5e66c9c004ae97dd963d8de7297260d51 100644 (file)
@@ -32,11 +32,11 @@ static void wb_lookupusergroups_done(struct tevent_req *subreq);
 
 struct tevent_req *wb_lookupusergroups_send(TALLOC_CTX *mem_ctx,
                                            struct tevent_context *ev,
-                                           struct winbindd_domain *domain,
                                            const struct dom_sid *sid)
 {
        struct tevent_req *req, *subreq;
        struct wb_lookupusergroups_state *state;
+       struct winbindd_domain *domain;
        NTSTATUS status;
 
        req = tevent_req_create(mem_ctx, &state,
@@ -55,6 +55,15 @@ struct tevent_req *wb_lookupusergroups_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
+       domain = find_domain_from_sid_noinit(&state->sid);
+       if (domain == NULL) {
+               char buf[DOM_SID_STR_BUFLEN];
+               dom_sid_string_buf(&state->sid, buf, sizeof(buf));
+               DEBUG(1,("could not find domain entry for sid %s\n", buf));
+               tevent_req_nterror(req, NT_STATUS_NO_SUCH_DOMAIN);
+               return tevent_req_post(req, ev);
+       }
+
        subreq = dcerpc_wbint_LookupUserGroups_send(
                state, ev, dom_child_handle(domain), &state->sid, &state->sids);
        if (tevent_req_nomem(subreq, req)) {
index 0faf0c6a763fea1ec07af4237846f36ccac6f5cf..46fb60038e6d2c647293a284ca72a23c18562bcc 100644 (file)
@@ -665,7 +665,6 @@ NTSTATUS winbindd_getsidaliases_recv(struct tevent_req *req,
                                     struct winbindd_response *response);
 struct tevent_req *wb_lookupusergroups_send(TALLOC_CTX *mem_ctx,
                                            struct tevent_context *ev,
-                                           struct winbindd_domain *domain,
                                            const struct dom_sid *sid);
 NTSTATUS wb_lookupusergroups_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
                                  int *num_sids, struct dom_sid **sids);