summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-09-23 19:49:12 -0700
committerAndrew Tridgell <tridge@samba.org>2010-09-25 10:38:45 -0700
commita360428588467c29e8eb40b27a9db525d4c2ea96 (patch)
tree7d928d7fa62161b9e06b39509742f6fc5b079ff5
parentbd228f98588919880ca3a9e4c1f23e17ce78aca5 (diff)
downloadsamba-a360428588467c29e8eb40b27a9db525d4c2ea96.tar.gz
samba-a360428588467c29e8eb40b27a9db525d4c2ea96.tar.bz2
samba-a360428588467c29e8eb40b27a9db525d4c2ea96.zip
s4-finddcs: allow override of server IP address
this will be used to implement --ipaddress option to net commands Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
-rw-r--r--source4/libcli/finddc.h2
-rw-r--r--source4/libcli/finddcs_cldap.c36
2 files changed, 37 insertions, 1 deletions
diff --git a/source4/libcli/finddc.h b/source4/libcli/finddc.h
index 3f1caf9ce5..86e2f2c231 100644
--- a/source4/libcli/finddc.h
+++ b/source4/libcli/finddc.h
@@ -27,6 +27,8 @@ struct finddcs {
const char *site_name; /* optional */
struct dom_sid *domain_sid; /* optional */
uint32_t minimum_dc_flags; /* DS_SERVER_* */
+ const char *server_address; /* optional, bypass name
+ resolution */
} in;
struct {
const char *address; /* IP address of server */
diff --git a/source4/libcli/finddcs_cldap.c b/source4/libcli/finddcs_cldap.c
index b7a8324c0f..4129ce26aa 100644
--- a/source4/libcli/finddcs_cldap.c
+++ b/source4/libcli/finddcs_cldap.c
@@ -55,6 +55,8 @@ static bool finddcs_cldap_nbt_lookup(struct finddcs_cldap_state *state,
struct resolve_context *resolve_ctx,
struct tevent_context *event_ctx);
static void finddcs_cldap_name_resolved(struct composite_context *ctx);
+static void finddcs_cldap_next_server(struct finddcs_cldap_state *state);
+static bool finddcs_cldap_ipaddress(struct finddcs_cldap_state *state, struct finddcs *io);
/*
@@ -91,7 +93,11 @@ struct tevent_req *finddcs_cldap_send(TALLOC_CTX *mem_ctx,
state->domain_sid = NULL;
}
- if (strchr(state->domain_name, '.')) {
+ if (io->in.server_address) {
+ if (!finddcs_cldap_ipaddress(state, io)) {
+ return tevent_req_post(req, event_ctx);
+ }
+ } else if (strchr(state->domain_name, '.')) {
/* looks like a DNS name */
if (!finddcs_cldap_srv_lookup(state, io, resolve_ctx, event_ctx)) {
return tevent_req_post(req, event_ctx);
@@ -105,6 +111,34 @@ struct tevent_req *finddcs_cldap_send(TALLOC_CTX *mem_ctx,
return req;
}
+
+/*
+ we've been told the IP of the server, bypass name
+ resolution and go straight to CLDAP
+*/
+static bool finddcs_cldap_ipaddress(struct finddcs_cldap_state *state, struct finddcs *io)
+{
+ NTSTATUS status;
+
+ state->srv_addresses = talloc_array(state, const char *, 2);
+ if (tevent_req_nomem(state->srv_addresses, state->req)) {
+ return false;
+ }
+ state->srv_addresses[0] = talloc_strdup(state->srv_addresses, io->in.server_address);
+ if (tevent_req_nomem(state->srv_addresses[0], state->req)) {
+ return false;
+ }
+ state->srv_addresses[1] = NULL;
+ state->srv_address_index = 0;
+ status = cldap_socket_init(state, state->ev, NULL, NULL, &state->cldap);
+ if (tevent_req_nterror(state->req, status)) {
+ return false;
+ }
+
+ finddcs_cldap_next_server(state);
+ return tevent_req_is_nterror(state->req, &status);
+}
+
/*
start a SRV DNS lookup
*/