wb-ndr: implement WINBIND_TRUST_LEVEL_COMPAT_LIST
authorStefan Metzmacher <metze@sernet.de>
Wed, 5 Mar 2008 06:52:38 +0000 (07:52 +0100)
committerStefan Metzmacher <metze@sernet.de>
Fri, 2 May 2008 14:13:24 +0000 (16:13 +0200)
metze

source/winbindd/winbindd_domain.c
source/winbindd/winbindd_misc.c

index 7f346e79d4520c39ae8e28d4cc440a3615ca002a..829259d147f3b4af178b1e0d878c0077885bbd0e 100644 (file)
@@ -41,6 +41,10 @@ static const struct winbindd_child_dispatch_table domain_dispatch_table[] = {
                .name           = "NDR_WINBIND_LOOKUP",
                .ndr_opnum      = NDR_WINBIND_LOOKUP,
                .ndr_fn         = winbindd_ndr_domain_child_lookup,
+       },{
+               .name           = "NDR_WINBIND_TRUST",
+               .ndr_opnum      = NDR_WINBIND_TRUST,
+               .ndr_fn         = winbindd_ndr_domain_child_trust,
        },{
                .name           = "LIST_TRUSTDOM",
                .struct_cmd     = WINBINDD_LIST_TRUSTDOM,
index 2e433a0783db5e8c4fc04de7a4ab8246f2204978..f5757823a65104070778ba3cd7b8572d57637880 100644 (file)
@@ -296,6 +296,93 @@ enum winbindd_result winbindd_dual_list_trusted_domains(struct winbindd_domain *
        return WINBINDD_OK;
 }
 
+static void ndr_child_trust_compat_list(struct winbindd_domain *domain,
+                                       struct winbindd_cli_state *state,
+                                       struct winbind_trust *r)
+{
+       uint32_t i, num_domains;
+       char **names, **alt_names;
+       DOM_SID *sids;
+       NTSTATUS result;
+       bool have_own_domain = False;
+       struct winbind_domain_info_compat *t;
+
+       DEBUG(3, ("list trusted domains\n"));
+
+       result = domain->methods->trusted_domains(domain, state->mem_ctx,
+                                                 &num_domains, &names,
+                                                 &alt_names, &sids);
+
+       if (!NT_STATUS_IS_OK(result)) {
+               DEBUG(3, ("winbindd_dual_list_trusted_domains: trusted_domains returned %s\n",
+                       nt_errstr(result) ));
+               r->out.result = WINBIND_STATUS_FOOBAR;
+               return;
+       }
+
+       t = talloc_array(r->out.rep,
+                        struct winbind_domain_info_compat,
+                        num_domains + 1);
+       if (!t) {
+               r->out.result = WINBIND_STATUS_NO_MEMORY;
+               return;
+       }
+
+       for (i=0; i<num_domains; i++) {
+               t[i].netbios_name       = names[i];
+               t[i].dns_name           = alt_names[i] ?
+                                         alt_names[i] :
+                                         names[i];
+               t[i].sid                = &sids[i];
+               /* TODO: fill this in */
+               t[i].is_native_mode     = false;
+               t[i].is_active_directory= false;
+               t[i].is_primary         = false;
+
+               if (strequal(names[i], domain->name)) {
+                       have_own_domain = True;
+                       t[i].is_native_mode     = domain->native_mode;
+                       t[i].is_active_directory= domain->active_directory;
+                       t[i].is_primary         = domain->primary;
+               }
+       }
+
+       /* add our primary domain */
+       if (!have_own_domain) {
+               t[i].netbios_name       = domain->name;
+               t[i].dns_name           = domain->alt_name ?
+                                         domain->alt_name :
+                                         domain->name;
+               t[i].sid                = &domain->sid;
+               t[i].is_native_mode     = domain->native_mode;
+               t[i].is_active_directory= domain->active_directory;
+               t[i].is_primary         = domain->primary;
+               i++;
+       }
+
+       r->out.rep->compat_trusts.num_domains   = i;
+       r->out.rep->compat_trusts.domains       = t;
+       r->out.result = WINBIND_STATUS_OK;
+}
+
+void winbindd_ndr_domain_child_trust(struct winbindd_domain *domain,
+                                    struct winbindd_cli_state *state)
+{
+       struct winbind_trust *r;
+
+       r = talloc_get_type_abort(state->c.ndr.r,
+                                 struct winbind_trust);
+
+       switch (*r->in.level) {
+       case WINBIND_TRUST_LEVEL_COMPAT_LIST:
+               ndr_child_trust_compat_list(domain, state, r);
+               return;
+       }
+
+       r->out.result = WINBIND_STATUS_UNKNOWN_LEVEL;
+       return;
+}
+
 static void winbindd_getdcname_recv(void *private_data,
                                    bool success,
                                    struct winbind_get_dc_info *r)