From 5c3ccf77666ab63e8dfc980188c365a7b15bafcf Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 30 Oct 2001 01:49:44 +0000 Subject: Added samlogon command to test against win2k native mode server. I think there's a bug in the marshalling of net_sam_logon. (This used to be commit 7c5ac46b8ad0be681d102e7ef3478d64d7a2b8e6) --- source3/rpcclient/cmd_netlogon.c | 58 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index a935900faa..180d0cc771 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -258,6 +258,63 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, return result; } +/* Log on a domain user */ + +static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, + TALLOC_CTX *mem_ctx, int argc, + char **argv) +{ + unsigned char trust_passwd[16]; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + int validation_level = 3; + char *username, *password; + + /* Check arguments */ + + if (argc < 3 || argc > 4) { + fprintf(stderr, "Usage: samlogon " + "[validation level]\n"); + return NT_STATUS_OK; + } + + username = argv[1]; + password = argv[2]; + + if (argc == 4) + sscanf(argv[3], "%i", &validation_level); + + /* Authenticate ourselves with the domain controller */ + + if (!secrets_init()) { + fprintf(stderr, "Unable to initialise secrets database\n"); + return result; + } + + if (!secrets_fetch_trust_account_password(lp_workgroup(), trust_passwd, + NULL)) { + fprintf(stderr, "could not fetch trust account password\n"); + goto done; + } + + result = cli_nt_setup_creds(cli, trust_passwd); + + if (!NT_STATUS_IS_OK(result)) { + fprintf(stderr, "Error initialising session creds\n"); + goto done; + } + + /* Perform the sam logon */ + + result = cli_netlogon_sam_logon(cli, mem_ctx, username, password, + validation_level); + + if (!NT_STATUS_IS_OK(result)) + goto done; + + done: + return result; +} + /* List of commands exported by this module */ struct cmd_set netlogon_commands[] = { @@ -268,6 +325,7 @@ struct cmd_set netlogon_commands[] = { { "logonctrl", cmd_netlogon_logon_ctrl, PIPE_NETLOGON, "Logon Control", "" }, { "samsync", cmd_netlogon_sam_sync, PIPE_NETLOGON, "Sam Synchronisation", "" }, { "samdeltas", cmd_netlogon_sam_deltas, PIPE_NETLOGON, "Query Sam Deltas", "" }, + { "samlogon", cmd_netlogon_sam_logon, PIPE_NETLOGON, "Sam Logon", "" }, { NULL } }; -- cgit