summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/libnet/libnet_become_dc.c4
-rw-r--r--source4/libnet/libnet_unbecome_dc.c48
2 files changed, 49 insertions, 3 deletions
diff --git a/source4/libnet/libnet_become_dc.c b/source4/libnet/libnet_become_dc.c
index 502b61d87a..fc46691ab3 100644
--- a/source4/libnet/libnet_become_dc.c
+++ b/source4/libnet/libnet_become_dc.c
@@ -712,7 +712,7 @@ static NTSTATUS becomeDC_ldap1_server_object_add(struct libnet_BecomeDC_state *s
msg = ldb_msg_new(s);
NT_STATUS_HAVE_NO_MEMORY(msg);
- msg->dn = ldb_dn_new_fmt(msg, s->ldap1.ldb, "CN=not,CN=add,CN=%s,CN=Servers,CN=%s,CN=Sites,%s",
+ msg->dn = ldb_dn_new_fmt(msg, s->ldap1.ldb, "CN=%s,CN=Servers,CN=%s,CN=Sites,%s",
s->dest_dsa.netbios_name,
s->dest_dsa.site_name,
s->forest.config_dn_str);
@@ -792,7 +792,7 @@ static void becomeDC_connect_ldap1(struct libnet_BecomeDC_state *s)
if (!composite_is_ok(c)) return;
c->status = becomeDC_ldap1_server_object_add(s);
-/* ignore for now... if (!composite_is_ok(c)) return;*/
+ if (!composite_is_ok(c)) return;
becomeDC_connect_ldap2(s);
}
diff --git a/source4/libnet/libnet_unbecome_dc.c b/source4/libnet/libnet_unbecome_dc.c
index d80ac99aab..b84b4d9ff5 100644
--- a/source4/libnet/libnet_unbecome_dc.c
+++ b/source4/libnet/libnet_unbecome_dc.c
@@ -50,6 +50,7 @@ struct libnet_UnbecomeDC_state {
struct drsuapi_DsBind bind_r;
struct GUID bind_guid;
struct policy_handle bind_handle;
+ struct drsuapi_DsRemoveDSServer rm_ds_srv_r;
} drsuapi;
struct {
@@ -191,6 +192,12 @@ static NTSTATUS unbecomeDC_ldap_rootdse(struct libnet_UnbecomeDC_state *s)
if (!s->forest.config_dn_str) return NT_STATUS_INVALID_NETWORK_RESPONSE;
talloc_steal(s, s->forest.config_dn_str);
+ s->dest_dsa.server_dn_str = talloc_asprintf(s, "CN=%s,CN=Servers,CN=%s,CN=Sites,%s",
+ s->dest_dsa.netbios_name,
+ s->dest_dsa.site_name,
+ s->forest.config_dn_str);
+ NT_STATUS_HAVE_NO_MEMORY(s->dest_dsa.server_dn_str);
+
talloc_free(r);
return NT_STATUS_OK;
}
@@ -420,11 +427,50 @@ static void unbecomeDC_drsuapi_bind_recv(struct rpc_request *req)
unbecomeDC_drsuapi_remove_ds_server_send(s);
}
+static void unbecomeDC_drsuapi_remove_ds_server_recv(struct rpc_request *req);
+
static void unbecomeDC_drsuapi_remove_ds_server_send(struct libnet_UnbecomeDC_state *s)
{
struct composite_context *c = s->creq;
+ struct rpc_request *req;
+ struct drsuapi_DsRemoveDSServer *r = &s->drsuapi.rm_ds_srv_r;
+
+ r->in.bind_handle = &s->drsuapi.bind_handle;
+ r->in.level = 1;
+ r->in.req.req1.server_dn= s->dest_dsa.server_dn_str;
+ r->in.req.req1.domain_dn= s->domain.dn_str;
+ r->in.req.req1.unknown = 0x00000001;
+
+ req = dcerpc_drsuapi_DsRemoveDSServer_send(s->drsuapi.pipe, s, r);
+ composite_continue_rpc(c, req, unbecomeDC_drsuapi_remove_ds_server_recv, s);
+}
+
+static void unbecomeDC_drsuapi_remove_ds_server_recv(struct rpc_request *req)
+{
+ struct libnet_UnbecomeDC_state *s = talloc_get_type(req->async.private,
+ struct libnet_UnbecomeDC_state);
+ struct composite_context *c = s->creq;
+ struct drsuapi_DsRemoveDSServer *r = &s->drsuapi.rm_ds_srv_r;
+
+ c->status = dcerpc_ndr_request_recv(req);
+ if (!composite_is_ok(c)) return;
+
+ if (!W_ERROR_IS_OK(r->out.result)) {
+ composite_error(c, werror_to_ntstatus(r->out.result));
+ return;
+ }
+
+ if (r->out.level != 1) {
+ composite_error(c, NT_STATUS_INVALID_NETWORK_RESPONSE);
+ return;
+ }
+
+ if (!W_ERROR_IS_OK(r->out.res.res1.status)) {
+ composite_error(c, werror_to_ntstatus(r->out.res.res1.status));
+ return;
+ }
- composite_error(c, NT_STATUS_NOT_IMPLEMENTED);
+ composite_done(c);
}
struct composite_context *libnet_UnbecomeDC_send(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, struct libnet_UnbecomeDC *r)