summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mdw@samba.org>2011-11-23 09:45:31 +0100
committerStefan Metzmacher <metze@samba.org>2011-11-26 10:26:52 +0100
commitad19aa6331ab44516afa82434f125120172b3dda (patch)
tree5dea1122a91f9ddebee782176930b60dc921a4fe /source4/libcli
parent9e6c88bda5ad8ea68f2471fbbe959b1282457f52 (diff)
downloadsamba-ad19aa6331ab44516afa82434f125120172b3dda.tar.gz
samba-ad19aa6331ab44516afa82434f125120172b3dda.tar.bz2
samba-ad19aa6331ab44516afa82434f125120172b3dda.zip
s4:libcli/finddcs_cldap.c - let "finddcs_cldap" work either with the IP address or the domain name
This will be useful for a new "samba-tool domain info" command. Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/finddcs_cldap.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/source4/libcli/finddcs_cldap.c b/source4/libcli/finddcs_cldap.c
index a0f538df7c..38e828fa98 100644
--- a/source4/libcli/finddcs_cldap.c
+++ b/source4/libcli/finddcs_cldap.c
@@ -60,7 +60,6 @@ static bool finddcs_cldap_ipaddress(struct finddcs_cldap_state *state, struct fi
/*
* find a list of DCs via DNS/CLDAP
- *
*/
struct tevent_req *finddcs_cldap_send(TALLOC_CTX *mem_ctx,
struct finddcs *io,
@@ -78,9 +77,14 @@ struct tevent_req *finddcs_cldap_send(TALLOC_CTX *mem_ctx,
state->req = req;
state->ev = event_ctx;
state->minimum_dc_flags = io->in.minimum_dc_flags;
- state->domain_name = talloc_strdup(state, io->in.domain_name);
- if (tevent_req_nomem(state->domain_name, req)) {
- return tevent_req_post(req, event_ctx);
+
+ if (io->in.domain_name) {
+ state->domain_name = talloc_strdup(state, io->in.domain_name);
+ if (tevent_req_nomem(state->domain_name, req)) {
+ return tevent_req_post(req, event_ctx);
+ }
+ } else {
+ state->domain_name = NULL;
}
if (io->in.domain_sid) {
@@ -97,17 +101,26 @@ struct tevent_req *finddcs_cldap_send(TALLOC_CTX *mem_ctx,
if (!finddcs_cldap_ipaddress(state, io)) {
return tevent_req_post(req, event_ctx);
}
- } else if (strchr(state->domain_name, '.')) {
- /* looks like a DNS name */
- DEBUG(4,("finddcs: searching for a DC by DNS domain %s\n", state->domain_name));
- if (!finddcs_cldap_srv_lookup(state, io, resolve_ctx, event_ctx)) {
- return tevent_req_post(req, event_ctx);
+ } else if (io->in.domain_name) {
+ if (strchr(state->domain_name, '.')) {
+ /* looks like a DNS name */
+ DEBUG(4,("finddcs: searching for a DC by DNS domain %s\n", state->domain_name));
+ if (!finddcs_cldap_srv_lookup(state, io, resolve_ctx,
+ event_ctx)) {
+ return tevent_req_post(req, event_ctx);
+ }
+ } else {
+ DEBUG(4,("finddcs: searching for a DC by NBT lookup %s\n", state->domain_name));
+ if (!finddcs_cldap_nbt_lookup(state, io, resolve_ctx,
+ event_ctx)) {
+ return tevent_req_post(req, event_ctx);
+ }
}
} else {
- DEBUG(4,("finddcs: searching for a DC by NBT lookup %s\n", state->domain_name));
- if (!finddcs_cldap_nbt_lookup(state, io, resolve_ctx, event_ctx)) {
- return tevent_req_post(req, event_ctx);
- }
+ /* either we have the domain name or the IP address */
+ tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER_MIX);
+ DEBUG(2,("finddcs: Please specify at least the domain name or the IP address! \n"));
+ return tevent_req_post(req, event_ctx);
}
return req;
@@ -233,7 +246,7 @@ static void finddcs_cldap_next_server(struct finddcs_cldap_state *state)
return;
}
- if (strchr(state->domain_name, '.')) {
+ if ((state->domain_name != NULL) && (strchr(state->domain_name, '.'))) {
state->netlogon->in.realm = state->domain_name;
}
if (state->domain_sid) {