s4:libnet/libnet_domain.c: make use of use tevent_req based dcerpc_binding_handle...
authorStefan Metzmacher <metze@samba.org>
Tue, 9 Mar 2010 15:45:04 +0000 (16:45 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 12 Mar 2010 14:25:43 +0000 (15:25 +0100)
metze

source4/libnet/libnet_domain.c

index ab168b570018eae1efff87dc8f40e131e5606613..0fafe7125005e9898b8e5afadf3ba4909ff2a435 100644 (file)
@@ -47,10 +47,10 @@ struct domain_open_samr_state {
 };
 
 
-static void continue_domain_open_close(struct rpc_request *req);
-static void continue_domain_open_connect(struct rpc_request *req);
-static void continue_domain_open_lookup(struct rpc_request *req);
-static void continue_domain_open_open(struct rpc_request *req);
+static void continue_domain_open_close(struct tevent_req *subreq);
+static void continue_domain_open_connect(struct tevent_req *subreq);
+static void continue_domain_open_lookup(struct tevent_req *subreq);
+static void continue_domain_open_open(struct tevent_req *subreq);
 
 
 /**
@@ -60,7 +60,7 @@ static void continue_domain_open_rpc_connect(struct composite_context *ctx)
 {
        struct composite_context *c;
        struct domain_open_samr_state *s;
-       struct rpc_request *conn_req;
+       struct tevent_req *subreq;
 
        c = talloc_get_type(ctx->async.private_data, struct composite_context);
        s = talloc_get_type(c->private_data, struct domain_open_samr_state);
@@ -76,11 +76,13 @@ static void continue_domain_open_rpc_connect(struct composite_context *ctx)
        s->connect.out.connect_handle  = &s->connect_handle;
 
        /* send request */
-       conn_req = dcerpc_samr_Connect_send(s->pipe, c, &s->connect);
-       if (composite_nomem(conn_req, c)) return;
+       subreq = dcerpc_samr_Connect_r_send(s, c->event_ctx,
+                                           s->pipe->binding_handle,
+                                           &s->connect);
+       if (composite_nomem(subreq, c)) return;
 
        /* callback handler */
-       composite_continue_rpc(c, conn_req, continue_domain_open_connect, c);
+       tevent_req_set_callback(subreq, continue_domain_open_connect, c);
 }
 
 
@@ -88,17 +90,17 @@ static void continue_domain_open_rpc_connect(struct composite_context *ctx)
  * Stage 0.5 (optional): Close existing (in libnet context) domain
  * handle
  */
-static void continue_domain_open_close(struct rpc_request *req)
+static void continue_domain_open_close(struct tevent_req *subreq)
 {
        struct composite_context *c;
        struct domain_open_samr_state *s;
-       struct rpc_request *conn_req;
 
-       c = talloc_get_type(req->async.private_data, struct composite_context);
+       c = tevent_req_callback_data(subreq, struct composite_context);
        s = talloc_get_type(c->private_data, struct domain_open_samr_state);
 
        /* receive samr_Close reply */
-       c->status = dcerpc_samr_Close_recv(req);
+       c->status = dcerpc_samr_Close_r_recv(subreq, s);
+       TALLOC_FREE(subreq);
        if (!composite_is_ok(c)) return;
 
        if (s->monitor_fn) {
@@ -121,29 +123,31 @@ static void continue_domain_open_close(struct rpc_request *req)
        s->connect.out.connect_handle  = &s->connect_handle;
        
        /* send request */
-       conn_req = dcerpc_samr_Connect_send(s->pipe, c, &s->connect);
-       if (composite_nomem(conn_req, c)) return;
+       subreq = dcerpc_samr_Connect_r_send(s, c->event_ctx,
+                                           s->pipe->binding_handle,
+                                           &s->connect);
+       if (composite_nomem(subreq, c)) return;
 
        /* callback handler */
-       composite_continue_rpc(c, conn_req, continue_domain_open_connect, c);
+       tevent_req_set_callback(subreq, continue_domain_open_connect, c);
 }
 
 
 /**
  * Stage 1: Connect to SAM server.
  */
-static void continue_domain_open_connect(struct rpc_request *req)
+static void continue_domain_open_connect(struct tevent_req *subreq)
 {
        struct composite_context *c;
        struct domain_open_samr_state *s;
-       struct rpc_request *lookup_req;
        struct samr_LookupDomain *r;
        
-       c = talloc_get_type(req->async.private_data, struct composite_context);
+       c = tevent_req_callback_data(subreq, struct composite_context);
        s = talloc_get_type(c->private_data, struct domain_open_samr_state);
 
        /* receive samr_Connect reply */
-       c->status = dcerpc_samr_Connect_recv(req);
+       c->status = dcerpc_samr_Connect_r_recv(subreq, s);
+       TALLOC_FREE(subreq);
        if (!composite_is_ok(c)) return;
 
        if (s->monitor_fn) {
@@ -163,28 +167,30 @@ static void continue_domain_open_connect(struct rpc_request *req)
        r->out.sid           = talloc(s, struct dom_sid2 *);
        if (composite_nomem(r->out.sid, c)) return;
 
-       lookup_req = dcerpc_samr_LookupDomain_send(s->pipe, c, r);
-       if (composite_nomem(lookup_req, c)) return;
+       subreq = dcerpc_samr_LookupDomain_r_send(s, c->event_ctx,
+                                                s->pipe->binding_handle,
+                                                r);
+       if (composite_nomem(subreq, c)) return;
 
-       composite_continue_rpc(c, lookup_req, continue_domain_open_lookup, c);
+       tevent_req_set_callback(subreq, continue_domain_open_lookup, c);
 }
 
 
 /**
  * Stage 2: Lookup domain by name.
  */
-static void continue_domain_open_lookup(struct rpc_request *req)
+static void continue_domain_open_lookup(struct tevent_req *subreq)
 {
        struct composite_context *c;
        struct domain_open_samr_state *s;
-       struct rpc_request *opendom_req;
        struct samr_OpenDomain *r;
 
-       c = talloc_get_type(req->async.private_data, struct composite_context);
+       c = tevent_req_callback_data(subreq, struct composite_context);
        s = talloc_get_type(c->private_data, struct domain_open_samr_state);
        
        /* receive samr_LookupDomain reply */
-       c->status = dcerpc_samr_LookupDomain_recv(req);
+       c->status = dcerpc_samr_LookupDomain_r_recv(subreq, s);
+       TALLOC_FREE(subreq);
 
        if (s->monitor_fn) {
                struct monitor_msg msg;
@@ -215,26 +221,29 @@ static void continue_domain_open_lookup(struct rpc_request *req)
        r->in.sid            = *s->lookup.out.sid;
        r->out.domain_handle = &s->domain_handle;
 
-       opendom_req = dcerpc_samr_OpenDomain_send(s->pipe, c, r);
-       if (composite_nomem(opendom_req, c)) return;
+       subreq = dcerpc_samr_OpenDomain_r_send(s, c->event_ctx,
+                                              s->pipe->binding_handle,
+                                              r);
+       if (composite_nomem(subreq, c)) return;
 
-       composite_continue_rpc(c, opendom_req, continue_domain_open_open, c);
+       tevent_req_set_callback(subreq, continue_domain_open_open, c);
 }
 
 
 /*
  * Stage 3: Open domain.
  */
-static void continue_domain_open_open(struct rpc_request *req)
+static void continue_domain_open_open(struct tevent_req *subreq)
 {
        struct composite_context *c;
        struct domain_open_samr_state *s;
 
-       c = talloc_get_type(req->async.private_data, struct composite_context);
+       c = tevent_req_callback_data(subreq, struct composite_context);
        s = talloc_get_type(c->private_data, struct domain_open_samr_state);
 
        /* receive samr_OpenDomain reply */
-       c->status = dcerpc_samr_OpenDomain_recv(req);
+       c->status = dcerpc_samr_OpenDomain_r_recv(subreq, s);
+       TALLOC_FREE(subreq);
        if (!composite_is_ok(c)) return;
 
        if (s->monitor_fn) {
@@ -265,7 +274,7 @@ struct composite_context *libnet_DomainOpenSamr_send(struct libnet_context *ctx,
        struct composite_context *c;
        struct domain_open_samr_state *s;
        struct composite_context *rpcconn_req;
-       struct rpc_request *close_req, *conn_req;
+       struct tevent_req *subreq;
 
        c = composite_create(ctx, ctx->event_ctx);
        if (c == NULL) return NULL;
@@ -313,11 +322,13 @@ struct composite_context *libnet_DomainOpenSamr_send(struct libnet_context *ctx,
                        s->close.in.handle = &ctx->samr.handle;
 
                        /* send request to close domain handle */
-                       close_req = dcerpc_samr_Close_send(s->pipe, c, &s->close);
-                       if (composite_nomem(close_req, c)) return c;
+                       subreq = dcerpc_samr_Close_r_send(s, c->event_ctx,
+                                                         s->pipe->binding_handle,
+                                                         &s->close);
+                       if (composite_nomem(subreq, c)) return c;
 
                        /* callback handler */
-                       composite_continue_rpc(c, close_req, continue_domain_open_close, c);
+                       tevent_req_set_callback(subreq, continue_domain_open_close, c);
                        return c;
                }
        }
@@ -328,11 +339,13 @@ struct composite_context *libnet_DomainOpenSamr_send(struct libnet_context *ctx,
        s->connect.out.connect_handle  = &s->connect_handle;
        
        /* send request */
-       conn_req = dcerpc_samr_Connect_send(s->pipe, c, &s->connect);
-       if (composite_nomem(conn_req, c)) return c;
+       subreq = dcerpc_samr_Connect_r_send(s, c->event_ctx,
+                                           s->pipe->binding_handle,
+                                           &s->connect);
+       if (composite_nomem(subreq, c)) return c;
 
        /* callback handler */
-       composite_continue_rpc(c, conn_req, continue_domain_open_connect, c);
+       tevent_req_set_callback(subreq, continue_domain_open_connect, c);
        return c;
 }
 
@@ -389,7 +402,7 @@ struct domain_open_lsa_state {
 
 
 static void continue_rpc_connect_lsa(struct composite_context *ctx);
-static void continue_lsa_policy_open(struct rpc_request *req);
+static void continue_lsa_policy_open(struct tevent_req *subreq);
 
 
 /**
@@ -407,7 +420,7 @@ struct composite_context* libnet_DomainOpenLsa_send(struct libnet_context *ctx,
        struct composite_context *c;
        struct domain_open_lsa_state *s;
        struct composite_context *rpcconn_req;
-       struct rpc_request *openpol_req;
+       struct tevent_req *subreq;
        struct lsa_QosInfo *qos;
 
        /* create composite context and state */
@@ -459,10 +472,12 @@ struct composite_context* libnet_DomainOpenLsa_send(struct libnet_context *ctx,
        s->openpol.out.handle       = &s->handle;
        
        /* send rpc request */
-       openpol_req = dcerpc_lsa_OpenPolicy2_send(s->pipe, c, &s->openpol);
-       if (composite_nomem(openpol_req, c)) return c;
+       subreq = dcerpc_lsa_OpenPolicy2_r_send(s, c->event_ctx,
+                                              s->pipe->binding_handle,
+                                              &s->openpol);
+       if (composite_nomem(subreq, c)) return c;
 
-       composite_continue_rpc(c, openpol_req, continue_lsa_policy_open, c);
+       tevent_req_set_callback(subreq, continue_lsa_policy_open, c);
        return c;
 }
 
@@ -475,7 +490,7 @@ static void continue_rpc_connect_lsa(struct composite_context *ctx)
        struct composite_context *c;
        struct domain_open_lsa_state *s;
        struct lsa_QosInfo *qos;
-       struct rpc_request *openpol_req;
+       struct tevent_req *subreq;
 
        c = talloc_get_type(ctx->async.private_data, struct composite_context);
        s = talloc_get_type(c->private_data, struct domain_open_lsa_state);
@@ -503,25 +518,28 @@ static void continue_rpc_connect_lsa(struct composite_context *ctx)
        s->openpol.out.handle       = &s->handle;
 
        /* send rpc request */
-       openpol_req = dcerpc_lsa_OpenPolicy2_send(s->pipe, c, &s->openpol);
-       if (composite_nomem(openpol_req, c)) return;
+       subreq = dcerpc_lsa_OpenPolicy2_r_send(s, c->event_ctx,
+                                              s->pipe->binding_handle,
+                                              &s->openpol);
+       if (composite_nomem(subreq, c)) return;
 
-       composite_continue_rpc(c, openpol_req, continue_lsa_policy_open, c);
+       tevent_req_set_callback(subreq, continue_lsa_policy_open, c);
 }
 
 
 /*
   Stage 1: Lsa policy opened - we're done, if successfully
  */
-static void continue_lsa_policy_open(struct rpc_request *req)
+static void continue_lsa_policy_open(struct tevent_req *subreq)
 {
        struct composite_context *c;
        struct domain_open_lsa_state *s;
 
-       c = talloc_get_type(req->async.private_data, struct composite_context);
+       c = tevent_req_callback_data(subreq, struct composite_context);
        s = talloc_get_type(c->private_data, struct domain_open_lsa_state);
 
-       c->status = dcerpc_lsa_OpenPolicy2_recv(req);
+       c->status = dcerpc_lsa_OpenPolicy2_r_recv(subreq, s);
+       TALLOC_FREE(subreq);
        if (!composite_is_ok(c)) return;
 
        if (s->monitor_fn) {
@@ -666,7 +684,7 @@ struct domain_close_lsa_state {
 };
 
 
-static void continue_lsa_close(struct rpc_request *req);
+static void continue_lsa_close(struct tevent_req *subreq);
 
 
 struct composite_context* libnet_DomainCloseLsa_send(struct libnet_context *ctx,
@@ -675,7 +693,7 @@ struct composite_context* libnet_DomainCloseLsa_send(struct libnet_context *ctx,
 {
        struct composite_context *c;
        struct domain_close_lsa_state *s;
-       struct rpc_request *close_req;
+       struct tevent_req *subreq;
 
        /* composite context and state structure allocation */
        c = composite_create(ctx, ctx->event_ctx);
@@ -702,10 +720,12 @@ struct composite_context* libnet_DomainCloseLsa_send(struct libnet_context *ctx,
        s->close.out.handle = &s->handle;
 
        /* send the request */
-       close_req = dcerpc_lsa_Close_send(s->pipe, c, &s->close);
-       if (composite_nomem(close_req, c)) return c;
+       subreq = dcerpc_lsa_Close_r_send(s, c->event_ctx,
+                                        s->pipe->binding_handle,
+                                        &s->close);
+       if (composite_nomem(subreq, c)) return c;
 
-       composite_continue_rpc(c, close_req, continue_lsa_close, c);
+       tevent_req_set_callback(subreq, continue_lsa_close, c);
        return c;
 }
 
@@ -713,15 +733,16 @@ struct composite_context* libnet_DomainCloseLsa_send(struct libnet_context *ctx,
 /*
   Stage 1: Receive result of lsa close call
 */
-static void continue_lsa_close(struct rpc_request *req)
+static void continue_lsa_close(struct tevent_req *subreq)
 {
        struct composite_context *c;
        struct domain_close_lsa_state *s;
        
-       c = talloc_get_type(req->async.private_data, struct composite_context);
+       c = tevent_req_callback_data(subreq, struct composite_context);
        s = talloc_get_type(c->private_data, struct domain_close_lsa_state);
 
-       c->status = dcerpc_lsa_Close_recv(req);
+       c->status = dcerpc_lsa_Close_r_recv(subreq, s);
+       TALLOC_FREE(subreq);
        if (!composite_is_ok(c)) return;
 
        if (s->monitor_fn) {
@@ -770,7 +791,7 @@ struct domain_close_samr_state {
 };
 
 
-static void continue_samr_close(struct rpc_request *req);
+static void continue_samr_close(struct tevent_req *subreq);
 
 
 struct composite_context* libnet_DomainCloseSamr_send(struct libnet_context *ctx,
@@ -779,7 +800,7 @@ struct composite_context* libnet_DomainCloseSamr_send(struct libnet_context *ctx
 {
        struct composite_context *c;
        struct domain_close_samr_state *s;
-       struct rpc_request *close_req;
+       struct tevent_req *subreq;
 
        /* composite context and state structure allocation */
        c = composite_create(ctx, ctx->event_ctx);
@@ -804,10 +825,12 @@ struct composite_context* libnet_DomainCloseSamr_send(struct libnet_context *ctx
        s->close.out.handle = &s->handle;
 
        /* send the request */
-       close_req = dcerpc_samr_Close_send(ctx->samr.pipe, ctx, &s->close);
-       if (composite_nomem(close_req, c)) return c;
+       subreq = dcerpc_samr_Close_r_send(s, c->event_ctx,
+                                         ctx->samr.pipe->binding_handle,
+                                         &s->close);
+       if (composite_nomem(subreq, c)) return c;
 
-       composite_continue_rpc(c, close_req, continue_samr_close, c);
+       tevent_req_set_callback(subreq, continue_samr_close, c);
        return c;
 }
 
@@ -815,15 +838,16 @@ struct composite_context* libnet_DomainCloseSamr_send(struct libnet_context *ctx
 /*
   Stage 1: Receive result of samr close call
 */
-static void continue_samr_close(struct rpc_request *req)
+static void continue_samr_close(struct tevent_req *subreq)
 {
        struct composite_context *c;
        struct domain_close_samr_state *s;
 
-       c = talloc_get_type(req->async.private_data, struct composite_context);
+       c = tevent_req_callback_data(subreq, struct composite_context);
        s = talloc_get_type(c->private_data, struct domain_close_samr_state);
        
-       c->status = dcerpc_samr_Close_recv(req);
+       c->status = dcerpc_samr_Close_r_recv(subreq, s);
+       TALLOC_FREE(subreq);
        if (!composite_is_ok(c)) return;
 
        if (s->monitor_fn) {
@@ -940,9 +964,9 @@ struct domain_list_state {
 
 
 static void continue_rpc_connect(struct composite_context *c);
-static void continue_samr_connect(struct rpc_request *c);
-static void continue_samr_enum_domains(struct rpc_request *req);
-static void continue_samr_close_handle(struct rpc_request *req);
+static void continue_samr_connect(struct tevent_req *subreq);
+static void continue_samr_enum_domains(struct tevent_req *subreq);
+static void continue_samr_close_handle(struct tevent_req *subreq);
 
 static struct domainlist* get_domain_list(TALLOC_CTX *mem_ctx, struct domain_list_state *s);
 
@@ -955,7 +979,7 @@ static void continue_rpc_connect(struct composite_context *ctx)
 {
        struct composite_context *c;
        struct domain_list_state *s;
-       struct rpc_request *samrconn_req;
+       struct tevent_req *subreq;
 
        c = talloc_get_type(ctx->async.private_data, struct composite_context);
        s = talloc_get_type(c->private_data, struct domain_list_state);
@@ -967,10 +991,12 @@ static void continue_rpc_connect(struct composite_context *ctx)
        s->samrconn.in.access_mask     = SEC_GENERIC_READ;     /* should be enough */
        s->samrconn.out.connect_handle = &s->connect_handle;
 
-       samrconn_req = dcerpc_samr_Connect_send(s->ctx->samr.pipe, c, &s->samrconn);
-       if (composite_nomem(samrconn_req, c)) return;
+       subreq = dcerpc_samr_Connect_r_send(s, c->event_ctx,
+                                           s->ctx->samr.pipe->binding_handle,
+                                           &s->samrconn);
+       if (composite_nomem(subreq, c)) return;
 
-       composite_continue_rpc(c, samrconn_req, continue_samr_connect, c);
+       tevent_req_set_callback(subreq, continue_samr_connect, c);
 }
 
 
@@ -978,16 +1004,16 @@ static void continue_rpc_connect(struct composite_context *ctx)
   Stage 2: Receive policy handle to the connected SAMR service and issue
   a request to enumerate domain databases available
 */
-static void continue_samr_connect(struct rpc_request *req)
+static void continue_samr_connect(struct tevent_req *subreq)
 {
        struct composite_context *c;
        struct domain_list_state *s;
-       struct rpc_request *enumdom_req;
 
-       c = talloc_get_type(req->async.private_data, struct composite_context);
+       c = tevent_req_callback_data(subreq, struct composite_context);
        s = talloc_get_type(c->private_data, struct domain_list_state);
        
-       c->status = dcerpc_samr_Connect_recv(req);
+       c->status = dcerpc_samr_Connect_r_recv(subreq, s);
+       TALLOC_FREE(subreq);
        if (!composite_is_ok(c)) return;
 
        if (s->monitor_fn) {
@@ -1008,10 +1034,12 @@ static void continue_samr_connect(struct rpc_request *req)
        s->enumdom.out.sam           = talloc(s, struct samr_SamArray *);
        if (composite_nomem(s->enumdom.out.sam, c)) return;
 
-       enumdom_req = dcerpc_samr_EnumDomains_send(s->ctx->samr.pipe, c, &s->enumdom);
-       if (composite_nomem(enumdom_req, c)) return;
+       subreq = dcerpc_samr_EnumDomains_r_send(s, c->event_ctx,
+                                               s->ctx->samr.pipe->binding_handle,
+                                               &s->enumdom);
+       if (composite_nomem(subreq, c)) return;
 
-       composite_continue_rpc(c, enumdom_req, continue_samr_enum_domains, c);
+       tevent_req_set_callback(subreq, continue_samr_enum_domains, c);
 }
 
 
@@ -1020,17 +1048,16 @@ static void continue_samr_connect(struct rpc_request *req)
   enumeration is not complete yet. Close samr connection handle
   upon completion.
 */
-static void continue_samr_enum_domains(struct rpc_request *req)
+static void continue_samr_enum_domains(struct tevent_req *subreq)
 {
        struct composite_context *c;
        struct domain_list_state *s;
-       struct rpc_request *enumdom_req;
-       struct rpc_request *samrclose_req;
 
-       c = talloc_get_type(req->async.private_data, struct composite_context);
+       c = tevent_req_callback_data(subreq, struct composite_context);
        s = talloc_get_type(c->private_data, struct domain_list_state);
        
-       c->status = dcerpc_samr_EnumDomains_recv(req);
+       c->status = dcerpc_samr_EnumDomains_r_recv(subreq, s);
+       TALLOC_FREE(subreq);
        if (!composite_is_ok(c)) return;
 
        if (s->monitor_fn) {
@@ -1057,10 +1084,12 @@ static void continue_samr_enum_domains(struct rpc_request *req)
                s->enumdom.out.resume_handle = &s->resume_handle;
 
                /* send the request */
-               enumdom_req = dcerpc_samr_EnumDomains_send(s->ctx->samr.pipe, c, &s->enumdom);
-               if (composite_nomem(enumdom_req, c)) return;
+               subreq = dcerpc_samr_EnumDomains_r_send(s, c->event_ctx,
+                                                       s->ctx->samr.pipe->binding_handle,
+                                                       &s->enumdom);
+               if (composite_nomem(subreq, c)) return;
 
-               composite_continue_rpc(c, enumdom_req, continue_samr_enum_domains, c);
+               tevent_req_set_callback(subreq, continue_samr_enum_domains, c);
 
        } else {
                composite_error(c, s->enumdom.out.result);
@@ -1072,25 +1101,28 @@ static void continue_samr_enum_domains(struct rpc_request *req)
        s->samrclose.out.handle = &s->connect_handle;
        
        /* send the request */
-       samrclose_req = dcerpc_samr_Close_send(s->ctx->samr.pipe, c, &s->samrclose);
-       if (composite_nomem(samrclose_req, c)) return;
+       subreq = dcerpc_samr_Close_r_send(s, c->event_ctx,
+                                         s->ctx->samr.pipe->binding_handle,
+                                         &s->samrclose);
+       if (composite_nomem(subreq, c)) return;
 
-       composite_continue_rpc(c, samrclose_req, continue_samr_close_handle, c);
+       tevent_req_set_callback(subreq, continue_samr_close_handle, c);
 }
 
 
 /*
   Stage 4: Receive result of closing samr connection handle.
 */
-static void continue_samr_close_handle(struct rpc_request *req)
+static void continue_samr_close_handle(struct tevent_req *subreq)
 {
        struct composite_context *c;
        struct domain_list_state *s;
 
-       c = talloc_get_type(req->async.private_data, struct composite_context);
+       c = tevent_req_callback_data(subreq, struct composite_context);
        s = talloc_get_type(c->private_data, struct domain_list_state);
 
-       c->status = dcerpc_samr_Close_recv(req);
+       c->status = dcerpc_samr_Close_r_recv(subreq, s);
+       TALLOC_FREE(subreq);
        if (!composite_is_ok(c)) return;
 
        if (s->monitor_fn) {
@@ -1163,7 +1195,7 @@ struct composite_context* libnet_DomainList_send(struct libnet_context *ctx,
        struct composite_context *c;
        struct domain_list_state *s;
        struct composite_context *rpcconn_req;
-       struct rpc_request *samrconn_req;
+       struct tevent_req *subreq;
 
        /* composite context and state structure allocation */
        c = composite_create(ctx, ctx->event_ctx);
@@ -1199,10 +1231,12 @@ struct composite_context* libnet_DomainList_send(struct libnet_context *ctx,
                s->samrconn.in.access_mask     = SEC_GENERIC_READ;
                s->samrconn.out.connect_handle = &s->connect_handle;
                
-               samrconn_req = dcerpc_samr_Connect_send(s->ctx->samr.pipe, c, &s->samrconn);
-               if (composite_nomem(samrconn_req, c)) return c;
+               subreq = dcerpc_samr_Connect_r_send(s, c->event_ctx,
+                                                   s->ctx->samr.pipe->binding_handle,
+                                                   &s->samrconn);
+               if (composite_nomem(subreq, c)) return c;
 
-               composite_continue_rpc(c, samrconn_req, continue_samr_connect, c);
+               tevent_req_set_callback(subreq, continue_samr_connect, c);
        }
 
        return c;