summaryrefslogtreecommitdiff
path: root/source4/libnet
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-12-03 19:22:51 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:28:47 -0500
commitc83efbe9009bff6cd3f11736219f182d781e53cc (patch)
tree268cbc460929a1e678dce0540f013a862c287386 /source4/libnet
parent6d7630a5166b96ac50be2d49077b3819dc9a1bb5 (diff)
downloadsamba-c83efbe9009bff6cd3f11736219f182d781e53cc.tar.gz
samba-c83efbe9009bff6cd3f11736219f182d781e53cc.tar.bz2
samba-c83efbe9009bff6cd3f11736219f182d781e53cc.zip
r20021: implement a CLDAP netlogon request to get some infos
needed for becoming a dc. metze (This used to be commit 6a007aaa512849459ddc172b38f73561cc5e4846)
Diffstat (limited to 'source4/libnet')
-rw-r--r--source4/libnet/libnet_become_dc.c112
-rw-r--r--source4/libnet/libnet_become_dc.h5
2 files changed, 109 insertions, 8 deletions
diff --git a/source4/libnet/libnet_become_dc.c b/source4/libnet/libnet_become_dc.c
index 5cbb50055f..c446eea411 100644
--- a/source4/libnet/libnet_become_dc.c
+++ b/source4/libnet/libnet_become_dc.c
@@ -21,36 +21,114 @@
#include "includes.h"
#include "libnet/libnet.h"
#include "libcli/composite/composite.h"
+#include "libcli/cldap/cldap.h"
struct libnet_BecomeDC_state {
+ struct composite_context *creq;
+
struct libnet_context *libnet;
+ struct {
+ struct cldap_socket *sock;
+ struct cldap_netlogon io;
+ struct nbt_cldap_netlogon_5 netlogon5;
+ } cldap;
+
struct becomeDC_ldap {
struct ldb_context *ldb;
struct ldb_message *rootdse;
} ldap1;
struct {
+ /* input */
const char *dns_name;
const char *netbios_name;
+
+ /* constructed */
+ struct GUID guid;
const char *domain_dn_str;
+ } domain;
+
+ struct {
+ /* constructed */
+ const char *dns_name;
const char *config_dn_str;
const char *schema_dn_str;
- } domain_info;
+ } forest;
struct {
+ /* input */
+ const char *address;
+
+ /* constructed */
const char *dns_name;
const char *netbios_name;
- const char *address;
+ const char *site_name;
const char *server_dn_str;
const char *ntds_dn_str;
} source_dsa;
struct {
- const char *hostname;
+ /* input */
+ const char *netbios_name;
+
+ /* constructed */
+ const char *dns_name;
+ const char *site_name;
+ const char *computer_dn_str;
+ const char *server_dn_str;
+ const char *ntds_dn_str;
} dest_dsa;
};
+static void becomeDC_recv_cldap(struct cldap_request *req)
+{
+ struct libnet_BecomeDC_state *s = talloc_get_type(req->async.private,
+ struct libnet_BecomeDC_state);
+ struct composite_context *c = s->creq;
+
+ c->status = cldap_netlogon_recv(req, s, &s->cldap.io);
+ if (!composite_is_ok(c)) return;
+
+ s->cldap.netlogon5 = s->cldap.io.out.netlogon.logon5;
+
+ s->domain.dns_name = s->cldap.netlogon5.dns_domain;
+ s->domain.netbios_name = s->cldap.netlogon5.domain;
+ s->domain.guid = s->cldap.netlogon5.domain_uuid;
+
+ s->forest.dns_name = s->cldap.netlogon5.forest;
+
+ s->source_dsa.dns_name = s->cldap.netlogon5.pdc_dns_name;
+ s->source_dsa.netbios_name = s->cldap.netlogon5.pdc_name;
+ s->source_dsa.site_name = s->cldap.netlogon5.server_site;
+
+ s->dest_dsa.site_name = s->cldap.netlogon5.client_site;
+
+ composite_error(c, NT_STATUS_NOT_IMPLEMENTED);
+}
+
+static void becomeDC_send_cldap(struct libnet_BecomeDC_state *s)
+{
+ struct composite_context *c = s->creq;
+ struct cldap_request *req;
+
+ s->cldap.io.in.dest_address = s->source_dsa.address;
+ s->cldap.io.in.realm = s->domain.dns_name;
+ s->cldap.io.in.host = s->dest_dsa.netbios_name;
+ s->cldap.io.in.user = NULL;
+ s->cldap.io.in.domain_guid = NULL;
+ s->cldap.io.in.domain_sid = NULL;
+ s->cldap.io.in.acct_control = -1;
+ s->cldap.io.in.version = 6;
+
+ s->cldap.sock = cldap_socket_init(s, s->libnet->event_ctx);
+ if (composite_nomem(s->cldap.sock, c)) return;
+
+ req = cldap_netlogon_send(s->cldap.sock, &s->cldap.io);
+ if (composite_nomem(req, c)) return;
+ req->async.fn = becomeDC_recv_cldap;
+ req->async.private = s;
+}
static NTSTATUS becomeDC_ldap_connect(struct libnet_BecomeDC_state *s, struct becomeDC_ldap *ldap)
{
@@ -66,6 +144,7 @@ struct composite_context *libnet_BecomeDC_send(struct libnet_context *ctx, TALLO
{
struct composite_context *c;
struct libnet_BecomeDC_state *s;
+ char *tmp_name;
c = composite_create(mem_ctx, ctx->event_ctx);
if (c == NULL) return NULL;
@@ -73,18 +152,37 @@ struct composite_context *libnet_BecomeDC_send(struct libnet_context *ctx, TALLO
s = talloc_zero(c, struct libnet_BecomeDC_state);
if (composite_nomem(s, c)) return c;
c->private_data = s;
+ s->creq = c;
+ s->libnet = ctx;
- s->libnet = ctx;
+ /* Domain input */
+ s->domain.dns_name = talloc_strdup(s, r->in.domain_dns_name);
+ if (composite_nomem(s->domain.dns_name, c)) return c;
+ s->domain.netbios_name = talloc_strdup(s, r->in.domain_netbios_name);
+ if (composite_nomem(s->domain.netbios_name, c)) return c;
- s->source_dsa.address = talloc_strdup(s, r->in.dest_address);
+ /* Source DSA input */
+ s->source_dsa.address = talloc_strdup(s, r->in.source_dsa_address);
if (composite_nomem(s->source_dsa.address, c)) return c;
- c->status = becomeDC_ldap_connect(s, &s->ldap1);
+ /* Destination DSA input */
+ s->dest_dsa.netbios_name= talloc_strdup(s, r->in.dest_dsa_netbios_name);
+ if (composite_nomem(s->dest_dsa.netbios_name, c)) return c;
+
+ /* Destination DSA dns_name construction */
+ tmp_name = strlower_talloc(s, s->dest_dsa.netbios_name);
+ if (composite_nomem(tmp_name, c)) return c;
+ s->dest_dsa.dns_name = talloc_asprintf_append(tmp_name, ".%s",
+ s->domain.dns_name);
+ if (composite_nomem(s->dest_dsa.dns_name, c)) return c;
+
+ becomeDC_send_cldap(s);
+/* c->status = becomeDC_ldap_connect(s, &s->ldap1);
if (!composite_is_ok(c)) return c;
c->status = becomeDC_ldap1_requests(s);
if (!composite_is_ok(c)) return c;
-
+*/
return c;
}
diff --git a/source4/libnet/libnet_become_dc.h b/source4/libnet/libnet_become_dc.h
index 6cda4d89b3..078281d72d 100644
--- a/source4/libnet/libnet_become_dc.h
+++ b/source4/libnet/libnet_become_dc.h
@@ -20,7 +20,10 @@
struct libnet_BecomeDC {
struct {
- const char *dest_address;
+ const char *domain_dns_name;
+ const char *domain_netbios_name;
+ const char *source_dsa_address;
+ const char *dest_dsa_netbios_name;
} in;
struct {