summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-12-06 12:15:07 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:28:55 -0500
commit85497ed8cbfce296664316d573b800b75000bcbc (patch)
treea8c5634aa7f90dc8a1cec27f3d2e67aee327e534 /source4
parent840ef0d5cfcf5c688dcaf356e32de280047aca15 (diff)
downloadsamba-85497ed8cbfce296664316d573b800b75000bcbc.tar.gz
samba-85497ed8cbfce296664316d573b800b75000bcbc.tar.bz2
samba-85497ed8cbfce296664316d573b800b75000bcbc.zip
r20052: implement the first drsuapi connection
metze (This used to be commit 96e5d896553abac79d9e302173facf357e0cfff7)
Diffstat (limited to 'source4')
-rw-r--r--source4/libnet/libnet_become_dc.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/source4/libnet/libnet_become_dc.c b/source4/libnet/libnet_become_dc.c
index 0bc0fed335..34022701d0 100644
--- a/source4/libnet/libnet_become_dc.c
+++ b/source4/libnet/libnet_become_dc.c
@@ -27,6 +27,7 @@
#include "lib/db_wrap.h"
#include "dsdb/samdb/samdb.h"
#include "dsdb/common/flags.h"
+#include "librpc/gen_ndr/ndr_drsuapi_c.h"
struct libnet_BecomeDC_state {
struct composite_context *creq;
@@ -44,6 +45,15 @@ struct libnet_BecomeDC_state {
const struct ldb_message *rootdse;
} ldap1, ldap2;
+ struct becomeDC_drsuapi {
+ struct libnet_BecomeDC_state *s;
+ struct dcerpc_binding *binding;
+ struct dcerpc_pipe *pipe;
+ struct drsuapi_DsBind bind_r;
+ struct GUID bind_guid;
+ struct policy_handle bind_handle;
+ } drsuapi1;
+
struct {
/* input */
const char *dns_name;
@@ -800,6 +810,10 @@ static NTSTATUS becomeDC_ldap1_server_object_modify(struct libnet_BecomeDC_state
return NT_STATUS_OK;
}
+static void becomeDC_drsuapi_connect_send(struct libnet_BecomeDC_state *s,
+ struct becomeDC_drsuapi *drsuapi,
+ void (*recv_fn)(struct composite_context *req));
+static void becomeDC_drsuapi1_connect_recv(struct composite_context *req);
static void becomeDC_connect_ldap2(struct libnet_BecomeDC_state *s);
static void becomeDC_connect_ldap1(struct libnet_BecomeDC_state *s)
@@ -848,6 +862,40 @@ static void becomeDC_connect_ldap1(struct libnet_BecomeDC_state *s)
c->status = becomeDC_ldap1_server_object_modify(s);
if (!composite_is_ok(c)) return;
+ becomeDC_drsuapi_connect_send(s, &s->drsuapi1, becomeDC_drsuapi1_connect_recv);
+}
+
+static void becomeDC_drsuapi_connect_send(struct libnet_BecomeDC_state *s,
+ struct becomeDC_drsuapi *drsuapi,
+ void (*recv_fn)(struct composite_context *req))
+{
+ struct composite_context *c = s->creq;
+ struct composite_context *creq;
+ char *binding_str;
+
+ drsuapi->s = s;
+
+ binding_str = talloc_asprintf(s, "ncacn_ip_tcp:%s[krb5,seal]", s->source_dsa.dns_name);
+ if (composite_nomem(binding_str, c)) return;
+
+ c->status = dcerpc_parse_binding(s, binding_str, &drsuapi->binding);
+ talloc_free(binding_str);
+ if (!composite_is_ok(c)) return;
+
+ creq = dcerpc_pipe_connect_b_send(s, drsuapi->binding, &dcerpc_table_drsuapi,
+ s->libnet->cred, s->libnet->event_ctx);
+ composite_continue(c, creq, recv_fn, s);
+}
+
+static void becomeDC_drsuapi1_connect_recv(struct composite_context *req)
+{
+ struct libnet_BecomeDC_state *s = talloc_get_type(req->async.private_data,
+ struct libnet_BecomeDC_state);
+ struct composite_context *c = s->creq;
+
+ c->status = dcerpc_pipe_connect_b_recv(req, s, &s->drsuapi1.pipe);
+ if (!composite_is_ok(c)) return;
+
becomeDC_connect_ldap2(s);
}