1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-30 19:42:05 +03:00

s3-net: use libnetjoin for "net rpc testjoin".

Guenther

Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Günther Deschner
2009-02-03 20:10:05 +01:00
committed by Andreas Schneider
parent 1242ab0cb3
commit 9cfa625160
3 changed files with 67 additions and 30 deletions

View File

@ -145,6 +145,7 @@ int run_rpc_command(struct net_context *c,
int argc,
const char **argv);
int net_rpc_changetrustpw(struct net_context *c, int argc, const char **argv);
int net_rpc_testjoin(struct net_context *c, int argc, const char **argv);
int net_rpc_join(struct net_context *c, int argc, const char **argv);
NTSTATUS rpc_info_internals(struct net_context *c,
const struct dom_sid *domain_sid,
@ -205,7 +206,6 @@ NTSTATUS net_rpc_join_ok(struct net_context *c, const char *domain,
const char *server,
const struct sockaddr_storage *server_ss);
int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv);
int net_rpc_testjoin(struct net_context *c, int argc, const char **argv);
/* The following definitions come from utils/net_rpc_printer.c */

View File

@ -437,6 +437,72 @@ fail:
return -1;
}
/**
* check that a join is OK
*
* @return A shell status integer (0 for success)
*
**/
int net_rpc_testjoin(struct net_context *c, int argc, const char **argv)
{
NTSTATUS status;
TALLOC_CTX *mem_ctx;
const char *domain = c->opt_target_workgroup;
const char *dc = c->opt_host;
if (c->display_usage) {
d_printf("Usage\n"
"net rpc testjoin\n"
" Test if a join is OK\n");
return 0;
}
mem_ctx = talloc_init("net_rpc_testjoin");
if (!mem_ctx) {
return -1;
}
if (!dc) {
struct netr_DsRGetDCNameInfo *info;
if (!c->msg_ctx) {
d_fprintf(stderr, _("Could not initialise message context. "
"Try running as root\n"));
talloc_destroy(mem_ctx);
return -1;
}
status = dsgetdcname(mem_ctx,
c->msg_ctx,
domain,
NULL,
NULL,
DS_RETURN_DNS_NAME,
&info);
if (!NT_STATUS_IS_OK(status)) {
talloc_destroy(mem_ctx);
return -1;
}
dc = strip_hostname(info->dc_unc);
}
/* Display success or failure */
status = libnet_join_ok(c->opt_workgroup, lp_netbios_name(), dc,
c->opt_kerberos);
if (!NT_STATUS_IS_OK(status)) {
fprintf(stderr,"Join to domain '%s' is not valid: %s\n",
domain, nt_errstr(status));
talloc_destroy(mem_ctx);
return -1;
}
printf("Join to '%s' is OK\n",domain);
talloc_destroy(mem_ctx);
return 0;
}
/**
* 'net rpc join' entrypoint.
* @param argc Standard main() style argc.

View File

@ -552,32 +552,3 @@ done:
return retval;
}
/**
* check that a join is OK
*
* @return A shell status integer (0 for success)
*
**/
int net_rpc_testjoin(struct net_context *c, int argc, const char **argv)
{
NTSTATUS nt_status;
if (c->display_usage) {
d_printf(_("Usage\n"
"net rpc testjoin\n"
" Test if a join is OK\n"));
return 0;
}
/* Display success or failure */
nt_status = net_rpc_join_ok(c, c->opt_target_workgroup, NULL, NULL);
if (!NT_STATUS_IS_OK(nt_status)) {
fprintf(stderr, _("Join to domain '%s' is not valid: %s\n"),
c->opt_target_workgroup, nt_errstr(nt_status));
return -1;
}
printf(_("Join to '%s' is OK\n"), c->opt_target_workgroup);
return 0;
}