s4-netlogon: merge netr_GetDcName from s3 idl.
[kai/samba.git] / source4 / winbind / wb_cmd_getdcname.c
index 2952ffc976a0f1b4cc6e891d2a1a954fbd651275..66dcbf9d7bd081e85754e773834b011556e6893a 100644 (file)
@@ -7,7 +7,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -16,8 +16,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
@@ -25,7 +24,7 @@
 #include "winbind/wb_server.h"
 #include "smbd/service_task.h"
 
-#include "librpc/gen_ndr/ndr_netlogon.h"
+#include "librpc/gen_ndr/ndr_netlogon_c.h"
 
 struct cmd_getdcname_state {
        struct composite_context *ctx;
@@ -44,11 +43,8 @@ struct composite_context *wb_cmd_getdcname_send(TALLOC_CTX *mem_ctx,
        struct composite_context *result, *ctx;
        struct cmd_getdcname_state *state;
 
-       result = talloc(mem_ctx, struct composite_context);
+       result = composite_create(mem_ctx, service->task->event_ctx);
        if (result == NULL) goto failed;
-       result->state = COMPOSITE_STATE_IN_PROGRESS;
-       result->async.fn = NULL;
-       result->event_ctx = service->task->event_ctx;
 
        state = talloc(result, struct cmd_getdcname_state);
        if (state == NULL) goto failed;
@@ -85,6 +81,7 @@ static void getdcname_recv_domain(struct composite_context *ctx)
                state, "\\\\%s",
                dcerpc_server_name(domain->netlogon_pipe));
        state->g.in.domainname = state->domain_name;
+       state->g.out.dcname = talloc(state, const char *);
 
        req = dcerpc_netr_GetAnyDCName_send(domain->netlogon_pipe, state,
                                            &state->g);
@@ -96,7 +93,7 @@ static void getdcname_recv_domain(struct composite_context *ctx)
 static void getdcname_recv_dcname(struct rpc_request *req)
 {
        struct cmd_getdcname_state *state =
-               talloc_get_type(req->async.private,
+               talloc_get_type(req->async.private_data,
                                struct cmd_getdcname_state);
 
        state->ctx->status = dcerpc_ndr_request_recv(req);
@@ -115,7 +112,7 @@ NTSTATUS wb_cmd_getdcname_recv(struct composite_context *c,
                talloc_get_type(c->private_data, struct cmd_getdcname_state);
        NTSTATUS status = composite_wait(c);
        if (NT_STATUS_IS_OK(status)) {
-               const char *p = state->g.out.dcname;
+               const char *p = *(state->g.out.dcname);
                if (*p == '\\') p += 1;
                if (*p == '\\') p += 1;
                *dcname = talloc_strdup(mem_ctx, p);