winbindd: only use the domain name from lookup sids if the domain matches
[samba.git] / source3 / winbindd / wb_sids2xids.c
index dc90bdf5ef756a84185266355d01f74e26aeeb2d..b8ad300ba3c80e1e82f5eccc1f87421d7ca963a7 100644 (file)
@@ -194,9 +194,13 @@ static void wb_sids2xids_lookupsids_done(struct tevent_req *subreq)
 
                if (n->sid_index != UINT32_MAX) {
                        const struct lsa_DomainInfo *info;
+                       bool match;
 
                        info = &domains->domains[n->sid_index];
-                       domain_name = info->name.string;
+                       match = dom_sid_in_domain(info->sid, sid);
+                       if (match) {
+                               domain_name = info->name.string;
+                       }
                }
                if (domain_name == NULL) {
                        struct winbindd_domain *wb_domain = NULL;