summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-12-04 17:27:46 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:28:50 -0500
commitd0be12ad50b1bb742672a3ac6c60662ca7b3c6a3 (patch)
tree36d354218fb5a69cf1cd4f31e8431a9a86d8fa82
parent408db037ac43fd8dd1692e975cd55833d0e38315 (diff)
downloadsamba-d0be12ad50b1bb742672a3ac6c60662ca7b3c6a3.tar.gz
samba-d0be12ad50b1bb742672a3ac6c60662ca7b3c6a3.tar.bz2
samba-d0be12ad50b1bb742672a3ac6c60662ca7b3c6a3.zip
r20030: - implement the computer object search
- fix a source vs. dest dsa bug metze (This used to be commit ef9d9799a48217c49b88e214b50a92988f474340)
-rw-r--r--source4/libnet/libnet_become_dc.c46
1 files changed, 44 insertions, 2 deletions
diff --git a/source4/libnet/libnet_become_dc.c b/source4/libnet/libnet_become_dc.c
index 807ebfe724..436084748e 100644
--- a/source4/libnet/libnet_become_dc.c
+++ b/source4/libnet/libnet_become_dc.c
@@ -69,7 +69,6 @@ struct libnet_BecomeDC_state {
const char *dns_name;
const char *netbios_name;
const char *site_name;
- struct GUID site_guid;
const char *server_dn_str;
const char *ntds_dn_str;
} source_dsa;
@@ -81,9 +80,11 @@ struct libnet_BecomeDC_state {
/* constructed */
const char *dns_name;
const char *site_name;
+ struct GUID site_guid;
const char *computer_dn_str;
const char *server_dn_str;
const char *ntds_dn_str;
+ uint32_t user_account_control;
} dest_dsa;
struct {
@@ -554,12 +555,50 @@ static NTSTATUS becomeDC_ldap1_site_object(struct libnet_BecomeDC_state *s)
return NT_STATUS_INVALID_NETWORK_RESPONSE;
}
- s->source_dsa.site_guid = samdb_result_guid(r->msgs[0], "objectGUID");
+ s->dest_dsa.site_guid = samdb_result_guid(r->msgs[0], "objectGUID");
talloc_free(r);
return NT_STATUS_OK;
}
+static NTSTATUS becomeDC_ldap1_computer_object(struct libnet_BecomeDC_state *s)
+{
+ int ret;
+ struct ldb_result *r;
+ struct ldb_dn *basedn;
+ char *filter;
+ static const char *attrs[] = {
+ "distinguishedName",
+ "userAccountControl",
+ NULL
+ };
+
+ basedn = ldb_dn_new(s, s->ldap1.ldb, s->domain.dn_str);
+ NT_STATUS_HAVE_NO_MEMORY(basedn);
+
+ filter = talloc_asprintf(basedn, "(&(|(objectClass=user)(objectClass=computer))(sAMAccountName=%s$))",
+ s->dest_dsa.netbios_name);
+ NT_STATUS_HAVE_NO_MEMORY(filter);
+
+ ret = ldb_search(s->ldap1.ldb, basedn, LDB_SCOPE_SUBTREE,
+ filter, 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->dest_dsa.computer_dn_str = samdb_result_string(r->msgs[0], "distinguishedName", NULL);
+ if (!s->dest_dsa.computer_dn_str) return NT_STATUS_INVALID_NETWORK_RESPONSE;
+ talloc_steal(s, s->dest_dsa.computer_dn_str);
+
+ s->dest_dsa.user_account_control = samdb_result_uint(r->msgs[0], "userAccountControl", 0);
+
+ talloc_free(r);
+ return NT_STATUS_OK;
+}
static void becomeDC_connect_ldap1(struct libnet_BecomeDC_state *s)
{
@@ -592,6 +631,9 @@ static void becomeDC_connect_ldap1(struct libnet_BecomeDC_state *s)
c->status = becomeDC_ldap1_site_object(s);
if (!composite_is_ok(c)) return;
+ c->status = becomeDC_ldap1_computer_object(s);
+ if (!composite_is_ok(c)) return;
+
composite_error(c, NT_STATUS_NOT_IMPLEMENTED);
}