use winbindd_get_dc_info_async() to implement WINBINDD_GETDCNAME
authorStefan Metzmacher <metze@sernet.de>
Mon, 17 Sep 2007 14:25:10 +0000 (16:25 +0200)
committerStefan Metzmacher <metze@sernet.de>
Thu, 11 Oct 2007 15:21:49 +0000 (17:21 +0200)
metze

source/winbindd/winbindd_misc.c

index 24a18b4..82695b2 100644 (file)
@@ -207,9 +207,27 @@ enum winbindd_result winbindd_dual_list_trusted_domains(struct winbindd_domain *
        return WINBINDD_OK;
 }
 
+static void winbindd_getdcname_recv(void *private_data,
+                                   BOOL success,
+                                   struct winbind_get_dc_info *r)
+{
+       struct winbindd_cli_state *state =
+               talloc_get_type_abort(private_data, struct winbindd_cli_state);
+
+       if (!success) {
+               request_error(state);
+               return;
+       }
+
+       fstrcpy(state->response.data.dc_name, r->out.dc_info->name);
+
+       request_ok(state);
+}
+
 void winbindd_getdcname(struct winbindd_cli_state *state)
 {
        struct winbindd_domain *domain;
+       struct winbind_get_dc_info *r;
 
        state->request.domain_name
                [sizeof(state->request.domain_name)-1] = '\0';
@@ -224,7 +242,21 @@ void winbindd_getdcname(struct winbindd_cli_state *state)
                return;
        }
 
-       sendto_domain(state, find_our_domain());
+       r = TALLOC_P(state->mem_ctx, struct winbind_get_dc_info);
+       if (!r) goto nomem;
+       r->in.level = TALLOC_P(r, enum winbind_dc_info_level);
+       if (!r->in.level) goto nomem;
+
+       *r->in.level            = WINBIND_DC_INFO_LEVEL_COMPAT_NT4;
+       r->in.domain_name       = state->request.domain_name;
+       r->in.dc_name           = NULL;
+
+       winbindd_get_dc_info_async(state->mem_ctx, find_our_domain(),
+                                  r, winbindd_getdcname_recv, state);
+       return;
+nomem:
+       request_error(state);
+       return;
 }
 
 enum winbindd_result winbindd_dual_getdcname(struct winbindd_domain *domain,