summaryrefslogtreecommitdiff
path: root/source4/libnet
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-12-04 09:40:16 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:28:48 -0500
commit6bf98f3adb9d54b0923065e464b76a2f05c3f731 (patch)
treed35338bf5240140b5ae528626b40b603f5093a27 /source4/libnet
parenteffc51d7db621ef03540070b36b1ce9d3de2eded (diff)
downloadsamba-6bf98f3adb9d54b0923065e464b76a2f05c3f731.tar.gz
samba-6bf98f3adb9d54b0923065e464b76a2f05c3f731.tar.bz2
samba-6bf98f3adb9d54b0923065e464b76a2f05c3f731.zip
r20025: - implement the windows2003update revision search
- finish the infrastructure fsmo detail searches metze (This used to be commit f1a2bd6f374321f5102f72c0ed2a9b53476d341b)
Diffstat (limited to 'source4/libnet')
-rw-r--r--source4/libnet/libnet_become_dc.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/source4/libnet/libnet_become_dc.c b/source4/libnet/libnet_become_dc.c
index 3fd920c7b8..cda31bc446 100644
--- a/source4/libnet/libnet_become_dc.c
+++ b/source4/libnet/libnet_become_dc.c
@@ -25,6 +25,7 @@
#include "lib/ldb/include/ldb.h"
#include "lib/ldb/include/ldb_errors.h"
#include "lib/db_wrap.h"
+#include "dsdb/samdb/samdb.h"
struct libnet_BecomeDC_state {
struct composite_context *creq;
@@ -88,7 +89,15 @@ struct libnet_BecomeDC_state {
uint32_t domain_behavior_version;
uint32_t config_behavior_version;
uint32_t schema_object_version;
+ uint32_t w2k3_update_revision;
} ads_options;
+
+ struct becomeDC_fsmo {
+ const char *dns_name;
+ const char *server_dn_str;
+ const char *ntds_dn_str;
+ struct GUID ntds_guid;
+ } infrastructure_fsmo;
};
static void becomeDC_connect_ldap1(struct libnet_BecomeDC_state *s);
@@ -292,11 +301,43 @@ static NTSTATUS becomeDC_ldap1_schema_object_version(struct libnet_BecomeDC_stat
return NT_STATUS_OK;
}
+static NTSTATUS becomeDC_ldap1_w2k3_update_revision(struct libnet_BecomeDC_state *s)
+{
+ int ret;
+ struct ldb_result *r;
+ struct ldb_dn *basedn;
+ static const char *attrs[] = {
+ "revision",
+ NULL
+ };
+
+ basedn = ldb_dn_new_fmt(s, s->ldap1.ldb, "CN=Windows2003Update,CN=DomainUpdates,CN=System,%s",
+ s->domain.dn_str);
+ NT_STATUS_HAVE_NO_MEMORY(basedn);
+
+ ret = ldb_search(s->ldap1.ldb, basedn, LDB_SCOPE_BASE,
+ "(objectClass=*)", attrs, &r);
+ talloc_free(basedn);
+ if (ret != LDB_SUCCESS) {
+ return NT_STATUS_LDAP(ret);
+ } else if (r->count != 1) {
+ talloc_free(r);
+ return NT_STATUS_INVALID_NETWORK_RESPONSE;
+ }
+
+ s->ads_options.w2k3_update_revision = ldb_msg_find_attr_as_uint(r->msgs[0], "revision", 0);
+
+ talloc_free(r);
+ return NT_STATUS_OK;
+}
+
static NTSTATUS becomeDC_ldap1_infrastructure_fsmo(struct libnet_BecomeDC_state *s)
{
int ret;
struct ldb_result *r;
struct ldb_dn *basedn;
+ struct ldb_dn *ntds_dn;
+ struct ldb_dn *server_dn;
static const char *_1_1_attrs[] = {
"1.1",
NULL
@@ -305,6 +346,14 @@ static NTSTATUS becomeDC_ldap1_infrastructure_fsmo(struct libnet_BecomeDC_state
"fSMORoleOwner",
NULL
};
+ static const char *dns_attrs[] = {
+ "dnsHostName",
+ NULL
+ };
+ static const char *guid_attrs[] = {
+ "objectGUID",
+ NULL
+ };
basedn = ldb_dn_new_fmt(s, s->ldap1.ldb, "<WKGUID=2fbac1870ade11d297c400c04fd8d5cd,%s>",
s->domain.dn_str);
@@ -333,7 +382,46 @@ static NTSTATUS becomeDC_ldap1_infrastructure_fsmo(struct libnet_BecomeDC_state
return NT_STATUS_INVALID_NETWORK_RESPONSE;
}
+ s->infrastructure_fsmo.ntds_dn_str = samdb_result_string(r->msgs[0], "fSMORoleOwner", NULL);
+ if (!s->infrastructure_fsmo.ntds_dn_str) return NT_STATUS_INVALID_NETWORK_RESPONSE;
+ talloc_steal(s, s->infrastructure_fsmo.ntds_dn_str);
+
+ talloc_free(r);
+
+ ntds_dn = ldb_dn_new(s, s->ldap1.ldb, s->infrastructure_fsmo.ntds_dn_str);
+ NT_STATUS_HAVE_NO_MEMORY(ntds_dn);
+
+ server_dn = ldb_dn_get_parent(s, ntds_dn);
+ NT_STATUS_HAVE_NO_MEMORY(server_dn);
+
+ ret = ldb_search(s->ldap1.ldb, server_dn, LDB_SCOPE_BASE,
+ "(objectClass=*)", dns_attrs, &r);
+ if (ret != LDB_SUCCESS) {
+ return NT_STATUS_LDAP(ret);
+ } else if (r->count != 1) {
+ talloc_free(r);
+ return NT_STATUS_INVALID_NETWORK_RESPONSE;
+ }
+
+ s->infrastructure_fsmo.dns_name = samdb_result_string(r->msgs[0], "dnsHostName", NULL);
+ if (!s->infrastructure_fsmo.dns_name) return NT_STATUS_INVALID_NETWORK_RESPONSE;
+ talloc_steal(s, s->infrastructure_fsmo.dns_name);
+
talloc_free(r);
+
+ ret = ldb_search(s->ldap1.ldb, ntds_dn, LDB_SCOPE_BASE,
+ "(objectClass=*)", guid_attrs, &r);
+ if (ret != LDB_SUCCESS) {
+ return NT_STATUS_LDAP(ret);
+ } else if (r->count != 1) {
+ talloc_free(r);
+ return NT_STATUS_INVALID_NETWORK_RESPONSE;
+ }
+
+ s->infrastructure_fsmo.ntds_guid = samdb_result_guid(r->msgs[0], "objectGUID");
+
+ talloc_free(r);
+
return NT_STATUS_NOT_IMPLEMENTED;
}
@@ -357,6 +445,9 @@ static void becomeDC_connect_ldap1(struct libnet_BecomeDC_state *s)
c->status = becomeDC_ldap1_schema_object_version(s);
if (!composite_is_ok(c)) return;
+ c->status = becomeDC_ldap1_w2k3_update_revision(s);
+ if (!composite_is_ok(c)) return;
+
c->status = becomeDC_ldap1_infrastructure_fsmo(s);
if (!composite_is_ok(c)) return;