This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "include/includes.h"
#include "libcli/composite/composite.h"
#include "libcli/libcli.h"
#include "libcli/resolve/resolve.h"
+#include "libcli/finddcs.h"
+#include "param/param.h"
struct finddcs_state {
struct composite_context *ctx;
struct messaging_context *msg_ctx;
+ const char *my_netbios_name;
const char *domain_name;
struct dom_sid *domain_sid;
*/
struct composite_context *finddcs_send(TALLOC_CTX *mem_ctx,
+ const char *my_netbios_name,
const char *domain_name,
int name_type,
struct dom_sid *domain_sid,
state->ctx = c;
+ state->my_netbios_name = talloc_strdup(state, my_netbios_name);
state->domain_name = talloc_strdup(state, domain_name);
if (composite_nomem(state->domain_name, c)) return c;
state->msg_ctx = msg_ctx;
make_nbt_name(&name, state->domain_name, name_type);
- creq = resolve_name_send(&name, event_ctx,
- methods);
+ creq = resolve_name_send(&name, event_ctx, methods);
composite_continue(c, creq, finddcs_name_resolved, state);
return c;
}
struct finddcs_state *state =
talloc_get_type(ctx->async.private_data, struct finddcs_state);
struct irpc_request *ireq;
- uint32_t *nbt_servers;
+ struct server_id *nbt_servers;
const char *address;
state->ctx->status = resolve_name_recv(ctx, state, &address);
if (!composite_is_ok(state->ctx)) return;
+ /* TODO: This should try and find all the DCs, and give the
+ * caller them in the order they responded */
+
state->num_dcs = 1;
state->dcs = talloc_array(state, struct nbt_dc_name, state->num_dcs);
if (composite_nomem(state->dcs, state->ctx)) return;
return;
}
- nbt_servers = irpc_servers_byname(state->msg_ctx, "nbt_server");
- if ((nbt_servers == NULL) || (nbt_servers[0] == 0)) {
+ nbt_servers = irpc_servers_byname(state->msg_ctx, state, "nbt_server");
+ if ((nbt_servers == NULL) || (nbt_servers[0].id == 0)) {
fallback_node_status(state);
return;
}
state->r.in.domainname = state->domain_name;
state->r.in.ip_address = state->dcs[0].address;
- state->r.in.my_computername = lp_netbios_name();
- state->r.in.my_accountname = talloc_asprintf(state, "%s$",
- lp_netbios_name());
+ state->r.in.my_computername = state->my_netbios_name;
+ state->r.in.my_accountname = talloc_asprintf(state, "%s$", state->my_netbios_name);
if (composite_nomem(state->r.in.my_accountname, state->ctx)) return;
state->r.in.account_control = ACB_WSTRUST;
state->r.in.domain_sid = state->domain_sid;
ireq = irpc_call_send(state->msg_ctx, nbt_servers[0],
- &dcerpc_table_irpc, DCERPC_NBTD_GETDCNAME,
+ &ndr_table_irpc, NDR_NBTD_GETDCNAME,
&state->r, state);
if (!ireq) {
fallback_node_status(state);
}
NTSTATUS finddcs(TALLOC_CTX *mem_ctx,
+ const char *my_netbios_name,
const char *domain_name, int name_type,
struct dom_sid *domain_sid,
const char **methods,
int *num_dcs, struct nbt_dc_name **dcs)
{
struct composite_context *c = finddcs_send(mem_ctx,
+ my_netbios_name,
domain_name, name_type,
domain_sid, methods,
event_ctx, msg_ctx);