s4:libnet: make use of dcerpc_binding_[g|s]et_*() in libnet_join.c
authorStefan Metzmacher <metze@samba.org>
Thu, 30 Jan 2014 21:04:11 +0000 (22:04 +0100)
committerGünther Deschner <gd@samba.org>
Thu, 13 Feb 2014 10:54:16 +0000 (11:54 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
source4/libnet/libnet_join.c

index 150bd6a1ab4ff641c462b560efd42ab07ff9f5af..1c5253191de5f41ba768bcbc4615f4083ad1a46c 100644 (file)
@@ -57,6 +57,7 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J
 
        struct dcerpc_pipe *drsuapi_pipe;
        struct dcerpc_binding *drsuapi_binding;
+       enum dcerpc_transport_t transport;
        struct drsuapi_DsBind r_drsuapi_bind;
        struct drsuapi_DsCrackNames r_crack_names;
        struct drsuapi_DsNameString names[1];
@@ -101,13 +102,37 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J
                return NT_STATUS_NO_MEMORY;
        }
 
+       transport = dcerpc_binding_get_transport(drsuapi_binding);
 
        /* DRSUAPI is only available on IP_TCP, and locally on NCALRPC */
-       if (drsuapi_binding->transport != NCALRPC) {
-               drsuapi_binding->transport = NCACN_IP_TCP;
+       if (transport != NCALRPC) {
+               status = dcerpc_binding_set_transport(drsuapi_binding, NCACN_IP_TCP);
+               if (!NT_STATUS_IS_OK(status)) {
+                       r->out.error_string = talloc_asprintf(r,
+                                               "dcerpc_binding_set_transport failed: %s",
+                                               nt_errstr(status));
+                       talloc_free(tmp_ctx);
+                       return status;
+               }
+       }
+
+       status = dcerpc_binding_set_string_option(drsuapi_binding, "endpoint", NULL);
+       if (!NT_STATUS_IS_OK(status)) {
+               r->out.error_string = talloc_asprintf(r,
+                                       "dcerpc_binding_set_string_option failed: %s",
+                                       nt_errstr(status));
+               talloc_free(tmp_ctx);
+               return status;
+       }
+
+       status = dcerpc_binding_set_flags(drsuapi_binding, DCERPC_SEAL, 0);
+       if (!NT_STATUS_IS_OK(status)) {
+               r->out.error_string = talloc_asprintf(r,
+                                       "dcerpc_binding_set_flags failed: %s",
+                                       nt_errstr(status));
+               talloc_free(tmp_ctx);
+               return status;
        }
-       drsuapi_binding->endpoint = NULL;
-       drsuapi_binding->flags |= DCERPC_SEAL;
 
        status = dcerpc_pipe_connect_b(tmp_ctx, 
                                       &drsuapi_pipe,