From 66d5d73a5d75e88a77970f7b27687b8354ab2e80 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 25 Sep 1998 21:01:52 +0000 Subject: added rpcclient program (This used to be commit aa38f39d67fade4dfd7badb7a9b39c833a1dd1ca) --- source3/rpcclient/cmd_netlogon.c | 108 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 source3/rpcclient/cmd_netlogon.c (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c new file mode 100644 index 0000000000..40bb257072 --- /dev/null +++ b/source3/rpcclient/cmd_netlogon.c @@ -0,0 +1,108 @@ +/* + Unix SMB/Netbios implementation. + Version 1.9. + NT Domain Authentication SMB / MSRPC client + Copyright (C) Andrew Tridgell 1994-1997 + Copyright (C) Luke Kenneth Casson Leighton 1996-1997 + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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. +*/ + + + +#ifdef SYSLOG +#undef SYSLOG +#endif + +#include "includes.h" +#include "nterr.h" + +extern int DEBUGLEVEL; + +#define DEBUG_TESTING + +extern struct cli_state *smb_cli; + +extern FILE* out_hnd; + + +/**************************************************************************** +experimental nt login. +****************************************************************************/ +void cmd_netlogon_login_test(struct client_info *info) +{ + BOOL res = True; + + /* machine account passwords */ + pstring new_mach_pwd; + + /* initialisation */ + new_mach_pwd[0] = 0; + + DEBUG(5,("do_nt_login_test: %d\n", __LINE__)); + +#if 0 + /* check whether the user wants to change their machine password */ + res = res ? trust_account_check(info->dest_ip, info->dest_host, + info->myhostname, smb_cli->domain, + info->mach_acct, new_mach_pwd) : False; +#endif + /* open NETLOGON session. negotiate credentials */ + res = res ? do_nt_session_open(smb_cli, + info->dest_host, info->myhostname, + info->mach_acct, + smb_cli->user_name, smb_cli->domain, + info->dom.sess_key, &info->dom.clnt_cred) : False; + + /* change the machine password? */ + if (new_mach_pwd != NULL && new_mach_pwd[0] != 0) + { + res = res ? do_nt_srv_pwset(smb_cli, info->dom.lsarpc_fnum, + info->dom.sess_key, &info->dom.clnt_cred, &info->dom.rtn_cred, + new_mach_pwd, + info->dest_host, info->mach_acct, info->myhostname) : False; + } + + /* create the user-identification info */ + make_nt_login_interactive(&info->dom.ctr, + info->dom.sess_key, + smb_cli->domain, info->myhostname, + getuid(), smb_cli->user_name); + + /* do an NT login */ + res = res ? do_nt_login(smb_cli, info->dom.lsarpc_fnum, + info->dom.sess_key, &info->dom.clnt_cred, &info->dom.rtn_cred, + &info->dom.ctr, info->dest_host, info->myhostname, &info->dom.user_info3) : False; + + /* ok! you're logged in! do anything you like, then... */ + + /* do an NT logout */ + res = res ? do_nt_logoff(smb_cli, info->dom.lsarpc_fnum, + info->dom.sess_key, &info->dom.clnt_cred, &info->dom.rtn_cred, + &info->dom.ctr, info->dest_host, info->myhostname) : False; + + /* close the session */ + cli_nt_session_close(smb_cli); + + if (res) + { + DEBUG(5,("cmd_nt_login: login test succeeded\n")); + } + else + { + DEBUG(5,("cmd_nt_login: login test failed\n")); + } +} + -- cgit From c404bb775414139a4b07a73f79cf069a083acb26 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 15 Oct 1998 23:51:07 +0000 Subject: rpcclient interactive login (with trust account changing if you are root) cli_session_setup handles null sessions correctly (This used to be commit 60c0f22a4e84703467006dfe1971384a6294a9aa) --- source3/rpcclient/cmd_netlogon.c | 75 ++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 23 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 40bb257072..88510c95e7 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -43,7 +43,13 @@ experimental nt login. ****************************************************************************/ void cmd_netlogon_login_test(struct client_info *info) { + extern BOOL global_machine_password_needs_changing; + + fstring nt_user_name; + fstring password; BOOL res = True; + char *nt_password; + unsigned char trust_passwd[16]; /* machine account passwords */ pstring new_mach_pwd; @@ -51,7 +57,28 @@ void cmd_netlogon_login_test(struct client_info *info) /* initialisation */ new_mach_pwd[0] = 0; - DEBUG(5,("do_nt_login_test: %d\n", __LINE__)); + if (!next_token(NULL, nt_user_name, NULL, sizeof(nt_user_name))) + { + fstrcpy(nt_user_name, smb_cli->user_name); + if (nt_user_name[0] == 0) + { + fprintf(out_hnd,"ntlogin: must specify username with anonymous connection\n"); + return; + } + } + + if (next_token(NULL, password, NULL, sizeof(password))) + { + nt_password = password; + } + else + { + nt_password = getpass("Enter NT Login password:"); + } + + DEBUG(5,("do_nt_login_test: username %s\n", nt_user_name)); + + res = res ? trust_get_passwd(trust_passwd, info->myhostname, smb_cli->domain) : False; #if 0 /* check whether the user wants to change their machine password */ @@ -60,38 +87,40 @@ void cmd_netlogon_login_test(struct client_info *info) info->mach_acct, new_mach_pwd) : False; #endif /* open NETLOGON session. negotiate credentials */ - res = res ? do_nt_session_open(smb_cli, - info->dest_host, info->myhostname, - info->mach_acct, - smb_cli->user_name, smb_cli->domain, - info->dom.sess_key, &info->dom.clnt_cred) : False; + res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON, False) : False; + + res = res ? cli_nt_setup_creds(smb_cli, trust_passwd) : False; /* change the machine password? */ - if (new_mach_pwd != NULL && new_mach_pwd[0] != 0) + if (global_machine_password_needs_changing) { - res = res ? do_nt_srv_pwset(smb_cli, info->dom.lsarpc_fnum, - info->dom.sess_key, &info->dom.clnt_cred, &info->dom.rtn_cred, - new_mach_pwd, - info->dest_host, info->mach_acct, info->myhostname) : False; + unsigned char new_trust_passwd[16]; + generate_random_buffer(new_trust_passwd, 16, True); + res = res ? cli_nt_srv_pwset(smb_cli, new_trust_passwd) : False; + + if (res) + { + global_machine_password_needs_changing = !set_trust_account_password(new_trust_passwd); + } + + memset(new_trust_passwd, 0, 16); } - /* create the user-identification info */ - make_nt_login_interactive(&info->dom.ctr, - info->dom.sess_key, - smb_cli->domain, info->myhostname, - getuid(), smb_cli->user_name); + memset(trust_passwd, 0, 16); /* do an NT login */ - res = res ? do_nt_login(smb_cli, info->dom.lsarpc_fnum, - info->dom.sess_key, &info->dom.clnt_cred, &info->dom.rtn_cred, - &info->dom.ctr, info->dest_host, info->myhostname, &info->dom.user_info3) : False; + res = res ? cli_nt_login_interactive(smb_cli, + smb_cli->domain, nt_user_name, + getuid(), nt_password, + &info->dom.ctr, &info->dom.user_info3) : False; + + /*** clear out the password ***/ + memset(password, 0, sizeof(password)); /* ok! you're logged in! do anything you like, then... */ - + /* do an NT logout */ - res = res ? do_nt_logoff(smb_cli, info->dom.lsarpc_fnum, - info->dom.sess_key, &info->dom.clnt_cred, &info->dom.rtn_cred, - &info->dom.ctr, info->dest_host, info->myhostname) : False; + res = res ? cli_nt_logoff(smb_cli, &info->dom.ctr) : False; /* close the session */ cli_nt_session_close(smb_cli); -- cgit From 1bcbc67767e68ae12533c1ea44e2c0a567e4c93c Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 16 Oct 1998 00:07:25 +0000 Subject: trust password (This used to be commit fa86770d56fd4a3e280ee4f5685e29dee2a713fb) --- source3/rpcclient/cmd_netlogon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 88510c95e7..1be24fe130 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -78,7 +78,7 @@ void cmd_netlogon_login_test(struct client_info *info) DEBUG(5,("do_nt_login_test: username %s\n", nt_user_name)); - res = res ? trust_get_passwd(trust_passwd, info->myhostname, smb_cli->domain) : False; + res = res ? trust_get_passwd(trust_passwd, smb_cli->domain, info->myhostname) : False; #if 0 /* check whether the user wants to change their machine password */ -- cgit From d4a82ea26d5b9501f210a5c441b1ac09c256a187 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 16 Oct 1998 20:07:02 +0000 Subject: rpc client mods (ntlmssp flags) (This used to be commit 16256f86bf451535c7955b8f51a9b88fc33a8e4d) --- source3/rpcclient/cmd_netlogon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 1be24fe130..d5ca2b2b1d 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -87,7 +87,7 @@ void cmd_netlogon_login_test(struct client_info *info) info->mach_acct, new_mach_pwd) : False; #endif /* open NETLOGON session. negotiate credentials */ - res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON, False) : False; + res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON) : False; res = res ? cli_nt_setup_creds(smb_cli, trust_passwd) : False; -- cgit From 6e3af45afe237790f1d7cd94ab2b22e1ca772157 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 21 Oct 1998 16:58:34 +0000 Subject: Fixed mainly signed/unsigned issues found by SGI cc in -fullwarn mode. smbd/chgpasswd.c: Fixed (my) stupid bug where I was returning stack based variables. Doh ! smbd/trans2.c: Allows SETFILEINFO as well as QFILEINFO on directory handles. Jeremy. (This used to be commit 0b44d27d0b5cc3948a6c2d78370ccddf1a84cd80) --- source3/rpcclient/cmd_netlogon.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index d5ca2b2b1d..8e65e9a7b5 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -51,11 +51,13 @@ void cmd_netlogon_login_test(struct client_info *info) char *nt_password; unsigned char trust_passwd[16]; +#if 0 /* machine account passwords */ pstring new_mach_pwd; /* initialisation */ new_mach_pwd[0] = 0; +#endif if (!next_token(NULL, nt_user_name, NULL, sizeof(nt_user_name))) { -- cgit From a0512ce5ff104bd2d2d11b3e3167d214615a9fbf Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 22 Oct 1998 22:19:08 +0000 Subject: rpctorture command (This used to be commit b4ae65e2d0582274d67d02ea190f6d3d83b48594) --- source3/rpcclient/cmd_netlogon.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 8e65e9a7b5..2c8514b43e 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -127,13 +127,7 @@ void cmd_netlogon_login_test(struct client_info *info) /* close the session */ cli_nt_session_close(smb_cli); - if (res) - { - DEBUG(5,("cmd_nt_login: login test succeeded\n")); - } - else - { - DEBUG(5,("cmd_nt_login: login test failed\n")); - } + fprintf(out_hnd,"cmd_nt_login: login (%s) test succeeded: %s\n", + nt_user_name, BOOLSTR(res)); } -- cgit From 9c848ec329a6ce86cffb2304746590116d9292f0 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 7 Dec 1998 20:23:41 +0000 Subject: removed nt_pipe_fnum from struct cli_state. need to be able to call LsaLookupSids etc from within SamrQueryAliasMembers, for example. fnum is now a parameter to client functions. thanks to mike black for starting the ball rolling. (This used to be commit bee8f7fa6b0f7f995f71303f4e14a4aaed0c2437) --- source3/rpcclient/cmd_netlogon.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 2c8514b43e..6001327862 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -43,6 +43,7 @@ experimental nt login. ****************************************************************************/ void cmd_netlogon_login_test(struct client_info *info) { + uint16 nt_pipe_fnum; extern BOOL global_machine_password_needs_changing; fstring nt_user_name; @@ -89,16 +90,16 @@ void cmd_netlogon_login_test(struct client_info *info) info->mach_acct, new_mach_pwd) : False; #endif /* open NETLOGON session. negotiate credentials */ - res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON) : False; + res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON, &nt_pipe_fnum) : False; - res = res ? cli_nt_setup_creds(smb_cli, trust_passwd) : False; + res = res ? cli_nt_setup_creds(smb_cli, nt_pipe_fnum, trust_passwd) : False; /* change the machine password? */ if (global_machine_password_needs_changing) { unsigned char new_trust_passwd[16]; generate_random_buffer(new_trust_passwd, 16, True); - res = res ? cli_nt_srv_pwset(smb_cli, new_trust_passwd) : False; + res = res ? cli_nt_srv_pwset(smb_cli, nt_pipe_fnum, new_trust_passwd) : False; if (res) { @@ -111,7 +112,7 @@ void cmd_netlogon_login_test(struct client_info *info) memset(trust_passwd, 0, 16); /* do an NT login */ - res = res ? cli_nt_login_interactive(smb_cli, + res = res ? cli_nt_login_interactive(smb_cli, nt_pipe_fnum, smb_cli->domain, nt_user_name, getuid(), nt_password, &info->dom.ctr, &info->dom.user_info3) : False; @@ -122,10 +123,10 @@ void cmd_netlogon_login_test(struct client_info *info) /* ok! you're logged in! do anything you like, then... */ /* do an NT logout */ - res = res ? cli_nt_logoff(smb_cli, &info->dom.ctr) : False; + res = res ? cli_nt_logoff(smb_cli, nt_pipe_fnum, &info->dom.ctr) : False; /* close the session */ - cli_nt_session_close(smb_cli); + cli_nt_session_close(smb_cli, nt_pipe_fnum); fprintf(out_hnd,"cmd_nt_login: login (%s) test succeeded: %s\n", nt_user_name, BOOLSTR(res)); -- cgit From 6e88171bace32ea2f01367e86d87e1c70892084b Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 12 Mar 1999 05:47:06 +0000 Subject: new "domtrust" test command. r&d into inter-domain trust accounts. (This used to be commit 65b0abe8b7594ff6c662da86dc2e35bd83a2d13d) --- source3/rpcclient/cmd_netlogon.c | 44 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 6001327862..1ad71b7f4f 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -92,7 +92,9 @@ void cmd_netlogon_login_test(struct client_info *info) /* open NETLOGON session. negotiate credentials */ res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON, &nt_pipe_fnum) : False; - res = res ? cli_nt_setup_creds(smb_cli, nt_pipe_fnum, trust_passwd) : False; + res = res ? cli_nt_setup_creds(smb_cli, nt_pipe_fnum, + smb_cli->mach_acct, + trust_passwd, SEC_CHAN_WKSTA) : False; /* change the machine password? */ if (global_machine_password_needs_changing) @@ -132,3 +134,43 @@ void cmd_netlogon_login_test(struct client_info *info) nt_user_name, BOOLSTR(res)); } +/**************************************************************************** +experimental nt login. +****************************************************************************/ +void cmd_netlogon_domain_test(struct client_info *info) +{ + uint16 nt_pipe_fnum; + + fstring nt_trust_dom; + BOOL res = True; + unsigned char trust_passwd[16]; + fstring inter_dom_acct; + + if (!next_token(NULL, nt_trust_dom, NULL, sizeof(nt_trust_dom))) + { + fprintf(out_hnd,"domtest: must specify domain name\n"); + return; + } + + DEBUG(5,("do_nt_login_test: domain %s\n", nt_trust_dom)); + + fstrcpy(inter_dom_acct, nt_trust_dom); + fstrcat(inter_dom_acct, "$"); + + res = res ? trust_get_passwd(trust_passwd, smb_cli->domain, nt_trust_dom) : False; + + /* open NETLOGON session. negotiate credentials */ + res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON, &nt_pipe_fnum) : False; + + res = res ? cli_nt_setup_creds(smb_cli, nt_pipe_fnum, inter_dom_acct, + trust_passwd, SEC_CHAN_DOMAIN) : False; + + memset(trust_passwd, 0, 16); + + /* close the session */ + cli_nt_session_close(smb_cli, nt_pipe_fnum); + + fprintf(out_hnd,"cmd_nt_login: credentials (%s) test succeeded: %s\n", + nt_trust_dom, BOOLSTR(res)); +} + -- cgit From 373ea639e03e72bef8242133abbf678cf90ed0d9 Mon Sep 17 00:00:00 2001 From: Matthew Chapman Date: Thu, 8 Apr 1999 05:36:15 +0000 Subject: Mainly BDC-related changes. * Added SEC_CHAN_BDC * Propagate sec_chan into the various functions which change trust account passwords, so they can be used for domain control and inter-domain trusts. * Fix for endianness problem reported by Edan Idzerda . A BUFFER2 is really a "unibuf" in my terminology and we should treat it as such. * Added some more common NT structures (BIGINT, BUFHDR2, BUFFER4). * Added NET_SAM_SYNC (-> NetDatabaseSync2) RPC for account replication. Still experimental and incomplete, with a few too many NULL security descriptors lying around (must go look at Jeremy's SD code). Haven't worked out password encryption yet either. However, the XXX_INFO structures I've added to rpc_netlogon.h are quite nice as they give some insight into how these objects are stored in the SAM. (This used to be commit 7b830350eb54dc9d357c115e12ddf9a0633527ac) --- source3/rpcclient/cmd_netlogon.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 1ad71b7f4f..be5bf8596a 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -101,7 +101,7 @@ void cmd_netlogon_login_test(struct client_info *info) { unsigned char new_trust_passwd[16]; generate_random_buffer(new_trust_passwd, 16, True); - res = res ? cli_nt_srv_pwset(smb_cli, nt_pipe_fnum, new_trust_passwd) : False; + res = res ? cli_nt_srv_pwset(smb_cli, nt_pipe_fnum, new_trust_passwd, SEC_CHAN_WKSTA) : False; if (res) { @@ -174,3 +174,31 @@ void cmd_netlogon_domain_test(struct client_info *info) nt_trust_dom, BOOLSTR(res)); } +/**************************************************************************** +experimental SAM synchronisation. +****************************************************************************/ +void cmd_sam_sync(struct client_info *info) +{ + uint16 nt_pipe_fnum; + BOOL res = True; + unsigned char trust_passwd[16]; + + DEBUG(5,("Attempting SAM Synchronisation with PDC\n")); + + res = res ? trust_get_passwd(trust_passwd, smb_cli->domain, info->myhostname) : False; + + /* open NETLOGON session. negotiate credentials */ + res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON, &nt_pipe_fnum) : False; + + res = res ? cli_nt_setup_creds(smb_cli, nt_pipe_fnum, smb_cli->mach_acct, + trust_passwd, SEC_CHAN_BDC) : False; + + res = res ? cli_net_sam_sync(smb_cli, nt_pipe_fnum, 0) : False; + + memset(trust_passwd, 0, 16); + + /* close the session */ + cli_nt_session_close(smb_cli, nt_pipe_fnum); + + fprintf(out_hnd,"cmd_sam_sync: test succeeded: %s\n", BOOLSTR(res)); +} -- cgit From 99e42c0656d3e1e3b8e06437a8a9082c12df22d2 Mon Sep 17 00:00:00 2001 From: Matthew Chapman Date: Wed, 2 Jun 1999 03:19:20 +0000 Subject: Some more BDC-related fixes, mainly to the NET_SAM_SYNC RPC with respect to alignment, missing fields, etc. - it should now work correctly. There is still the problem of decoding the private data field. (This used to be commit c3c25e762fbc30d5663323f23449c913f2ce4b0e) --- source3/rpcclient/cmd_netlogon.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index be5bf8596a..def5dba297 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -179,26 +179,5 @@ experimental SAM synchronisation. ****************************************************************************/ void cmd_sam_sync(struct client_info *info) { - uint16 nt_pipe_fnum; - BOOL res = True; - unsigned char trust_passwd[16]; - - DEBUG(5,("Attempting SAM Synchronisation with PDC\n")); - - res = res ? trust_get_passwd(trust_passwd, smb_cli->domain, info->myhostname) : False; - - /* open NETLOGON session. negotiate credentials */ - res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON, &nt_pipe_fnum) : False; - - res = res ? cli_nt_setup_creds(smb_cli, nt_pipe_fnum, smb_cli->mach_acct, - trust_passwd, SEC_CHAN_BDC) : False; - - res = res ? cli_net_sam_sync(smb_cli, nt_pipe_fnum, 0) : False; - - memset(trust_passwd, 0, 16); - - /* close the session */ - cli_nt_session_close(smb_cli, nt_pipe_fnum); - - fprintf(out_hnd,"cmd_sam_sync: test succeeded: %s\n", BOOLSTR(res)); + do_sam_sync(smb_cli); } -- cgit From 6a5a4e818684a616306d2954d1a2612113b314a6 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 21 Jul 1999 00:32:09 +0000 Subject: BDC support. (This used to be commit 2331aa32ab36c3ee5fd8cfbe972e57299939e33d) --- source3/rpcclient/cmd_netlogon.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index def5dba297..1d99b99f9c 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -179,5 +179,14 @@ experimental SAM synchronisation. ****************************************************************************/ void cmd_sam_sync(struct client_info *info) { - do_sam_sync(smb_cli); + SAM_DELTA_HDR hdr_deltas[MAX_SAM_DELTAS]; + SAM_DELTA_CTR deltas[MAX_SAM_DELTAS]; + uint32 num; + + if (do_sam_sync(smb_cli, hdr_deltas, deltas, &num)) + { + display_sam_sync(out_hnd, ACTION_HEADER , hdr_deltas, deltas, num); + display_sam_sync(out_hnd, ACTION_ENUMERATE, hdr_deltas, deltas, num); + display_sam_sync(out_hnd, ACTION_FOOTER , hdr_deltas, deltas, num); + } } -- cgit From f1c2fdb2704e04b05fe3247c53162006a25e75fb Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 21 Sep 1999 21:28:27 +0000 Subject: split matthew's sync command (only currently called from smbpasswd) into a separate module (This used to be commit d99eca020a255022dbc71f3671127343d75db59e) --- source3/rpcclient/cmd_netlogon.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 1d99b99f9c..f536a0f52f 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -65,7 +65,7 @@ void cmd_netlogon_login_test(struct client_info *info) fstrcpy(nt_user_name, smb_cli->user_name); if (nt_user_name[0] == 0) { - fprintf(out_hnd,"ntlogin: must specify username with anonymous connection\n"); + report(out_hnd,"ntlogin: must specify username with anonymous connection\n"); return; } } @@ -130,7 +130,7 @@ void cmd_netlogon_login_test(struct client_info *info) /* close the session */ cli_nt_session_close(smb_cli, nt_pipe_fnum); - fprintf(out_hnd,"cmd_nt_login: login (%s) test succeeded: %s\n", + report(out_hnd,"cmd_nt_login: login (%s) test succeeded: %s\n", nt_user_name, BOOLSTR(res)); } @@ -148,7 +148,7 @@ void cmd_netlogon_domain_test(struct client_info *info) if (!next_token(NULL, nt_trust_dom, NULL, sizeof(nt_trust_dom))) { - fprintf(out_hnd,"domtest: must specify domain name\n"); + report(out_hnd,"domtest: must specify domain name\n"); return; } @@ -170,7 +170,7 @@ void cmd_netlogon_domain_test(struct client_info *info) /* close the session */ cli_nt_session_close(smb_cli, nt_pipe_fnum); - fprintf(out_hnd,"cmd_nt_login: credentials (%s) test succeeded: %s\n", + report(out_hnd,"cmd_nt_login: credentials (%s) test succeeded: %s\n", nt_trust_dom, BOOLSTR(res)); } @@ -182,8 +182,16 @@ void cmd_sam_sync(struct client_info *info) SAM_DELTA_HDR hdr_deltas[MAX_SAM_DELTAS]; SAM_DELTA_CTR deltas[MAX_SAM_DELTAS]; uint32 num; + uchar trust_passwd[16]; + extern pstring global_myname; - if (do_sam_sync(smb_cli, hdr_deltas, deltas, &num)) + if (!trust_get_passwd(trust_passwd, smb_cli->domain, global_myname)) + { + report(out_hnd, "cmd_sam_sync: no trust account password\n"); + return; + } + + if (do_sam_sync(smb_cli, trust_passwd, hdr_deltas, deltas, &num)) { display_sam_sync(out_hnd, ACTION_HEADER , hdr_deltas, deltas, num); display_sam_sync(out_hnd, ACTION_ENUMERATE, hdr_deltas, deltas, num); -- cgit From 87d92a1f1182a6b4e4dbe91d7f574c7ac8aecb21 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 19 Oct 1999 19:55:43 +0000 Subject: need status codes from cli_net_req_chal() and cli_net_auth2(). this format is what i would like _all_ these functions to be (returning status codes, not BOOL) but that's a horrendous amount of work at the moment :) (This used to be commit 02f240604241367f146b26934ad1a1b2563430de) --- source3/rpcclient/cmd_netlogon.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index f536a0f52f..ce4d727d34 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -94,8 +94,9 @@ void cmd_netlogon_login_test(struct client_info *info) res = res ? cli_nt_setup_creds(smb_cli, nt_pipe_fnum, smb_cli->mach_acct, - trust_passwd, SEC_CHAN_WKSTA) : False; + trust_passwd, SEC_CHAN_WKSTA) == 0x0 : False; +#if 0 /* change the machine password? */ if (global_machine_password_needs_changing) { @@ -110,6 +111,7 @@ void cmd_netlogon_login_test(struct client_info *info) memset(new_trust_passwd, 0, 16); } +#endif memset(trust_passwd, 0, 16); @@ -163,7 +165,7 @@ void cmd_netlogon_domain_test(struct client_info *info) res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON, &nt_pipe_fnum) : False; res = res ? cli_nt_setup_creds(smb_cli, nt_pipe_fnum, inter_dom_acct, - trust_passwd, SEC_CHAN_DOMAIN) : False; + trust_passwd, SEC_CHAN_DOMAIN) == 0x0 : False; memset(trust_passwd, 0, 16); -- cgit From 6f9105c853020fde1691a28cd707d6d3f6561b4d Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 21 Oct 1999 16:53:50 +0000 Subject: various. debug levels changed. nmbd doesn't need libsmb/clienttrust.c. samr_lookup_rids() moved to a dynamic memory structure not a static one limited to 32 RIDs. cli_pipe.c reading wasn't checking ERRmoredata when DOS error codes negotiated (this terminates MSRPC code with prejudice). (This used to be commit 8976eca2db43576c32069dcda017e8777048e007) --- source3/rpcclient/cmd_netlogon.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index ce4d727d34..c9eee7bf8a 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -36,6 +36,7 @@ extern int DEBUGLEVEL; extern struct cli_state *smb_cli; extern FILE* out_hnd; +extern pstring global_myname; /**************************************************************************** @@ -93,7 +94,7 @@ void cmd_netlogon_login_test(struct client_info *info) res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON, &nt_pipe_fnum) : False; res = res ? cli_nt_setup_creds(smb_cli, nt_pipe_fnum, - smb_cli->mach_acct, + smb_cli->mach_acct, global_myname, trust_passwd, SEC_CHAN_WKSTA) == 0x0 : False; #if 0 @@ -165,7 +166,8 @@ void cmd_netlogon_domain_test(struct client_info *info) res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON, &nt_pipe_fnum) : False; res = res ? cli_nt_setup_creds(smb_cli, nt_pipe_fnum, inter_dom_acct, - trust_passwd, SEC_CHAN_DOMAIN) == 0x0 : False; + trust_passwd, global_myname, + SEC_CHAN_DOMAIN) == 0x0 : False; memset(trust_passwd, 0, 16); @@ -193,7 +195,8 @@ void cmd_sam_sync(struct client_info *info) return; } - if (do_sam_sync(smb_cli, trust_passwd, hdr_deltas, deltas, &num)) + if (do_sam_sync(smb_cli, global_myname, + trust_passwd, hdr_deltas, deltas, &num)) { display_sam_sync(out_hnd, ACTION_HEADER , hdr_deltas, deltas, num); display_sam_sync(out_hnd, ACTION_ENUMERATE, hdr_deltas, deltas, num); -- cgit From 45b794bdde0cb906216425c8fc2af8610aa8ad3c Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 21 Oct 1999 19:02:57 +0000 Subject: the dynamic memory alloc blood-fest goes on... (This used to be commit 134b20e2a7b5ddfa4cc9bf100de5025c7b98f594) --- source3/rpcclient/cmd_netlogon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index c9eee7bf8a..3652218692 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -166,7 +166,7 @@ void cmd_netlogon_domain_test(struct client_info *info) res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON, &nt_pipe_fnum) : False; res = res ? cli_nt_setup_creds(smb_cli, nt_pipe_fnum, inter_dom_acct, - trust_passwd, global_myname, + global_myname, trust_passwd, SEC_CHAN_DOMAIN) == 0x0 : False; memset(trust_passwd, 0, 16); @@ -195,8 +195,8 @@ void cmd_sam_sync(struct client_info *info) return; } - if (do_sam_sync(smb_cli, global_myname, - trust_passwd, hdr_deltas, deltas, &num)) + if (do_sam_sync(smb_cli, trust_passwd, global_myname, + hdr_deltas, deltas, &num)) { display_sam_sync(out_hnd, ACTION_HEADER , hdr_deltas, deltas, num); display_sam_sync(out_hnd, ACTION_ENUMERATE, hdr_deltas, deltas, num); -- cgit From ea6592046f40ca21c689bff6472b4dd764850e43 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 26 Oct 1999 16:46:45 +0000 Subject: adding extra parameter back in to trust account functions (trust account name). restoring opening S-1-5-20 in sam enum users code. (This used to be commit 1be877114e2e958c59e6516dacf22d3fb5a4240f) --- source3/rpcclient/cmd_netlogon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 3652218692..5c17e5c3da 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -45,7 +45,9 @@ experimental nt login. void cmd_netlogon_login_test(struct client_info *info) { uint16 nt_pipe_fnum; +#if 0 extern BOOL global_machine_password_needs_changing; +#endif fstring nt_user_name; fstring password; @@ -195,7 +197,8 @@ void cmd_sam_sync(struct client_info *info) return; } - if (do_sam_sync(smb_cli, trust_passwd, global_myname, + if (do_sam_sync(smb_cli, trust_passwd, + smb_cli->mach_acct, global_myname, hdr_deltas, deltas, &num)) { display_sam_sync(out_hnd, ACTION_HEADER , hdr_deltas, deltas, num); -- cgit From aa12f3e0e922f42318b71c601cba08a6c96ff486 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 22 Nov 1999 19:02:39 +0000 Subject: okay :) all cmd_() functions now take int argc, char **argv :) that means that some commands need more work, as they still use next_token(), the use of which i wish to avoid. plus, i was getting fed up of the poor command-line processing in some of these commands. i'm starting to need getopt() in them, especially in samsetuser. WARNING: only cmd_samr has been modded to use getopt() so far! reg commands won't work, esp. (This used to be commit 9a1efa03c8bb86c9b7e73f102a9d48fb6a57a523) --- source3/rpcclient/cmd_netlogon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 5c17e5c3da..ed30a3122a 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -42,7 +42,7 @@ extern pstring global_myname; /**************************************************************************** experimental nt login. ****************************************************************************/ -void cmd_netlogon_login_test(struct client_info *info) +void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) { uint16 nt_pipe_fnum; #if 0 @@ -142,7 +142,7 @@ void cmd_netlogon_login_test(struct client_info *info) /**************************************************************************** experimental nt login. ****************************************************************************/ -void cmd_netlogon_domain_test(struct client_info *info) +void cmd_netlogon_domain_test(struct client_info *info, int argc, char *argv[]) { uint16 nt_pipe_fnum; @@ -183,7 +183,7 @@ void cmd_netlogon_domain_test(struct client_info *info) /**************************************************************************** experimental SAM synchronisation. ****************************************************************************/ -void cmd_sam_sync(struct client_info *info) +void cmd_sam_sync(struct client_info *info, int argc, char *argv[]) { SAM_DELTA_HDR hdr_deltas[MAX_SAM_DELTAS]; SAM_DELTA_CTR deltas[MAX_SAM_DELTAS]; -- cgit From 1ed8653112f8b26cb107e2c1e872565675ba1465 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 22 Nov 1999 19:46:26 +0000 Subject: another four next_token() removals (using getopt instead) (This used to be commit 3e76ca9b172e1a6886e714d6a36453f30ff3e771) --- source3/rpcclient/cmd_netlogon.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index ed30a3122a..c255ff5370 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -63,7 +63,10 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) new_mach_pwd[0] = 0; #endif - if (!next_token(NULL, nt_user_name, NULL, sizeof(nt_user_name))) + argc--; + argv++; + + if (argc < 1) { fstrcpy(nt_user_name, smb_cli->user_name); if (nt_user_name[0] == 0) @@ -72,10 +75,17 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) return; } } + else + { + fstrcpy(nt_user_name, argv[0]); + } + + argc--; + argv++; - if (next_token(NULL, password, NULL, sizeof(password))) + if (argc < 2) { - nt_password = password; + nt_password = argv[0]; } else { @@ -146,17 +156,19 @@ void cmd_netlogon_domain_test(struct client_info *info, int argc, char *argv[]) { uint16 nt_pipe_fnum; - fstring nt_trust_dom; + char *nt_trust_dom; BOOL res = True; unsigned char trust_passwd[16]; fstring inter_dom_acct; - if (!next_token(NULL, nt_trust_dom, NULL, sizeof(nt_trust_dom))) + if (argc < 2) { report(out_hnd,"domtest: must specify domain name\n"); return; } + nt_trust_dom = argv[1]; + DEBUG(5,("do_nt_login_test: domain %s\n", nt_trust_dom)); fstrcpy(inter_dom_acct, nt_trust_dom); -- cgit From 2803a72751cf511aa0b5e6745e1b169faa66f68a Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 24 Nov 1999 22:45:09 +0000 Subject: ok. *whew*. this is the first completed part of the restructure. verified that lsaquery, lsalookupsids work, and found some bugs in the parameters of these commands :-) soo... we now have an lsa_* api that has the same arguments as the nt Lsa* api! cool! the only significant coding difference is the introduction of a user_credentials structure, containing user, domain, pass and ntlmssp flags. (This used to be commit 57bff6fe82d777e599d535f076efb2328ba1188b) --- source3/rpcclient/cmd_netlogon.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index c255ff5370..67585ffff4 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -34,6 +34,7 @@ extern int DEBUGLEVEL; #define DEBUG_TESTING extern struct cli_state *smb_cli; +extern struct user_credentials *usr_creds; extern FILE* out_hnd; extern pstring global_myname; @@ -68,7 +69,7 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) if (argc < 1) { - fstrcpy(nt_user_name, smb_cli->user_name); + fstrcpy(nt_user_name, usr_creds->user_name); if (nt_user_name[0] == 0) { report(out_hnd,"ntlogin: must specify username with anonymous connection\n"); @@ -94,12 +95,12 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) DEBUG(5,("do_nt_login_test: username %s\n", nt_user_name)); - res = res ? trust_get_passwd(trust_passwd, smb_cli->domain, info->myhostname) : False; + res = res ? trust_get_passwd(trust_passwd, usr_creds->domain, info->myhostname) : False; #if 0 /* check whether the user wants to change their machine password */ res = res ? trust_account_check(info->dest_ip, info->dest_host, - info->myhostname, smb_cli->domain, + info->myhostname, usr_creds->domain, info->mach_acct, new_mach_pwd) : False; #endif /* open NETLOGON session. negotiate credentials */ @@ -130,7 +131,7 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) /* do an NT login */ res = res ? cli_nt_login_interactive(smb_cli, nt_pipe_fnum, - smb_cli->domain, nt_user_name, + usr_creds->domain, nt_user_name, getuid(), nt_password, &info->dom.ctr, &info->dom.user_info3) : False; @@ -174,7 +175,7 @@ void cmd_netlogon_domain_test(struct client_info *info, int argc, char *argv[]) fstrcpy(inter_dom_acct, nt_trust_dom); fstrcat(inter_dom_acct, "$"); - res = res ? trust_get_passwd(trust_passwd, smb_cli->domain, nt_trust_dom) : False; + res = res ? trust_get_passwd(trust_passwd, usr_creds->domain, nt_trust_dom) : False; /* open NETLOGON session. negotiate credentials */ res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON, &nt_pipe_fnum) : False; @@ -203,7 +204,7 @@ void cmd_sam_sync(struct client_info *info, int argc, char *argv[]) uchar trust_passwd[16]; extern pstring global_myname; - if (!trust_get_passwd(trust_passwd, smb_cli->domain, global_myname)) + if (!trust_get_passwd(trust_passwd, usr_creds->domain, global_myname)) { report(out_hnd, "cmd_sam_sync: no trust account password\n"); return; -- cgit From e302cb2b189f679bcf7efe60d5ae9fb4218c1411 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 29 Nov 1999 19:46:57 +0000 Subject: first attempt at getting \PIPE\NETLOGON working. it's pretty horrible. (This used to be commit 44dd3efa6380544e9a515e91960f9271498cefaf) --- source3/rpcclient/cmd_netlogon.c | 63 ++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 28 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 67585ffff4..3010ed5297 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -33,11 +33,9 @@ extern int DEBUGLEVEL; #define DEBUG_TESTING -extern struct cli_state *smb_cli; extern struct user_credentials *usr_creds; extern FILE* out_hnd; -extern pstring global_myname; /**************************************************************************** @@ -45,7 +43,6 @@ experimental nt login. ****************************************************************************/ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) { - uint16 nt_pipe_fnum; #if 0 extern BOOL global_machine_password_needs_changing; #endif @@ -55,6 +52,12 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) BOOL res = True; char *nt_password; unsigned char trust_passwd[16]; + fstring trust_acct; + + fstring srv_name; + fstrcpy(srv_name, "\\\\"); + fstrcat(srv_name, info->dest_host); + strupper(srv_name); #if 0 /* machine account passwords */ @@ -93,7 +96,11 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) nt_password = getpass("Enter NT Login password:"); } - DEBUG(5,("do_nt_login_test: username %s\n", nt_user_name)); + DEBUG(5,("do_nt_login_test: username %s from: %s\n", + nt_user_name, info->myhostname)); + + fstrcpy(trust_acct, info->myhostname); + fstrcat(trust_acct, "$"); res = res ? trust_get_passwd(trust_passwd, usr_creds->domain, info->myhostname) : False; @@ -103,11 +110,9 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) info->myhostname, usr_creds->domain, info->mach_acct, new_mach_pwd) : False; #endif - /* open NETLOGON session. negotiate credentials */ - res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON, &nt_pipe_fnum) : False; - res = res ? cli_nt_setup_creds(smb_cli, nt_pipe_fnum, - smb_cli->mach_acct, global_myname, + res = res ? cli_nt_setup_creds(srv_name, info->myhostname, + trust_acct, trust_passwd, SEC_CHAN_WKSTA) == 0x0 : False; #if 0 @@ -116,7 +121,7 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) { unsigned char new_trust_passwd[16]; generate_random_buffer(new_trust_passwd, 16, True); - res = res ? cli_nt_srv_pwset(smb_cli, nt_pipe_fnum, new_trust_passwd, SEC_CHAN_WKSTA) : False; + res = res ? cli_nt_srv_pwset(srv_name, info->myhostname, new_trust_passwd, SEC_CHAN_WKSTA) : False; if (res) { @@ -130,7 +135,7 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) memset(trust_passwd, 0, 16); /* do an NT login */ - res = res ? cli_nt_login_interactive(smb_cli, nt_pipe_fnum, + res = res ? cli_nt_login_interactive(srv_name, info->myhostname, usr_creds->domain, nt_user_name, getuid(), nt_password, &info->dom.ctr, &info->dom.user_info3) : False; @@ -141,10 +146,7 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) /* ok! you're logged in! do anything you like, then... */ /* do an NT logout */ - res = res ? cli_nt_logoff(smb_cli, nt_pipe_fnum, &info->dom.ctr) : False; - - /* close the session */ - cli_nt_session_close(smb_cli, nt_pipe_fnum); + res = res ? cli_nt_logoff(srv_name, info->myhostname, &info->dom.ctr) : False; report(out_hnd,"cmd_nt_login: login (%s) test succeeded: %s\n", nt_user_name, BOOLSTR(res)); @@ -155,13 +157,16 @@ experimental nt login. ****************************************************************************/ void cmd_netlogon_domain_test(struct client_info *info, int argc, char *argv[]) { - uint16 nt_pipe_fnum; - char *nt_trust_dom; BOOL res = True; unsigned char trust_passwd[16]; fstring inter_dom_acct; + fstring srv_name; + fstrcpy(srv_name, "\\\\"); + fstrcat(srv_name, info->dest_host); + strupper(srv_name); + if (argc < 2) { report(out_hnd,"domtest: must specify domain name\n"); @@ -177,18 +182,12 @@ void cmd_netlogon_domain_test(struct client_info *info, int argc, char *argv[]) res = res ? trust_get_passwd(trust_passwd, usr_creds->domain, nt_trust_dom) : False; - /* open NETLOGON session. negotiate credentials */ - res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON, &nt_pipe_fnum) : False; - - res = res ? cli_nt_setup_creds(smb_cli, nt_pipe_fnum, inter_dom_acct, - global_myname, trust_passwd, + res = res ? cli_nt_setup_creds(srv_name, info->myhostname, inter_dom_acct, + trust_passwd, SEC_CHAN_DOMAIN) == 0x0 : False; memset(trust_passwd, 0, 16); - /* close the session */ - cli_nt_session_close(smb_cli, nt_pipe_fnum); - report(out_hnd,"cmd_nt_login: credentials (%s) test succeeded: %s\n", nt_trust_dom, BOOLSTR(res)); } @@ -202,16 +201,24 @@ void cmd_sam_sync(struct client_info *info, int argc, char *argv[]) SAM_DELTA_CTR deltas[MAX_SAM_DELTAS]; uint32 num; uchar trust_passwd[16]; - extern pstring global_myname; + fstring srv_name; + fstring trust_acct; + + fstrcpy(srv_name, "\\\\"); + fstrcat(srv_name, info->dest_host); + strupper(srv_name); + + fstrcpy(trust_acct, info->myhostname); + fstrcat(trust_acct, "$"); - if (!trust_get_passwd(trust_passwd, usr_creds->domain, global_myname)) + if (!trust_get_passwd(trust_passwd, usr_creds->domain, info->myhostname)) { report(out_hnd, "cmd_sam_sync: no trust account password\n"); return; } - if (do_sam_sync(smb_cli, trust_passwd, - smb_cli->mach_acct, global_myname, + if (net_sam_sync(srv_name, info->myhostname, + trust_acct, trust_passwd, hdr_deltas, deltas, &num)) { display_sam_sync(out_hnd, ACTION_HEADER , hdr_deltas, deltas, num); -- cgit From 44334ace985b55295dfc1c93e92d46e01d39fb97 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 29 Nov 1999 21:16:12 +0000 Subject: ok. got ntlogin command working. argh, it maintains a connection to the remote machine, because i don't know what to _do_ with it!!!! argh!!! (This used to be commit 85cc680736f17e3f879895be5dac8f1427653919) --- source3/rpcclient/cmd_netlogon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 3010ed5297..4933501b7a 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -87,7 +87,7 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) argc--; argv++; - if (argc < 2) + if (argc > 0) { nt_password = argv[0]; } -- cgit From 0d44ff9a765f2e89be8b0ee99ec7c907e7c225c3 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 29 Nov 1999 21:47:14 +0000 Subject: attempting to resolve the issue that multiple servers often specified in parameters to connect to \PIPE\NETLOGON. (This used to be commit d1986ade30bdcac1f49707221a3e5a5ae597ce62) --- source3/rpcclient/cmd_netlogon.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 4933501b7a..0b0292e632 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -113,7 +113,8 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) res = res ? cli_nt_setup_creds(srv_name, info->myhostname, trust_acct, - trust_passwd, SEC_CHAN_WKSTA) == 0x0 : False; + trust_passwd, SEC_CHAN_WKSTA, + srv_name) == 0x0 : False; #if 0 /* change the machine password? */ @@ -182,9 +183,11 @@ void cmd_netlogon_domain_test(struct client_info *info, int argc, char *argv[]) res = res ? trust_get_passwd(trust_passwd, usr_creds->domain, nt_trust_dom) : False; - res = res ? cli_nt_setup_creds(srv_name, info->myhostname, inter_dom_acct, + res = res ? cli_nt_setup_creds(srv_name, + info->myhostname, inter_dom_acct, trust_passwd, - SEC_CHAN_DOMAIN) == 0x0 : False; + SEC_CHAN_DOMAIN, + srv_name) == 0x0 : False; memset(trust_passwd, 0, 16); -- cgit From 106fe88be01f7ac7d1369e97a6468dcd80c0a813 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 1 Dec 1999 16:39:51 +0000 Subject: 1) when no domain used in ntlogin test command, should use default one from previous lsaquery command. over-ridden from DOMAIN\username 2) initialisation of cli_state is a little more specific: sets use_ntlmv2 to Auto. this can always be over-ridden. 3) fixed reusage of ntlmssp_cli_flgs which was being a pain 4) added pwd_compare() function then fixed bug in cli_use where NULL domain name was making connections multiply unfruitfully 5) type-casting of mallocs and Reallocs that cause ansi-c compilers to bitch (This used to be commit 301a6efaf67ddc96e6dcfd21b45a82863ff8f39a) --- source3/rpcclient/cmd_netlogon.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 0b0292e632..89e52ed779 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -53,12 +53,20 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) char *nt_password; unsigned char trust_passwd[16]; fstring trust_acct; + fstring domain; + char *p; fstring srv_name; fstrcpy(srv_name, "\\\\"); fstrcat(srv_name, info->dest_host); strupper(srv_name); + fstrcpy(domain, usr_creds->domain); + + if (domain[0] == 0) + { + fstrcpy(domain, info->dom.level3_dom); + } #if 0 /* machine account passwords */ pstring new_mach_pwd; @@ -76,6 +84,7 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) if (nt_user_name[0] == 0) { report(out_hnd,"ntlogin: must specify username with anonymous connection\n"); + report(out_hnd,"ntlogin [[DOMAIN\\]user] [password]\n"); return; } } @@ -84,6 +93,24 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) fstrcpy(nt_user_name, argv[0]); } + p = strchr(nt_user_name, '\\'); + if (p != NULL) + { + fstrcpy(domain, nt_user_name); + p = strchr(domain, '\\'); + if (p != NULL) + { + *p = 0; + fstrcpy(nt_user_name, p+1); + } + + } + + if (domain[0] == 0) + { + report(out_hnd,"no domain specified.\n"); + } + argc--; argv++; @@ -102,7 +129,7 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) fstrcpy(trust_acct, info->myhostname); fstrcat(trust_acct, "$"); - res = res ? trust_get_passwd(trust_passwd, usr_creds->domain, info->myhostname) : False; + res = res ? trust_get_passwd(trust_passwd, domain, info->myhostname) : False; #if 0 /* check whether the user wants to change their machine password */ -- cgit From f6c5f755681a5b595b7d5f5fefc6394e9001a3e4 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 1 Dec 1999 20:18:21 +0000 Subject: damn, that took a while. nt login password was being stored incorrectly in private .mac file (oops). ntlogin test now works. (This used to be commit c98c66690683965612e9631d77c2dff91ec8a872) --- source3/rpcclient/cmd_netlogon.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 89e52ed779..910d75e1f7 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -171,10 +171,12 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) /*** clear out the password ***/ memset(password, 0, sizeof(password)); +#if 0 /* ok! you're logged in! do anything you like, then... */ /* do an NT logout */ res = res ? cli_nt_logoff(srv_name, info->myhostname, &info->dom.ctr) : False; +#endif report(out_hnd,"cmd_nt_login: login (%s) test succeeded: %s\n", nt_user_name, BOOLSTR(res)); -- cgit From 98e28ee14ce7ffe93777315891a6626ac7a0828a Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 2 Dec 1999 19:03:23 +0000 Subject: cleaning up: removing those horrible references to server list functions (cli_net_use_addlist()). needed originally because there was no get_dc_any_name() function. (This used to be commit 3a2b920ea2e6704b2574f404e1e41c7cfc0f96b2) --- source3/rpcclient/cmd_netlogon.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 910d75e1f7..9bd398643f 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -140,8 +140,7 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) res = res ? cli_nt_setup_creds(srv_name, info->myhostname, trust_acct, - trust_passwd, SEC_CHAN_WKSTA, - srv_name) == 0x0 : False; + trust_passwd, SEC_CHAN_WKSTA) == 0x0 : False; #if 0 /* change the machine password? */ @@ -215,8 +214,7 @@ void cmd_netlogon_domain_test(struct client_info *info, int argc, char *argv[]) res = res ? cli_nt_setup_creds(srv_name, info->myhostname, inter_dom_acct, trust_passwd, - SEC_CHAN_DOMAIN, - srv_name) == 0x0 : False; + SEC_CHAN_DOMAIN) == 0x0 : False; memset(trust_passwd, 0, 16); -- cgit From 4ab9d91428b66bd2fe407b0dba94f4130160b576 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 8 Dec 1999 21:43:03 +0000 Subject: ABOUT TIME!!!!!!!! damn, this one is bad. started, at least two days ago, to add an authentication mechanism to the smbd<->msrpc redirector/relay, such that sufficient unix / nt information could be transferred across the unix socket to do a become_user() on the other side of the socket. it is necessary that the msrpc daemon inherit the same unix and nt credentials as the smbd process from which it was spawned, until such time as the msrpc daemon receives an authentication request of its own, whereupon the msrpc daemon is responsible for authenticating the new credentials and doing yet another become_user() etc sequence. (This used to be commit 30c7fdd6ef10ecd35594311c1b250b95ff895489) --- source3/rpcclient/cmd_netlogon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 9bd398643f..c518fbb9f5 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -33,7 +33,7 @@ extern int DEBUGLEVEL; #define DEBUG_TESTING -extern struct user_credentials *usr_creds; +extern struct ntuser_creds *usr_creds; extern FILE* out_hnd; -- cgit From 3db52feb1f3b2c07ce0b06ad4a7099fa6efe3fc7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Dec 1999 13:27:58 +0000 Subject: first pass at updating head branch to be to be the same as the SAMBA_2_0 branch (This used to be commit 453a822a76780063dff23526c35408866d0c0154) --- source3/rpcclient/cmd_netlogon.c | 167 +++++---------------------------------- 1 file changed, 21 insertions(+), 146 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index c518fbb9f5..2c8514b43e 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -33,7 +33,7 @@ extern int DEBUGLEVEL; #define DEBUG_TESTING -extern struct ntuser_creds *usr_creds; +extern struct cli_state *smb_cli; extern FILE* out_hnd; @@ -41,32 +41,16 @@ extern FILE* out_hnd; /**************************************************************************** experimental nt login. ****************************************************************************/ -void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) +void cmd_netlogon_login_test(struct client_info *info) { -#if 0 extern BOOL global_machine_password_needs_changing; -#endif fstring nt_user_name; fstring password; BOOL res = True; char *nt_password; unsigned char trust_passwd[16]; - fstring trust_acct; - fstring domain; - char *p; - - fstring srv_name; - fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, info->dest_host); - strupper(srv_name); - - fstrcpy(domain, usr_creds->domain); - if (domain[0] == 0) - { - fstrcpy(domain, info->dom.level3_dom); - } #if 0 /* machine account passwords */ pstring new_mach_pwd; @@ -75,80 +59,46 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) new_mach_pwd[0] = 0; #endif - argc--; - argv++; - - if (argc < 1) + if (!next_token(NULL, nt_user_name, NULL, sizeof(nt_user_name))) { - fstrcpy(nt_user_name, usr_creds->user_name); + fstrcpy(nt_user_name, smb_cli->user_name); if (nt_user_name[0] == 0) { - report(out_hnd,"ntlogin: must specify username with anonymous connection\n"); - report(out_hnd,"ntlogin [[DOMAIN\\]user] [password]\n"); + fprintf(out_hnd,"ntlogin: must specify username with anonymous connection\n"); return; } } - else - { - fstrcpy(nt_user_name, argv[0]); - } - - p = strchr(nt_user_name, '\\'); - if (p != NULL) - { - fstrcpy(domain, nt_user_name); - p = strchr(domain, '\\'); - if (p != NULL) - { - *p = 0; - fstrcpy(nt_user_name, p+1); - } - - } - if (domain[0] == 0) + if (next_token(NULL, password, NULL, sizeof(password))) { - report(out_hnd,"no domain specified.\n"); - } - - argc--; - argv++; - - if (argc > 0) - { - nt_password = argv[0]; + nt_password = password; } else { nt_password = getpass("Enter NT Login password:"); } - DEBUG(5,("do_nt_login_test: username %s from: %s\n", - nt_user_name, info->myhostname)); + DEBUG(5,("do_nt_login_test: username %s\n", nt_user_name)); - fstrcpy(trust_acct, info->myhostname); - fstrcat(trust_acct, "$"); - - res = res ? trust_get_passwd(trust_passwd, domain, info->myhostname) : False; + res = res ? trust_get_passwd(trust_passwd, smb_cli->domain, info->myhostname) : False; #if 0 /* check whether the user wants to change their machine password */ res = res ? trust_account_check(info->dest_ip, info->dest_host, - info->myhostname, usr_creds->domain, + info->myhostname, smb_cli->domain, info->mach_acct, new_mach_pwd) : False; #endif + /* open NETLOGON session. negotiate credentials */ + res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON) : False; - res = res ? cli_nt_setup_creds(srv_name, info->myhostname, - trust_acct, - trust_passwd, SEC_CHAN_WKSTA) == 0x0 : False; + res = res ? cli_nt_setup_creds(smb_cli, trust_passwd) : False; -#if 0 /* change the machine password? */ if (global_machine_password_needs_changing) { unsigned char new_trust_passwd[16]; generate_random_buffer(new_trust_passwd, 16, True); - res = res ? cli_nt_srv_pwset(srv_name, info->myhostname, new_trust_passwd, SEC_CHAN_WKSTA) : False; + res = res ? cli_nt_srv_pwset(smb_cli, new_trust_passwd) : False; if (res) { @@ -157,102 +107,27 @@ void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]) memset(new_trust_passwd, 0, 16); } -#endif memset(trust_passwd, 0, 16); /* do an NT login */ - res = res ? cli_nt_login_interactive(srv_name, info->myhostname, - usr_creds->domain, nt_user_name, + res = res ? cli_nt_login_interactive(smb_cli, + smb_cli->domain, nt_user_name, getuid(), nt_password, &info->dom.ctr, &info->dom.user_info3) : False; /*** clear out the password ***/ memset(password, 0, sizeof(password)); -#if 0 /* ok! you're logged in! do anything you like, then... */ /* do an NT logout */ - res = res ? cli_nt_logoff(srv_name, info->myhostname, &info->dom.ctr) : False; -#endif + res = res ? cli_nt_logoff(smb_cli, &info->dom.ctr) : False; - report(out_hnd,"cmd_nt_login: login (%s) test succeeded: %s\n", - nt_user_name, BOOLSTR(res)); -} + /* close the session */ + cli_nt_session_close(smb_cli); -/**************************************************************************** -experimental nt login. -****************************************************************************/ -void cmd_netlogon_domain_test(struct client_info *info, int argc, char *argv[]) -{ - char *nt_trust_dom; - BOOL res = True; - unsigned char trust_passwd[16]; - fstring inter_dom_acct; - - fstring srv_name; - fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, info->dest_host); - strupper(srv_name); - - if (argc < 2) - { - report(out_hnd,"domtest: must specify domain name\n"); - return; - } - - nt_trust_dom = argv[1]; - - DEBUG(5,("do_nt_login_test: domain %s\n", nt_trust_dom)); - - fstrcpy(inter_dom_acct, nt_trust_dom); - fstrcat(inter_dom_acct, "$"); - - res = res ? trust_get_passwd(trust_passwd, usr_creds->domain, nt_trust_dom) : False; - - res = res ? cli_nt_setup_creds(srv_name, - info->myhostname, inter_dom_acct, - trust_passwd, - SEC_CHAN_DOMAIN) == 0x0 : False; - - memset(trust_passwd, 0, 16); - - report(out_hnd,"cmd_nt_login: credentials (%s) test succeeded: %s\n", - nt_trust_dom, BOOLSTR(res)); + fprintf(out_hnd,"cmd_nt_login: login (%s) test succeeded: %s\n", + nt_user_name, BOOLSTR(res)); } -/**************************************************************************** -experimental SAM synchronisation. -****************************************************************************/ -void cmd_sam_sync(struct client_info *info, int argc, char *argv[]) -{ - SAM_DELTA_HDR hdr_deltas[MAX_SAM_DELTAS]; - SAM_DELTA_CTR deltas[MAX_SAM_DELTAS]; - uint32 num; - uchar trust_passwd[16]; - fstring srv_name; - fstring trust_acct; - - fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, info->dest_host); - strupper(srv_name); - - fstrcpy(trust_acct, info->myhostname); - fstrcat(trust_acct, "$"); - - if (!trust_get_passwd(trust_passwd, usr_creds->domain, info->myhostname)) - { - report(out_hnd, "cmd_sam_sync: no trust account password\n"); - return; - } - - if (net_sam_sync(srv_name, info->myhostname, - trust_acct, trust_passwd, - hdr_deltas, deltas, &num)) - { - display_sam_sync(out_hnd, ACTION_HEADER , hdr_deltas, deltas, num); - display_sam_sync(out_hnd, ACTION_ENUMERATE, hdr_deltas, deltas, num); - display_sam_sync(out_hnd, ACTION_FOOTER , hdr_deltas, deltas, num); - } -} -- cgit From 00e3fe132476fcaed0f4b9bbe74b0a6559c39df0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 25 Apr 2000 14:06:57 +0000 Subject: moved trans2.h and nterr.h into includes.h with all our other includes (This used to be commit d7cd7c88fdabb01d9e40ae8a657737907a21ac37) --- source3/rpcclient/cmd_netlogon.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 2c8514b43e..944eda86b7 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -27,7 +27,6 @@ #endif #include "includes.h" -#include "nterr.h" extern int DEBUGLEVEL; -- cgit From 2958dfcdf87d5169fe1152806be6ad03acb04d88 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 8 May 2000 10:42:21 +0000 Subject: added secrets.tdb and changed storage of trust account password to use it (This used to be commit 88ad00b82acc4636ab57dfe710af08ea85b82ff1) --- source3/rpcclient/cmd_netlogon.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 944eda86b7..639453b4d7 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -79,7 +79,8 @@ void cmd_netlogon_login_test(struct client_info *info) DEBUG(5,("do_nt_login_test: username %s\n", nt_user_name)); - res = res ? trust_get_passwd(trust_passwd, smb_cli->domain, info->myhostname) : False; + res = res ? get_trust_account_password(smb_cli->domain, + trust_passwd, NULL) : False; #if 0 /* check whether the user wants to change their machine password */ @@ -101,7 +102,8 @@ void cmd_netlogon_login_test(struct client_info *info) if (res) { - global_machine_password_needs_changing = !set_trust_account_password(new_trust_passwd); + global_machine_password_needs_changing = !set_trust_account_password(smb_cli->domain, + new_trust_passwd); } memset(new_trust_passwd, 0, 16); -- cgit From da44845a0907bc6c9da9aabc0374b8280a85017f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 3 Jun 2000 06:22:19 +0000 Subject: moved secrets fns into secrets.c (This used to be commit f890bcf06786e7c63bf76fad2fd46d287a99a270) --- source3/rpcclient/cmd_netlogon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 639453b4d7..d00bb41b88 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -79,8 +79,8 @@ void cmd_netlogon_login_test(struct client_info *info) DEBUG(5,("do_nt_login_test: username %s\n", nt_user_name)); - res = res ? get_trust_account_password(smb_cli->domain, - trust_passwd, NULL) : False; + res = res ? secrets_fetch_trust_account_password(smb_cli->domain, + trust_passwd, NULL) : False; #if 0 /* check whether the user wants to change their machine password */ -- cgit From 3396a1d97850bb705ead64857c22b60a855ccd5a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 23 Jun 2000 00:09:21 +0000 Subject: just enough to get rpcclient to compile. Look for #if 0 blocks around a few unimplemented functions. Also had to add cli_reg.c to Makefile.in --jerry (This used to be commit 426c43fb5167b042682c22e67871e5ebadb4b769) --- source3/rpcclient/cmd_netlogon.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index d00bb41b88..93be5f5652 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -93,6 +93,7 @@ void cmd_netlogon_login_test(struct client_info *info) res = res ? cli_nt_setup_creds(smb_cli, trust_passwd) : False; +#if 0 /* change the machine password? */ if (global_machine_password_needs_changing) { @@ -108,6 +109,7 @@ void cmd_netlogon_login_test(struct client_info *info) memset(new_trust_passwd, 0, 16); } +#endif memset(trust_passwd, 0, 16); -- cgit From 40ff4007c7ea1c1512592c8a0cb3833be2fe97d1 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 24 May 2001 00:20:32 +0000 Subject: Added stubs for SRVSVC and NETLOGON rpcclient commands. (This used to be commit 3343c9f0d67d98687e5933e1a73c0ff487279160) --- source3/rpcclient/cmd_netlogon.c | 124 ++++----------------------------------- 1 file changed, 10 insertions(+), 114 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 93be5f5652..697cf26be1 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -1,10 +1,10 @@ /* Unix SMB/Netbios implementation. - Version 1.9. - NT Domain Authentication SMB / MSRPC client - Copyright (C) Andrew Tridgell 1994-1997 - Copyright (C) Luke Kenneth Casson Leighton 1996-1997 - + Version 2.2 + RPC pipe client + + Copyright (C) Tim Potter 2000 + 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 @@ -20,117 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#ifdef SYSLOG -#undef SYSLOG -#endif - #include "includes.h" extern int DEBUGLEVEL; -#define DEBUG_TESTING - -extern struct cli_state *smb_cli; - -extern FILE* out_hnd; - - -/**************************************************************************** -experimental nt login. -****************************************************************************/ -void cmd_netlogon_login_test(struct client_info *info) -{ - extern BOOL global_machine_password_needs_changing; - - fstring nt_user_name; - fstring password; - BOOL res = True; - char *nt_password; - unsigned char trust_passwd[16]; - -#if 0 - /* machine account passwords */ - pstring new_mach_pwd; - - /* initialisation */ - new_mach_pwd[0] = 0; -#endif - - if (!next_token(NULL, nt_user_name, NULL, sizeof(nt_user_name))) - { - fstrcpy(nt_user_name, smb_cli->user_name); - if (nt_user_name[0] == 0) - { - fprintf(out_hnd,"ntlogin: must specify username with anonymous connection\n"); - return; - } - } - - if (next_token(NULL, password, NULL, sizeof(password))) - { - nt_password = password; - } - else - { - nt_password = getpass("Enter NT Login password:"); - } - - DEBUG(5,("do_nt_login_test: username %s\n", nt_user_name)); - - res = res ? secrets_fetch_trust_account_password(smb_cli->domain, - trust_passwd, NULL) : False; - -#if 0 - /* check whether the user wants to change their machine password */ - res = res ? trust_account_check(info->dest_ip, info->dest_host, - info->myhostname, smb_cli->domain, - info->mach_acct, new_mach_pwd) : False; -#endif - /* open NETLOGON session. negotiate credentials */ - res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON) : False; - - res = res ? cli_nt_setup_creds(smb_cli, trust_passwd) : False; - -#if 0 - /* change the machine password? */ - if (global_machine_password_needs_changing) - { - unsigned char new_trust_passwd[16]; - generate_random_buffer(new_trust_passwd, 16, True); - res = res ? cli_nt_srv_pwset(smb_cli, new_trust_passwd) : False; - - if (res) - { - global_machine_password_needs_changing = !set_trust_account_password(smb_cli->domain, - new_trust_passwd); - } - - memset(new_trust_passwd, 0, 16); - } -#endif - - memset(trust_passwd, 0, 16); - - /* do an NT login */ - res = res ? cli_nt_login_interactive(smb_cli, - smb_cli->domain, nt_user_name, - getuid(), nt_password, - &info->dom.ctr, &info->dom.user_info3) : False; - - /*** clear out the password ***/ - memset(password, 0, sizeof(password)); - - /* ok! you're logged in! do anything you like, then... */ - - /* do an NT logout */ - res = res ? cli_nt_logoff(smb_cli, &info->dom.ctr) : False; - - /* close the session */ - cli_nt_session_close(smb_cli); - - fprintf(out_hnd,"cmd_nt_login: login (%s) test succeeded: %s\n", - nt_user_name, BOOLSTR(res)); -} +/* List of commands exported by this module */ +struct cmd_set netlogon_commands[] = { + { "NETLOGON", NULL, "" }, + { NULL, NULL, NULL } +}; -- cgit From 43bc613e74f06d4e6169c359149db72c9f925039 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 24 May 2001 08:10:50 +0000 Subject: Added srvinfo and partial logonctrl and logonctrl2 commands. (This used to be commit c93718daa1375269e4e0ef52016271b7a607e292) --- source3/rpcclient/cmd_netlogon.c | 76 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 697cf26be1..184771a7ad 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -24,9 +24,83 @@ extern int DEBUGLEVEL; +static uint32 cmd_netlogon_logon_ctrl2(struct cli_state *cli, int argc, + char **argv) +{ + uint32 query_level = 1; + TALLOC_CTX *mem_ctx; + uint32 result = NT_STATUS_UNSUCCESSFUL; + + if (argc > 1) { + printf("Usage: %s\n", argv[0]); + return 0; + } + + if (!(mem_ctx = talloc_init())) { + DEBUG(0,("cmd_srvsvc_srv_query_info: talloc_init failed\n")); + goto done; + } + + /* Initialise RPC connection */ + + if (!cli_nt_session_open (cli, PIPE_NETLOGON)) { + DEBUG(0, ("Could not initialize srvsvc pipe!\n")); + goto done; + } + + if ((result = cli_netlogon_logon_ctrl2(cli, mem_ctx, query_level)) + != NT_STATUS_NOPROBLEMO) { + goto done; + } + + /* Display results */ + + done: + return result; +} + +static uint32 cmd_netlogon_logon_ctrl(struct cli_state *cli, int argc, + char **argv) +{ + uint32 query_level = 1; + TALLOC_CTX *mem_ctx; + uint32 result = NT_STATUS_UNSUCCESSFUL; + + if (argc > 1) { + printf("Usage: %s\n", argv[0]); + return 0; + } + + if (!(mem_ctx = talloc_init())) { + DEBUG(0,("cmd_srvsvc_srv_query_info: talloc_init failed\n")); + goto done; + } + + /* Initialise RPC connection */ + + if (!cli_nt_session_open (cli, PIPE_NETLOGON)) { + DEBUG(0, ("Could not initialize srvsvc pipe!\n")); + goto done; + } + +#if 0 + if ((result = cli_netlogon_logon_ctrl(cli, mem_ctx, query_level)) + != NT_STATUS_NOPROBLEMO) { + goto done; + } +#endif + + /* Display results */ + + done: + return result; +} + /* List of commands exported by this module */ struct cmd_set netlogon_commands[] = { - { "NETLOGON", NULL, "" }, + { "NETLOGON", NULL, "" }, + { "logonctrl2", cmd_netlogon_logon_ctrl2, "Logon Control 2" }, + { "logonctrl", cmd_netlogon_logon_ctrl, "Logon Control" }, { NULL, NULL, NULL } }; -- cgit From 6ad1fcc2799d9cccbe22c271650118e065e5be3c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 23 Jun 2001 14:58:38 +0000 Subject: fix compiler warnings (This used to be commit 1959864490e79756257ba10431b188de78b8c8a7) --- source3/rpcclient/cmd_netlogon.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 184771a7ad..93f6f1c395 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -62,7 +62,9 @@ static uint32 cmd_netlogon_logon_ctrl2(struct cli_state *cli, int argc, static uint32 cmd_netlogon_logon_ctrl(struct cli_state *cli, int argc, char **argv) { +#if 0 uint32 query_level = 1; +#endif TALLOC_CTX *mem_ctx; uint32 result = NT_STATUS_UNSUCCESSFUL; -- cgit From 8db78af9702dab2e89f1f7adf56996a20a8cb2f4 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 20 Jul 2001 04:38:58 +0000 Subject: Started adding some help/usage info for rpcclient commands. (This used to be commit 37052a1bcc5cd049918c3d5ac4c41c3a669290af) --- source3/rpcclient/cmd_netlogon.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 93f6f1c395..549e21e25e 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -101,8 +101,11 @@ static uint32 cmd_netlogon_logon_ctrl(struct cli_state *cli, int argc, /* List of commands exported by this module */ struct cmd_set netlogon_commands[] = { - { "NETLOGON", NULL, "" }, - { "logonctrl2", cmd_netlogon_logon_ctrl2, "Logon Control 2" }, - { "logonctrl", cmd_netlogon_logon_ctrl, "Logon Control" }, - { NULL, NULL, NULL } + + { "NETLOGON" }, + + { "logonctrl2", cmd_netlogon_logon_ctrl2, "Logon Control 2", "" }, + { "logonctrl", cmd_netlogon_logon_ctrl, "Logon Control", "" }, + + { NULL } }; -- cgit From b031af348c7dcc8c74bf49945211c466b8eca079 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 27 Aug 2001 19:46:22 +0000 Subject: converted another bunch of stuff to NTSTATUS (This used to be commit 1d36250e338ae0ff9fbbf86019809205dd97d05e) --- source3/rpcclient/cmd_netlogon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 549e21e25e..410fd7fb0a 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -49,7 +49,7 @@ static uint32 cmd_netlogon_logon_ctrl2(struct cli_state *cli, int argc, } if ((result = cli_netlogon_logon_ctrl2(cli, mem_ctx, query_level)) - != NT_STATUS_NOPROBLEMO) { + != NT_STATUS_OK) { goto done; } @@ -87,7 +87,7 @@ static uint32 cmd_netlogon_logon_ctrl(struct cli_state *cli, int argc, #if 0 if ((result = cli_netlogon_logon_ctrl(cli, mem_ctx, query_level)) - != NT_STATUS_NOPROBLEMO) { + != NT_STATUS_OK) { goto done; } #endif -- cgit From d5c9172adadb83283e437578be7bad4368ad9f20 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 28 Aug 2001 06:43:43 +0000 Subject: Merge of sam sync code from TNG. Reverse-engineered the sam replication protocol from staring at hex dumps for a while. It's pretty similar to the sam sync protocol with a couple of different delta header types. I wasn't able to figure out the format of the privilege stuff - needs more time and a whiteboard. (-: The impressive bit is that the sam sync stuff from tng basically just worked thanks mainly to Luke Leighton's efforts in this area. (This used to be commit 3a60cb44f22d5f3f8c78a56ed8f5ea4794cd7ab3) --- source3/rpcclient/cmd_netlogon.c | 220 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 217 insertions(+), 3 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 410fd7fb0a..1b49387558 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -81,7 +81,7 @@ static uint32 cmd_netlogon_logon_ctrl(struct cli_state *cli, int argc, /* Initialise RPC connection */ if (!cli_nt_session_open (cli, PIPE_NETLOGON)) { - DEBUG(0, ("Could not initialize srvsvc pipe!\n")); + DEBUG(0, ("Could not initialize netlogon pipe!\n")); goto done; } @@ -98,14 +98,228 @@ static uint32 cmd_netlogon_logon_ctrl(struct cli_state *cli, int argc, return result; } +/* Display sam synchronisation information */ + +static void display_sam_sync(uint32 num_deltas, SAM_DELTA_HDR *hdr_deltas, + SAM_DELTA_CTR *deltas) +{ + fstring name; + uint32 i, j; + + for (i = 0; i < num_deltas; i++) { + switch (hdr_deltas[i].type) { + case SAM_DELTA_DOMAIN_INFO: + unistr2_to_ascii(name, + &deltas[i].domain_info.uni_dom_name, + sizeof(name) - 1); + DEBUG(0, ("Domain: %s\n", name)); + break; + case SAM_DELTA_GROUP_INFO: + unistr2_to_ascii(name, + &deltas[i].group_info.uni_grp_name, + sizeof(name) - 1); + DEBUG(0, ("Group: %s\n", name)); + break; + case SAM_DELTA_ACCOUNT_INFO: + unistr2_to_ascii(name, + &deltas[i].account_info.uni_acct_name, + sizeof(name) - 1); + DEBUG(0, ("Account: %s\n", name)); + break; + case SAM_DELTA_ALIAS_INFO: + unistr2_to_ascii(name, + &deltas[i].alias_info.uni_als_name, + sizeof(name) - 1); + DEBUG(0, ("Alias: %s\n", name)); + break; + case SAM_DELTA_ALIAS_MEM: { + SAM_ALIAS_MEM_INFO *alias = &deltas[i].als_mem_info; + + for (j = 0; j < alias->num_members; j++) { + fstring sid_str; + + sid_to_string(sid_str, &alias->sids[j].sid); + + DEBUG(0, ("%s\n", sid_str)); + } + break; + } + case SAM_DELTA_GROUP_MEM: { + SAM_GROUP_MEM_INFO *group = &deltas[i].grp_mem_info; + + for (j = 0; j < group->num_members; j++) + DEBUG(0, ("rid 0x%x, attrib 0x%08x\n", + group->rids[j], group->attribs[j])); + break; + } + case SAM_DELTA_SAM_STAMP: { + SAM_DELTA_STAMP *stamp = &deltas[i].stamp; + + DEBUG(0, ("sam sequence update: 0x%04x\n", + stamp->seqnum)); + break; + } + default: + DEBUG(0, ("unknown delta type 0x%02x\n", + hdr_deltas[i].type)); + break; + } + } +} + +/* Perform sam synchronisation */ + +static uint32 cmd_netlogon_sam_sync(struct cli_state *cli, int argc, + char **argv) +{ + uint32 result = NT_STATUS_UNSUCCESSFUL; + unsigned char trust_passwd[16]; + TALLOC_CTX *mem_ctx; + uint32 database_id = 0, num_deltas; + SAM_DELTA_HDR *hdr_deltas; + SAM_DELTA_CTR *deltas; + + if (argc > 2) { + printf("Usage: %s [database_id]\n", argv[0]); + return 0; + } + + if (argc == 2) + database_id = atoi(argv[1]); + + if (!secrets_init()) { + DEBUG(0, ("Unable to initialise secrets database\n")); + return result; + } + + if (!(mem_ctx = talloc_init())) { + DEBUG(0,("talloc_init failed\n")); + return result; + } + + /* Initialise RPC connection */ + + if (!cli_nt_session_open (cli, PIPE_NETLOGON)) { + DEBUG(0, ("Could not initialize netlogon pipe!\n")); + goto done; + } + + /* Initialise session credentials */ + + if (!secrets_fetch_trust_account_password(lp_workgroup(), trust_passwd, + NULL)) { + DEBUG(0, ("could not fetch trust account password\n")); + goto done; + } + + if (!cli_nt_setup_creds(cli, trust_passwd)) { + DEBUG(0, ("Error initialising session creds\n")); + goto done; + } + + /* Synchronise sam database */ + + if ((result = cli_netlogon_sam_sync(cli, mem_ctx, database_id, + &num_deltas, &hdr_deltas, &deltas)) + != NT_STATUS_OK) { + goto done; + } + + /* Display results */ + + display_sam_sync(num_deltas, hdr_deltas, deltas); + + done: + cli_nt_session_close(cli); + talloc_destroy(mem_ctx); + + return result; +} + +/* Perform sam delta synchronisation */ + +static uint32 cmd_netlogon_sam_deltas(struct cli_state *cli, int argc, + char **argv) +{ + uint32 result = NT_STATUS_UNSUCCESSFUL; + unsigned char trust_passwd[16]; + TALLOC_CTX *mem_ctx = NULL; + uint32 database_id, num_deltas, tmp; + SAM_DELTA_HDR *hdr_deltas; + SAM_DELTA_CTR *deltas; + UINT64_S seqnum; + + if (argc != 3) { + printf("Usage: %s database_id seqnum\n", argv[0]); + return 0; + } + + database_id = atoi(argv[1]); + tmp = atoi(argv[2]); + + seqnum.low = tmp & 0xffff; + seqnum.high = 0; + + if (!secrets_init()) { + DEBUG(0, ("Unable to initialise secrets database\n")); + goto done; + } + + if (!(mem_ctx = talloc_init())) { + DEBUG(0,("talloc_init failed\n")); + goto done; + } + + /* Initialise RPC connection */ + + if (!cli_nt_session_open (cli, PIPE_NETLOGON)) { + DEBUG(0, ("Could not initialize netlogon pipe!\n")); + goto done; + } + + /* Initialise session credentials */ + + if (!secrets_fetch_trust_account_password(lp_workgroup(), trust_passwd, + NULL)) { + DEBUG(0, ("could not fetch trust account password\n")); + goto done; + } + + if (!cli_nt_setup_creds(cli, trust_passwd)) { + DEBUG(0, ("Error initialising session creds\n")); + goto done; + } + + /* Synchronise sam database */ + + if ((result = cli_netlogon_sam_deltas(cli, mem_ctx, database_id, + seqnum, &num_deltas, + &hdr_deltas, &deltas)) + != NT_STATUS_OK) { + goto done; + } + + /* Display results */ + + display_sam_sync(num_deltas, hdr_deltas, deltas); + + done: + cli_nt_session_close(cli); + talloc_destroy(mem_ctx); + + return result; +} + /* List of commands exported by this module */ struct cmd_set netlogon_commands[] = { { "NETLOGON" }, - { "logonctrl2", cmd_netlogon_logon_ctrl2, "Logon Control 2", "" }, - { "logonctrl", cmd_netlogon_logon_ctrl, "Logon Control", "" }, + { "logonctrl2", cmd_netlogon_logon_ctrl2, "Logon Control 2", "" }, + { "logonctrl", cmd_netlogon_logon_ctrl, "Logon Control", "" }, + { "samsync", cmd_netlogon_sam_sync, "Sam Synchronisation", "" }, + { "samdeltas", cmd_netlogon_sam_deltas, "Query Sam Deltas", "" }, { NULL } }; -- cgit From c76dd1404041f42d3a398339cefbeb60f22d2910 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 4 Sep 2001 10:57:29 +0000 Subject: it now all compiles - so try enabling it by default and see what explodes on the build farm (This used to be commit 5bb7e4f0f65edf1db20245f403cbe81833134240) --- source3/rpcclient/cmd_netlogon.c | 46 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 1b49387558..41bf8883a2 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -24,16 +24,16 @@ extern int DEBUGLEVEL; -static uint32 cmd_netlogon_logon_ctrl2(struct cli_state *cli, int argc, +static NTSTATUS cmd_netlogon_logon_ctrl2(struct cli_state *cli, int argc, char **argv) { uint32 query_level = 1; TALLOC_CTX *mem_ctx; - uint32 result = NT_STATUS_UNSUCCESSFUL; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; if (argc > 1) { printf("Usage: %s\n", argv[0]); - return 0; + return NT_STATUS_OK; } if (!(mem_ctx = talloc_init())) { @@ -48,8 +48,8 @@ static uint32 cmd_netlogon_logon_ctrl2(struct cli_state *cli, int argc, goto done; } - if ((result = cli_netlogon_logon_ctrl2(cli, mem_ctx, query_level)) - != NT_STATUS_OK) { + result = cli_netlogon_logon_ctrl2(cli, mem_ctx, query_level); + if (!NT_STATUS_IS_OK(result)) { goto done; } @@ -59,18 +59,18 @@ static uint32 cmd_netlogon_logon_ctrl2(struct cli_state *cli, int argc, return result; } -static uint32 cmd_netlogon_logon_ctrl(struct cli_state *cli, int argc, +static NTSTATUS cmd_netlogon_logon_ctrl(struct cli_state *cli, int argc, char **argv) { #if 0 uint32 query_level = 1; #endif TALLOC_CTX *mem_ctx; - uint32 result = NT_STATUS_UNSUCCESSFUL; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; if (argc > 1) { printf("Usage: %s\n", argv[0]); - return 0; + return NT_STATUS_OK; } if (!(mem_ctx = talloc_init())) { @@ -86,8 +86,8 @@ static uint32 cmd_netlogon_logon_ctrl(struct cli_state *cli, int argc, } #if 0 - if ((result = cli_netlogon_logon_ctrl(cli, mem_ctx, query_level)) - != NT_STATUS_OK) { + result = cli_netlogon_logon_ctrl(cli, mem_ctx, query_level); + if (!NT_STATUS_IS_OK(result)) { goto done; } #endif @@ -169,10 +169,10 @@ static void display_sam_sync(uint32 num_deltas, SAM_DELTA_HDR *hdr_deltas, /* Perform sam synchronisation */ -static uint32 cmd_netlogon_sam_sync(struct cli_state *cli, int argc, +static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, int argc, char **argv) { - uint32 result = NT_STATUS_UNSUCCESSFUL; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; unsigned char trust_passwd[16]; TALLOC_CTX *mem_ctx; uint32 database_id = 0, num_deltas; @@ -181,7 +181,7 @@ static uint32 cmd_netlogon_sam_sync(struct cli_state *cli, int argc, if (argc > 2) { printf("Usage: %s [database_id]\n", argv[0]); - return 0; + return NT_STATUS_OK; } if (argc == 2) @@ -219,9 +219,9 @@ static uint32 cmd_netlogon_sam_sync(struct cli_state *cli, int argc, /* Synchronise sam database */ - if ((result = cli_netlogon_sam_sync(cli, mem_ctx, database_id, - &num_deltas, &hdr_deltas, &deltas)) - != NT_STATUS_OK) { + result = cli_netlogon_sam_sync(cli, mem_ctx, database_id, + &num_deltas, &hdr_deltas, &deltas); + if (!NT_STATUS_IS_OK(result)) { goto done; } @@ -238,10 +238,10 @@ static uint32 cmd_netlogon_sam_sync(struct cli_state *cli, int argc, /* Perform sam delta synchronisation */ -static uint32 cmd_netlogon_sam_deltas(struct cli_state *cli, int argc, +static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, int argc, char **argv) { - uint32 result = NT_STATUS_UNSUCCESSFUL; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; unsigned char trust_passwd[16]; TALLOC_CTX *mem_ctx = NULL; uint32 database_id, num_deltas, tmp; @@ -251,7 +251,7 @@ static uint32 cmd_netlogon_sam_deltas(struct cli_state *cli, int argc, if (argc != 3) { printf("Usage: %s database_id seqnum\n", argv[0]); - return 0; + return NT_STATUS_OK; } database_id = atoi(argv[1]); @@ -292,10 +292,10 @@ static uint32 cmd_netlogon_sam_deltas(struct cli_state *cli, int argc, /* Synchronise sam database */ - if ((result = cli_netlogon_sam_deltas(cli, mem_ctx, database_id, - seqnum, &num_deltas, - &hdr_deltas, &deltas)) - != NT_STATUS_OK) { + result = cli_netlogon_sam_deltas(cli, mem_ctx, database_id, + seqnum, &num_deltas, + &hdr_deltas, &deltas); + if (!NT_STATUS_IS_OK(result)) { goto done; } -- cgit From 15a6649c01195f2b385fbfd7e54279c1acc3a878 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 18 Sep 2001 02:49:35 +0000 Subject: Converted cli_net_auth2() and cli_nt_setup_creds() to return NTSTATUS. (This used to be commit e0bdcbc5994345fdc76f7590dba7bce5f0127d58) --- source3/rpcclient/cmd_netlogon.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 41bf8883a2..3adae373ff 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -212,7 +212,9 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, int argc, goto done; } - if (!cli_nt_setup_creds(cli, trust_passwd)) { + result = cli_nt_setup_creds(cli, trust_passwd); + + if (!NT_STATUS_IS_OK(result)) { DEBUG(0, ("Error initialising session creds\n")); goto done; } @@ -285,7 +287,9 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, int argc, goto done; } - if (!cli_nt_setup_creds(cli, trust_passwd)) { + result = cli_nt_setup_creds(cli, trust_passwd); + + if (!NT_STATUS_IS_OK(result)) { DEBUG(0, ("Error initialising session creds\n")); goto done; } -- cgit From dc1fc3ee8ec2199bc73bb5d7ec711c6800f61d65 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 2 Oct 2001 04:29:50 +0000 Subject: Removed 'extern int DEBUGLEVEL' as it is now in the smb.h header. (This used to be commit 2d0922b0eabfdc0aaf1d0797482fef47ed7fde8e) --- source3/rpcclient/cmd_netlogon.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 3adae373ff..3d73fc1fde 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -22,8 +22,6 @@ #include "includes.h" -extern int DEBUGLEVEL; - static NTSTATUS cmd_netlogon_logon_ctrl2(struct cli_state *cli, int argc, char **argv) { -- cgit From 439c7e0ca2ceb866cac4f0fbed65e157aa12482d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 12 Oct 2001 05:56:23 +0000 Subject: Some old stuff hanging around since the CIFS conference. Big cleanup of rpcclient code. Refactored cmd_* functions to move common mem_ctx and pipe opening stuff up one level. Moved rpcclient.h into rpcclient directory and out of includes/smb.h (This used to be commit a40facba9651f9fb1dcc9e143f92ca298a324312) --- source3/rpcclient/cmd_netlogon.c | 142 ++++++++++++--------------------------- 1 file changed, 44 insertions(+), 98 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 3d73fc1fde..a935900faa 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -21,35 +21,24 @@ */ #include "includes.h" +#include "rpcclient.h" -static NTSTATUS cmd_netlogon_logon_ctrl2(struct cli_state *cli, int argc, - char **argv) +static NTSTATUS cmd_netlogon_logon_ctrl2(struct cli_state *cli, + TALLOC_CTX *mem_ctx, int argc, + char **argv) { uint32 query_level = 1; - TALLOC_CTX *mem_ctx; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; if (argc > 1) { - printf("Usage: %s\n", argv[0]); + fprintf(stderr, "Usage: %s\n", argv[0]); return NT_STATUS_OK; } - if (!(mem_ctx = talloc_init())) { - DEBUG(0,("cmd_srvsvc_srv_query_info: talloc_init failed\n")); - goto done; - } - - /* Initialise RPC connection */ - - if (!cli_nt_session_open (cli, PIPE_NETLOGON)) { - DEBUG(0, ("Could not initialize srvsvc pipe!\n")); - goto done; - } - result = cli_netlogon_logon_ctrl2(cli, mem_ctx, query_level); - if (!NT_STATUS_IS_OK(result)) { + + if (!NT_STATUS_IS_OK(result)) goto done; - } /* Display results */ @@ -57,32 +46,20 @@ static NTSTATUS cmd_netlogon_logon_ctrl2(struct cli_state *cli, int argc, return result; } -static NTSTATUS cmd_netlogon_logon_ctrl(struct cli_state *cli, int argc, - char **argv) +static NTSTATUS cmd_netlogon_logon_ctrl(struct cli_state *cli, + TALLOC_CTX *mem_ctx, int argc, + char **argv) { #if 0 uint32 query_level = 1; #endif - TALLOC_CTX *mem_ctx; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; if (argc > 1) { - printf("Usage: %s\n", argv[0]); + fprintf(stderr, "Usage: %s\n", argv[0]); return NT_STATUS_OK; } - if (!(mem_ctx = talloc_init())) { - DEBUG(0,("cmd_srvsvc_srv_query_info: talloc_init failed\n")); - goto done; - } - - /* Initialise RPC connection */ - - if (!cli_nt_session_open (cli, PIPE_NETLOGON)) { - DEBUG(0, ("Could not initialize netlogon pipe!\n")); - goto done; - } - #if 0 result = cli_netlogon_logon_ctrl(cli, mem_ctx, query_level); if (!NT_STATUS_IS_OK(result)) { @@ -92,7 +69,6 @@ static NTSTATUS cmd_netlogon_logon_ctrl(struct cli_state *cli, int argc, /* Display results */ - done: return result; } @@ -110,25 +86,25 @@ static void display_sam_sync(uint32 num_deltas, SAM_DELTA_HDR *hdr_deltas, unistr2_to_ascii(name, &deltas[i].domain_info.uni_dom_name, sizeof(name) - 1); - DEBUG(0, ("Domain: %s\n", name)); + printf("Domain: %s\n", name); break; case SAM_DELTA_GROUP_INFO: unistr2_to_ascii(name, &deltas[i].group_info.uni_grp_name, sizeof(name) - 1); - DEBUG(0, ("Group: %s\n", name)); + printf("Group: %s\n", name); break; case SAM_DELTA_ACCOUNT_INFO: unistr2_to_ascii(name, &deltas[i].account_info.uni_acct_name, sizeof(name) - 1); - DEBUG(0, ("Account: %s\n", name)); + printf("Account: %s\n", name); break; case SAM_DELTA_ALIAS_INFO: unistr2_to_ascii(name, &deltas[i].alias_info.uni_als_name, sizeof(name) - 1); - DEBUG(0, ("Alias: %s\n", name)); + printf("Alias: %s\n", name); break; case SAM_DELTA_ALIAS_MEM: { SAM_ALIAS_MEM_INFO *alias = &deltas[i].als_mem_info; @@ -138,7 +114,7 @@ static void display_sam_sync(uint32 num_deltas, SAM_DELTA_HDR *hdr_deltas, sid_to_string(sid_str, &alias->sids[j].sid); - DEBUG(0, ("%s\n", sid_str)); + printf("%s\n", sid_str); } break; } @@ -146,20 +122,20 @@ static void display_sam_sync(uint32 num_deltas, SAM_DELTA_HDR *hdr_deltas, SAM_GROUP_MEM_INFO *group = &deltas[i].grp_mem_info; for (j = 0; j < group->num_members; j++) - DEBUG(0, ("rid 0x%x, attrib 0x%08x\n", - group->rids[j], group->attribs[j])); + printf("rid 0x%x, attrib 0x%08x\n", + group->rids[j], group->attribs[j]); break; } case SAM_DELTA_SAM_STAMP: { SAM_DELTA_STAMP *stamp = &deltas[i].stamp; - DEBUG(0, ("sam sequence update: 0x%04x\n", - stamp->seqnum)); + printf("sam sequence update: 0x%04x\n", + stamp->seqnum); break; } default: - DEBUG(0, ("unknown delta type 0x%02x\n", - hdr_deltas[i].type)); + printf("unknown delta type 0x%02x\n", + hdr_deltas[i].type); break; } } @@ -167,18 +143,18 @@ static void display_sam_sync(uint32 num_deltas, SAM_DELTA_HDR *hdr_deltas, /* Perform sam synchronisation */ -static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, int argc, - char **argv) +static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, + TALLOC_CTX *mem_ctx, int argc, + char **argv) { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; unsigned char trust_passwd[16]; - TALLOC_CTX *mem_ctx; uint32 database_id = 0, num_deltas; SAM_DELTA_HDR *hdr_deltas; SAM_DELTA_CTR *deltas; if (argc > 2) { - printf("Usage: %s [database_id]\n", argv[0]); + fprintf(stderr, "Usage: %s [database_id]\n", argv[0]); return NT_STATUS_OK; } @@ -186,34 +162,22 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, int argc, database_id = atoi(argv[1]); if (!secrets_init()) { - DEBUG(0, ("Unable to initialise secrets database\n")); + fprintf(stderr, "Unable to initialise secrets database\n"); return result; } - if (!(mem_ctx = talloc_init())) { - DEBUG(0,("talloc_init failed\n")); - return result; - } - - /* Initialise RPC connection */ - - if (!cli_nt_session_open (cli, PIPE_NETLOGON)) { - DEBUG(0, ("Could not initialize netlogon pipe!\n")); - goto done; - } - /* Initialise session credentials */ if (!secrets_fetch_trust_account_password(lp_workgroup(), trust_passwd, NULL)) { - DEBUG(0, ("could not fetch trust account password\n")); + 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)) { - DEBUG(0, ("Error initialising session creds\n")); + fprintf(stderr, "Error initialising session creds\n"); goto done; } @@ -221,36 +185,33 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, int argc, result = cli_netlogon_sam_sync(cli, mem_ctx, database_id, &num_deltas, &hdr_deltas, &deltas); - if (!NT_STATUS_IS_OK(result)) { + + if (!NT_STATUS_IS_OK(result)) goto done; - } /* Display results */ display_sam_sync(num_deltas, hdr_deltas, deltas); done: - cli_nt_session_close(cli); - talloc_destroy(mem_ctx); - return result; } /* Perform sam delta synchronisation */ -static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, int argc, - char **argv) +static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, + TALLOC_CTX *mem_ctx, int argc, + char **argv) { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; unsigned char trust_passwd[16]; - TALLOC_CTX *mem_ctx = NULL; uint32 database_id, num_deltas, tmp; SAM_DELTA_HDR *hdr_deltas; SAM_DELTA_CTR *deltas; UINT64_S seqnum; if (argc != 3) { - printf("Usage: %s database_id seqnum\n", argv[0]); + fprintf(stderr, "Usage: %s database_id seqnum\n", argv[0]); return NT_STATUS_OK; } @@ -261,34 +222,22 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, int argc, seqnum.high = 0; if (!secrets_init()) { - DEBUG(0, ("Unable to initialise secrets database\n")); + fprintf(stderr, "Unable to initialise secrets database\n"); goto done; } - if (!(mem_ctx = talloc_init())) { - DEBUG(0,("talloc_init failed\n")); - goto done; - } - - /* Initialise RPC connection */ - - if (!cli_nt_session_open (cli, PIPE_NETLOGON)) { - DEBUG(0, ("Could not initialize netlogon pipe!\n")); - goto done; - } - /* Initialise session credentials */ if (!secrets_fetch_trust_account_password(lp_workgroup(), trust_passwd, NULL)) { - DEBUG(0, ("could not fetch trust account password\n")); + 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)) { - DEBUG(0, ("Error initialising session creds\n")); + fprintf(stderr, "Error initialising session creds\n"); goto done; } @@ -297,18 +246,15 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, int argc, result = cli_netlogon_sam_deltas(cli, mem_ctx, database_id, seqnum, &num_deltas, &hdr_deltas, &deltas); - if (!NT_STATUS_IS_OK(result)) { + + if (!NT_STATUS_IS_OK(result)) goto done; - } /* Display results */ display_sam_sync(num_deltas, hdr_deltas, deltas); done: - cli_nt_session_close(cli); - talloc_destroy(mem_ctx); - return result; } @@ -318,10 +264,10 @@ struct cmd_set netlogon_commands[] = { { "NETLOGON" }, - { "logonctrl2", cmd_netlogon_logon_ctrl2, "Logon Control 2", "" }, - { "logonctrl", cmd_netlogon_logon_ctrl, "Logon Control", "" }, - { "samsync", cmd_netlogon_sam_sync, "Sam Synchronisation", "" }, - { "samdeltas", cmd_netlogon_sam_deltas, "Query Sam Deltas", "" }, + { "logonctrl2", cmd_netlogon_logon_ctrl2, PIPE_NETLOGON, "Logon Control 2", "" }, + { "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", "" }, { NULL } }; -- cgit 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 From 35e44b3a83d53005d562b18695068a76bebd61e5 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 30 Oct 2001 05:41:07 +0000 Subject: Allow the logon level to be passed to cli_netlogon_sam_logon() rather than the validation level. (This used to be commit c79e94ea27aab31423b1bdc34e9cff25688dbe5f) --- source3/rpcclient/cmd_netlogon.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 180d0cc771..524ff5fb49 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -266,14 +266,14 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, { unsigned char trust_passwd[16]; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - int validation_level = 3; + int logon_type = NET_LOGON_TYPE; char *username, *password; /* Check arguments */ if (argc < 3 || argc > 4) { fprintf(stderr, "Usage: samlogon " - "[validation level]\n"); + "[logon_type]\n"); return NT_STATUS_OK; } @@ -281,7 +281,7 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, password = argv[2]; if (argc == 4) - sscanf(argv[3], "%i", &validation_level); + sscanf(argv[3], "%i", &logon_type); /* Authenticate ourselves with the domain controller */ @@ -306,7 +306,7 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, /* Perform the sam logon */ result = cli_netlogon_sam_logon(cli, mem_ctx, username, password, - validation_level); + logon_type); if (!NT_STATUS_IS_OK(result)) goto done; -- cgit From 9f59fc64b8c1772b6a73d1649013d2187c298868 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Thu, 13 Dec 2001 18:09:29 +0000 Subject: update the ldap support code. it compiles. Ignacio you can update your howto ;-) samsync: a small patch to try chaning challenges. J.F. (This used to be commit c99bc305599698f2291efbfe20024355cb2bcde0) --- source3/rpcclient/cmd_netlogon.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 524ff5fb49..e98573da0c 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -152,6 +152,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, uint32 database_id = 0, num_deltas; SAM_DELTA_HDR *hdr_deltas; SAM_DELTA_CTR *deltas; + DOM_CRED ret_creds; if (argc > 2) { fprintf(stderr, "Usage: %s [database_id]\n", argv[0]); @@ -181,9 +182,12 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, goto done; } + /* on first call the returnAuthenticator is empty */ + memset(&ret_creds, 0, sizeof(ret_creds)); + /* Synchronise sam database */ - result = cli_netlogon_sam_sync(cli, mem_ctx, database_id, + result = cli_netlogon_sam_sync(cli, mem_ctx, &ret_creds, database_id, &num_deltas, &hdr_deltas, &deltas); if (!NT_STATUS_IS_OK(result)) -- cgit From cd68afe31256ad60748b34f7318a180cfc2127cc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 30 Jan 2002 06:08:46 +0000 Subject: Removed version number from file header. Changed "SMB/Netbios" to "SMB/CIFS" in file header. (This used to be commit 6a58c9bd06d0d7502a24bf5ce5a2faf0a146edfa) --- source3/rpcclient/cmd_netlogon.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index e98573da0c..4d67cba1b5 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -1,6 +1,5 @@ /* - Unix SMB/Netbios implementation. - Version 2.2 + Unix SMB/CIFS implementation. RPC pipe client Copyright (C) Tim Potter 2000 -- cgit From e90b65284812aaa5ff9e9935ce9bbad7791cbbcd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 15 Jul 2002 10:35:28 +0000 Subject: updated the 3.0 branch from the head branch - ready for alpha18 (This used to be commit 03ac082dcb375b6f3ca3d810a6a6367542bc23ce) --- source3/rpcclient/cmd_netlogon.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 4d67cba1b5..2e89572660 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -174,7 +174,8 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, goto done; } - result = cli_nt_setup_creds(cli, trust_passwd); + result = new_cli_nt_setup_creds(cli, (lp_server_role() == ROLE_DOMAIN_MEMBER) ? + SEC_CHAN_WKSTA : SEC_CHAN_BDC, trust_passwd); if (!NT_STATUS_IS_OK(result)) { fprintf(stderr, "Error initialising session creds\n"); @@ -237,7 +238,8 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, goto done; } - result = cli_nt_setup_creds(cli, trust_passwd); + result = new_cli_nt_setup_creds(cli, (lp_server_role() == ROLE_DOMAIN_MEMBER) ? + SEC_CHAN_WKSTA : SEC_CHAN_BDC, trust_passwd); if (!NT_STATUS_IS_OK(result)) { fprintf(stderr, "Error initialising session creds\n"); @@ -299,7 +301,8 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, goto done; } - result = cli_nt_setup_creds(cli, trust_passwd); + result = new_cli_nt_setup_creds(cli, (lp_server_role() == ROLE_DOMAIN_MEMBER) ? + SEC_CHAN_WKSTA : SEC_CHAN_BDC, trust_passwd); if (!NT_STATUS_IS_OK(result)) { fprintf(stderr, "Error initialising session creds\n"); -- cgit From 64c53e819b53035ff07f9fa00ca4daef18138f51 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 17 Aug 2002 15:33:49 +0000 Subject: sync 3.0 branch with HEAD (This used to be commit 6497eb78e87a6ffa4c2c61aa4ef6ecd451821a27) --- source3/rpcclient/cmd_netlogon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 2e89572660..c3bc9e5e13 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -174,7 +174,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, goto done; } - result = new_cli_nt_setup_creds(cli, (lp_server_role() == ROLE_DOMAIN_MEMBER) ? + result = cli_nt_setup_creds(cli, (lp_server_role() == ROLE_DOMAIN_MEMBER) ? SEC_CHAN_WKSTA : SEC_CHAN_BDC, trust_passwd); if (!NT_STATUS_IS_OK(result)) { @@ -238,7 +238,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, goto done; } - result = new_cli_nt_setup_creds(cli, (lp_server_role() == ROLE_DOMAIN_MEMBER) ? + result = cli_nt_setup_creds(cli, (lp_server_role() == ROLE_DOMAIN_MEMBER) ? SEC_CHAN_WKSTA : SEC_CHAN_BDC, trust_passwd); if (!NT_STATUS_IS_OK(result)) { @@ -301,7 +301,7 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, goto done; } - result = new_cli_nt_setup_creds(cli, (lp_server_role() == ROLE_DOMAIN_MEMBER) ? + result = cli_nt_setup_creds(cli, (lp_server_role() == ROLE_DOMAIN_MEMBER) ? SEC_CHAN_WKSTA : SEC_CHAN_BDC, trust_passwd); if (!NT_STATUS_IS_OK(result)) { -- cgit From a834a73e341059be154426390304a42e4a011f72 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 25 Sep 2002 15:19:00 +0000 Subject: sync'ing up for 3.0alpha20 release (This used to be commit 65e7b5273bb58802bf0c389b77f7fcae0a1f6139) --- source3/rpcclient/cmd_netlogon.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index c3bc9e5e13..98ba92e5a3 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -125,11 +125,10 @@ static void display_sam_sync(uint32 num_deltas, SAM_DELTA_HDR *hdr_deltas, group->rids[j], group->attribs[j]); break; } - case SAM_DELTA_SAM_STAMP: { - SAM_DELTA_STAMP *stamp = &deltas[i].stamp; + case SAM_DELTA_MODIFIED_COUNT: { + SAM_DELTA_MOD_COUNT *mc = &deltas[i].mod_count; - printf("sam sequence update: 0x%04x\n", - stamp->seqnum); + printf("sam sequence update: 0x%04x\n", mc->seqnum); break; } default: @@ -152,6 +151,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, SAM_DELTA_HDR *hdr_deltas; SAM_DELTA_CTR *deltas; DOM_CRED ret_creds; + uint32 neg_flags = 0x000001ff; if (argc > 2) { fprintf(stderr, "Usage: %s [database_id]\n", argv[0]); @@ -174,8 +174,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, goto done; } - result = cli_nt_setup_creds(cli, (lp_server_role() == ROLE_DOMAIN_MEMBER) ? - SEC_CHAN_WKSTA : SEC_CHAN_BDC, trust_passwd); + result = cli_nt_setup_creds(cli, get_sec_chan(), trust_passwd, &neg_flags, 2); if (!NT_STATUS_IS_OK(result)) { fprintf(stderr, "Error initialising session creds\n"); @@ -188,7 +187,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, /* Synchronise sam database */ result = cli_netlogon_sam_sync(cli, mem_ctx, &ret_creds, database_id, - &num_deltas, &hdr_deltas, &deltas); + 0, &num_deltas, &hdr_deltas, &deltas); if (!NT_STATUS_IS_OK(result)) goto done; @@ -213,6 +212,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, SAM_DELTA_HDR *hdr_deltas; SAM_DELTA_CTR *deltas; UINT64_S seqnum; + uint32 neg_flags = 0x000001ff; if (argc != 3) { fprintf(stderr, "Usage: %s database_id seqnum\n", argv[0]); @@ -238,8 +238,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, goto done; } - result = cli_nt_setup_creds(cli, (lp_server_role() == ROLE_DOMAIN_MEMBER) ? - SEC_CHAN_WKSTA : SEC_CHAN_BDC, trust_passwd); + result = cli_nt_setup_creds(cli, get_sec_chan(), trust_passwd, &neg_flags, 2); if (!NT_STATUS_IS_OK(result)) { fprintf(stderr, "Error initialising session creds\n"); @@ -273,12 +272,15 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, NTSTATUS result = NT_STATUS_UNSUCCESSFUL; int logon_type = NET_LOGON_TYPE; char *username, *password; + uint32 neg_flags = 0x000001ff; + int auth_level = 2; /* Check arguments */ - if (argc < 3 || argc > 4) { + if (argc < 3 || argc > 6) { fprintf(stderr, "Usage: samlogon " - "[logon_type]\n"); + "[logon_type] [neg flags] [auth level (2 or 3)]\n" + "neg flags being 0x000001ff or 0x6007ffff\n"); return NT_STATUS_OK; } @@ -288,6 +290,12 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, if (argc == 4) sscanf(argv[3], "%i", &logon_type); + if (argc == 5) + sscanf(argv[4], "%i", &neg_flags); + + if (argc == 6) + sscanf(argv[5], "%i", &auth_level); + /* Authenticate ourselves with the domain controller */ if (!secrets_init()) { @@ -295,14 +303,12 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, return result; } - if (!secrets_fetch_trust_account_password(lp_workgroup(), trust_passwd, - NULL)) { + 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, (lp_server_role() == ROLE_DOMAIN_MEMBER) ? - SEC_CHAN_WKSTA : SEC_CHAN_BDC, trust_passwd); + result = cli_nt_setup_creds(cli, get_sec_chan(), trust_passwd, &neg_flags, auth_level); if (!NT_STATUS_IS_OK(result)) { fprintf(stderr, "Error initialising session creds\n"); @@ -311,8 +317,7 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, /* Perform the sam logon */ - result = cli_netlogon_sam_logon(cli, mem_ctx, username, password, - logon_type); + result = cli_netlogon_sam_logon(cli, mem_ctx, username, password, logon_type); if (!NT_STATUS_IS_OK(result)) goto done; -- cgit From 36ef82a52953384acedbd51f54ded9357fa8ca3e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 4 Oct 2002 04:10:23 +0000 Subject: merge of new client side support the Win2k LSARPC UUID in rpcbind from APP_HEAD (This used to be commit 1cfd2ee433305e91e87804dd55d10e025d30a69e) --- source3/rpcclient/cmd_netlogon.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 98ba92e5a3..53a926d52b 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -332,11 +332,11 @@ struct cmd_set netlogon_commands[] = { { "NETLOGON" }, - { "logonctrl2", cmd_netlogon_logon_ctrl2, PIPE_NETLOGON, "Logon Control 2", "" }, - { "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", "" }, + { "logonctrl2", cmd_netlogon_logon_ctrl2, PI_NETLOGON, "Logon Control 2", "" }, + { "logonctrl", cmd_netlogon_logon_ctrl, PI_NETLOGON, "Logon Control", "" }, + { "samsync", cmd_netlogon_sam_sync, PI_NETLOGON, "Sam Synchronisation", "" }, + { "samdeltas", cmd_netlogon_sam_deltas, PI_NETLOGON, "Query Sam Deltas", "" }, + { "samlogon", cmd_netlogon_sam_logon, PI_NETLOGON, "Sam Logon", "" }, { NULL } }; -- cgit From 1788f806e7655aa37cff22eaa6f3f424fb779274 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 25 Feb 2003 23:51:56 +0000 Subject: Merge: const fixes. (This used to be commit a20aba09996e470425a151271237f2d48a8302af) --- source3/rpcclient/cmd_netlogon.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 53a926d52b..407bff3735 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -24,7 +24,7 @@ static NTSTATUS cmd_netlogon_logon_ctrl2(struct cli_state *cli, TALLOC_CTX *mem_ctx, int argc, - char **argv) + const char **argv) { uint32 query_level = 1; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; @@ -47,7 +47,7 @@ static NTSTATUS cmd_netlogon_logon_ctrl2(struct cli_state *cli, static NTSTATUS cmd_netlogon_logon_ctrl(struct cli_state *cli, TALLOC_CTX *mem_ctx, int argc, - char **argv) + const char **argv) { #if 0 uint32 query_level = 1; @@ -143,7 +143,7 @@ static void display_sam_sync(uint32 num_deltas, SAM_DELTA_HDR *hdr_deltas, static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, TALLOC_CTX *mem_ctx, int argc, - char **argv) + const char **argv) { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; unsigned char trust_passwd[16]; @@ -204,7 +204,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, TALLOC_CTX *mem_ctx, int argc, - char **argv) + const char **argv) { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; unsigned char trust_passwd[16]; @@ -266,12 +266,12 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, TALLOC_CTX *mem_ctx, int argc, - char **argv) + const char **argv) { unsigned char trust_passwd[16]; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; int logon_type = NET_LOGON_TYPE; - char *username, *password; + const char *username, *password; uint32 neg_flags = 0x000001ff; int auth_level = 2; -- cgit From 417bf608f4253fadf4b227b5f7360f03b0193ff2 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 18 Mar 2003 06:30:30 +0000 Subject: Merge of waider's rpcclient return type patch. (This used to be commit fb91bfa7a28f548dcc549f7e09805e4485c83538) --- source3/rpcclient/cmd_netlogon.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 407bff3735..1421c4da26 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -332,11 +332,11 @@ struct cmd_set netlogon_commands[] = { { "NETLOGON" }, - { "logonctrl2", cmd_netlogon_logon_ctrl2, PI_NETLOGON, "Logon Control 2", "" }, - { "logonctrl", cmd_netlogon_logon_ctrl, PI_NETLOGON, "Logon Control", "" }, - { "samsync", cmd_netlogon_sam_sync, PI_NETLOGON, "Sam Synchronisation", "" }, - { "samdeltas", cmd_netlogon_sam_deltas, PI_NETLOGON, "Query Sam Deltas", "" }, - { "samlogon", cmd_netlogon_sam_logon, PI_NETLOGON, "Sam Logon", "" }, + { "logonctrl2", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl2, NULL, PI_NETLOGON, "Logon Control 2", "" }, + { "logonctrl", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl, NULL, PI_NETLOGON, "Logon Control", "" }, + { "samsync", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_sync, NULL, PI_NETLOGON, "Sam Synchronisation", "" }, + { "samdeltas", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_deltas, NULL, PI_NETLOGON, "Query Sam Deltas", "" }, + { "samlogon", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_logon, NULL, PI_NETLOGON, "Sam Logon", "" }, { NULL } }; -- cgit From 7238bf5f40e16360439e028fa7607a5a28e02965 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 9 Apr 2003 15:54:17 +0000 Subject: This is the netlogon schannel client code. Try a rpcclient -S pdc -U% -c "samlogon user password" and it should work with the schannel. Needs testing against platforms different from NT4SP6. Volker (This used to be commit eaef0d8aeff1aa5a067679be3f17e08d7434e1e8) --- source3/rpcclient/cmd_netlogon.c | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 1421c4da26..e6ec28beab 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -296,25 +296,6 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, if (argc == 6) sscanf(argv[5], "%i", &auth_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, get_sec_chan(), trust_passwd, &neg_flags, auth_level); - - 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, logon_type); -- cgit From c182b78639c6db1111d658c77e32c44b92085f00 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 14 Apr 2003 05:26:30 +0000 Subject: Merge: remove unused variable. (This used to be commit 6a1d99d318c2dddc01d8262f31c7afbe9bb1a286) --- source3/rpcclient/cmd_netlogon.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index e6ec28beab..7a77d125a6 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -268,7 +268,6 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { - unsigned char trust_passwd[16]; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; int logon_type = NET_LOGON_TYPE; const char *username, *password; -- cgit From f071020f5e49837154581c97c5af5f84d0e2de89 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 21 Apr 2003 14:09:03 +0000 Subject: Merge from HEAD - save the type of channel used to contact the DC. This allows us to join as a BDC, without appearing on the network as one until we have the database replicated, and the admin changes the configuration. This also change the SID retreval order from secrets.tdb, so we no longer require a 'net rpc getsid' - the sid fetch during the domain join is sufficient. Also minor fixes to 'net'. Andrew Bartlett (This used to be commit 876e00fd112e4aaf7519eec27f382eb99ec7562a) --- source3/rpcclient/cmd_netlogon.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 7a77d125a6..32fa9c3699 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -152,6 +152,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, SAM_DELTA_CTR *deltas; DOM_CRED ret_creds; uint32 neg_flags = 0x000001ff; + uint32 sec_channel_type = 0; if (argc > 2) { fprintf(stderr, "Usage: %s [database_id]\n", argv[0]); @@ -169,12 +170,12 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, /* Initialise session credentials */ if (!secrets_fetch_trust_account_password(lp_workgroup(), trust_passwd, - NULL)) { + NULL, &sec_channel_type)) { fprintf(stderr, "could not fetch trust account password\n"); goto done; } - result = cli_nt_setup_creds(cli, get_sec_chan(), trust_passwd, &neg_flags, 2); + result = cli_nt_setup_creds(cli, sec_channel_type, trust_passwd, &neg_flags, 2); if (!NT_STATUS_IS_OK(result)) { fprintf(stderr, "Error initialising session creds\n"); @@ -213,6 +214,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, SAM_DELTA_CTR *deltas; UINT64_S seqnum; uint32 neg_flags = 0x000001ff; + uint32 sec_channel_type = 0; if (argc != 3) { fprintf(stderr, "Usage: %s database_id seqnum\n", argv[0]); @@ -233,12 +235,12 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, /* Initialise session credentials */ if (!secrets_fetch_trust_account_password(lp_workgroup(), trust_passwd, - NULL)) { + NULL, &sec_channel_type)) { fprintf(stderr, "could not fetch trust account password\n"); goto done; } - result = cli_nt_setup_creds(cli, get_sec_chan(), trust_passwd, &neg_flags, 2); + result = cli_nt_setup_creds(cli, sec_channel_type, trust_passwd, &neg_flags, 2); if (!NT_STATUS_IS_OK(result)) { fprintf(stderr, "Error initialising session creds\n"); -- cgit From d1da999e0a84939e372ebe590861376e2c0075b3 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 8 May 2003 08:02:52 +0000 Subject: This puts real netlogon connection caching to winbind. This becomes important once we start doing schannel, as there would be a lot more roundtrips for the second PIPE open and bind. With this patch logging in to a member server is a matter of two (three if you count the ack...) packets between us and the DC. Volker (This used to be commit 5b3cb7725a974629d0bd8b707bc2940c36b8745e) --- source3/rpcclient/cmd_netlogon.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 32fa9c3699..0ec78a0673 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -275,6 +275,7 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, const char *username, *password; uint32 neg_flags = 0x000001ff; int auth_level = 2; + DOM_CRED ret_creds; /* Check arguments */ @@ -299,7 +300,13 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, /* Perform the sam logon */ - result = cli_netlogon_sam_logon(cli, mem_ctx, username, password, logon_type); + ZERO_STRUCT(ret_creds); + + result = cli_netlogon_sam_logon(cli, mem_ctx, &ret_creds, username, password, logon_type); + + clnt_deal_with_creds(cli->sess_key, &(cli->clnt_cred), &ret_creds); + + result = cli_netlogon_sam_logon(cli, mem_ctx, &ret_creds, username, password, logon_type); if (!NT_STATUS_IS_OK(result)) goto done; -- cgit From 172766eea7a374e910ea91c857fcce45996783a2 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 14 Aug 2003 01:08:00 +0000 Subject: Change Samba to always use extended security for it's guest logins, (ie, NTLMSSP with "" username, NULL password), and add --machine-pass (-P) to all of Samba's clients. When connecting to an Active Directory DC, you must initiate the CIFS level session setup with Kerberos, not a guest login. If you don't, your machine account is demoted to NT4. Andrew Bartlett (This used to be commit 3547cb3def45a90f99f67829a533eac1ccba5e77) --- source3/rpcclient/cmd_netlogon.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 0ec78a0673..e7d5f7f118 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -308,6 +308,8 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, result = cli_netlogon_sam_logon(cli, mem_ctx, &ret_creds, username, password, logon_type); + clnt_deal_with_creds(cli->sess_key, &(cli->clnt_cred), &ret_creds); + if (!NT_STATUS_IS_OK(result)) goto done; -- cgit From f0cd6b35e551cdb2acb088f52edb0746da251b73 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 19 Aug 2003 20:39:32 +0000 Subject: - Fix the kerberos downgrade problem: - When connecting to the NETOGON pipe, we make a call to auth2, in order to verify our identity. This call was being made with negotiation flags of 0x1ff. This caused our account to be downgraded. If we instead make the call with flags > 1ff (such as 0x701ff), then this does not occour. - This is *not* related to the use of kerberos for the CIFS-level connection My theory is that Win2k has a test to see if we are sending *exactly* what NT4 sent - setting any other flags seems to cause us to remain intact. Also ensure that we only have 'setup schannel' code in a few places, not scattered around cmd_netlogon too. Andrew Bartlett (This used to be commit e10f0529fe9d8d245b3cd001cce6a9a86896679c) --- source3/rpcclient/cmd_netlogon.c | 84 +++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 49 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index e7d5f7f118..a48b59bf6a 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -146,13 +146,10 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, const char **argv) { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - unsigned char trust_passwd[16]; uint32 database_id = 0, num_deltas; SAM_DELTA_HDR *hdr_deltas; SAM_DELTA_CTR *deltas; DOM_CRED ret_creds; - uint32 neg_flags = 0x000001ff; - uint32 sec_channel_type = 0; if (argc > 2) { fprintf(stderr, "Usage: %s [database_id]\n", argv[0]); @@ -162,26 +159,6 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, if (argc == 2) database_id = atoi(argv[1]); - if (!secrets_init()) { - fprintf(stderr, "Unable to initialise secrets database\n"); - return result; - } - - /* Initialise session credentials */ - - if (!secrets_fetch_trust_account_password(lp_workgroup(), trust_passwd, - NULL, &sec_channel_type)) { - fprintf(stderr, "could not fetch trust account password\n"); - goto done; - } - - result = cli_nt_setup_creds(cli, sec_channel_type, trust_passwd, &neg_flags, 2); - - if (!NT_STATUS_IS_OK(result)) { - fprintf(stderr, "Error initialising session creds\n"); - goto done; - } - /* on first call the returnAuthenticator is empty */ memset(&ret_creds, 0, sizeof(ret_creds)); @@ -208,13 +185,10 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, const char **argv) { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - unsigned char trust_passwd[16]; uint32 database_id, num_deltas, tmp; SAM_DELTA_HDR *hdr_deltas; SAM_DELTA_CTR *deltas; UINT64_S seqnum; - uint32 neg_flags = 0x000001ff; - uint32 sec_channel_type = 0; if (argc != 3) { fprintf(stderr, "Usage: %s database_id seqnum\n", argv[0]); @@ -227,28 +201,6 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, seqnum.low = tmp & 0xffff; seqnum.high = 0; - if (!secrets_init()) { - fprintf(stderr, "Unable to initialise secrets database\n"); - goto done; - } - - /* Initialise session credentials */ - - if (!secrets_fetch_trust_account_password(lp_workgroup(), trust_passwd, - NULL, &sec_channel_type)) { - fprintf(stderr, "could not fetch trust account password\n"); - goto done; - } - - result = cli_nt_setup_creds(cli, sec_channel_type, trust_passwd, &neg_flags, 2); - - if (!NT_STATUS_IS_OK(result)) { - fprintf(stderr, "Error initialising session creds\n"); - goto done; - } - - /* Synchronise sam database */ - result = cli_netlogon_sam_deltas(cli, mem_ctx, database_id, seqnum, &num_deltas, &hdr_deltas, &deltas); @@ -317,6 +269,39 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, return result; } +/* Change the trust account password */ + +static NTSTATUS cmd_netlogon_change_trust_pw(struct cli_state *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + DOM_CRED ret_creds; + + /* Check arguments */ + + if (argc > 1) { + fprintf(stderr, "Usage: change_trust_pw"); + return NT_STATUS_OK; + } + + /* Perform the sam logon */ + + ZERO_STRUCT(ret_creds); + + result = trust_pw_find_change_and_store_it(cli, mem_ctx, + lp_workgroup()); + + clnt_deal_with_creds(cli->sess_key, &(cli->clnt_cred), &ret_creds); + + if (!NT_STATUS_IS_OK(result)) + goto done; + + done: + return result; +} + + /* List of commands exported by this module */ struct cmd_set netlogon_commands[] = { @@ -327,7 +312,8 @@ struct cmd_set netlogon_commands[] = { { "logonctrl", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl, NULL, PI_NETLOGON, "Logon Control", "" }, { "samsync", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_sync, NULL, PI_NETLOGON, "Sam Synchronisation", "" }, { "samdeltas", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_deltas, NULL, PI_NETLOGON, "Query Sam Deltas", "" }, - { "samlogon", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_logon, NULL, PI_NETLOGON, "Sam Logon", "" }, + { "samlogon", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_logon, NULL, PI_NETLOGON, "Sam Logon", "" }, + { "samlogon", RPC_RTYPE_NTSTATUS, cmd_netlogon_change_trust_pw, NULL, PI_NETLOGON, "Change Trust Account Password", "" }, { NULL } }; -- cgit From 044c6f513dca21d4fc01db4a686c75d43d4952d2 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 2 Apr 2004 12:56:18 +0000 Subject: Implement NETLOGON GetDCName client side. You can ask a DC for the name of a DC it trusts. Volker (This used to be commit ae6840320ff47827c2817549fe3133a57e3fe77f) --- source3/rpcclient/cmd_netlogon.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index a48b59bf6a..9e281fefce 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -45,6 +45,31 @@ static NTSTATUS cmd_netlogon_logon_ctrl2(struct cli_state *cli, return result; } +static NTSTATUS cmd_netlogon_getdcname(struct cli_state *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + fstring dcname; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + + if (argc != 2) { + fprintf(stderr, "Usage: %s domainname\n", argv[0]); + return NT_STATUS_OK; + } + + result = cli_netlogon_getdcname(cli, mem_ctx, argv[1], dcname); + + if (!NT_STATUS_IS_OK(result)) + goto done; + + /* Display results */ + + printf("%s\n", dcname); + + done: + return result; +} + static NTSTATUS cmd_netlogon_logon_ctrl(struct cli_state *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) @@ -309,6 +334,7 @@ struct cmd_set netlogon_commands[] = { { "NETLOGON" }, { "logonctrl2", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl2, NULL, PI_NETLOGON, "Logon Control 2", "" }, + { "getdcname", RPC_RTYPE_NTSTATUS, cmd_netlogon_getdcname, NULL, PI_NETLOGON, "Get trusted DC name", "" }, { "logonctrl", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl, NULL, PI_NETLOGON, "Logon Control", "" }, { "samsync", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_sync, NULL, PI_NETLOGON, "Sam Synchronisation", "" }, { "samdeltas", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_deltas, NULL, PI_NETLOGON, "Query Sam Deltas", "" }, -- cgit From 68f62ab74e3f462faf7a010b40e2d8ba1fb865d2 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 26 Jul 2004 10:08:03 +0000 Subject: r1590: Small fixes from Günther Deschner (This used to be commit 2d68fdf06b3b027227ab77372b001b13fd2b494d) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source3/rpcclient/cmd_netlogon.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 9e281fefce..b55306ddc8 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -266,10 +266,10 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, username = argv[1]; password = argv[2]; - if (argc == 4) + if (argc >= 4) sscanf(argv[3], "%i", &logon_type); - if (argc == 5) + if (argc >= 5) sscanf(argv[4], "%i", &neg_flags); if (argc == 6) @@ -283,10 +283,6 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, clnt_deal_with_creds(cli->sess_key, &(cli->clnt_cred), &ret_creds); - result = cli_netlogon_sam_logon(cli, mem_ctx, &ret_creds, username, password, logon_type); - - clnt_deal_with_creds(cli->sess_key, &(cli->clnt_cred), &ret_creds); - if (!NT_STATUS_IS_OK(result)) goto done; @@ -339,7 +335,7 @@ struct cmd_set netlogon_commands[] = { { "samsync", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_sync, NULL, PI_NETLOGON, "Sam Synchronisation", "" }, { "samdeltas", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_deltas, NULL, PI_NETLOGON, "Query Sam Deltas", "" }, { "samlogon", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_logon, NULL, PI_NETLOGON, "Sam Logon", "" }, - { "samlogon", RPC_RTYPE_NTSTATUS, cmd_netlogon_change_trust_pw, NULL, PI_NETLOGON, "Change Trust Account Password", "" }, + { "change_trust_pw", RPC_RTYPE_NTSTATUS, cmd_netlogon_change_trust_pw, NULL, PI_NETLOGON, "Change Trust Account Password", "" }, { NULL } }; -- cgit From 54abd2aa66069e6baf7769c496f46d9dba18db39 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 30 Sep 2005 17:13:37 +0000 Subject: r10656: BIG merge from trunk. Features not copied over * \PIPE\unixinfo * winbindd's {group,alias}membership new functions * winbindd's lookupsids() functionality * swat (trunk changes to be reverted as per discussion with Deryck) (This used to be commit 939c3cb5d78e3a2236209b296aa8aba8bdce32d3) --- source3/rpcclient/cmd_netlogon.c | 52 +++++++++++++++------------------------- 1 file changed, 19 insertions(+), 33 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index b55306ddc8..153daa5cf2 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -22,7 +22,7 @@ #include "includes.h" #include "rpcclient.h" -static NTSTATUS cmd_netlogon_logon_ctrl2(struct cli_state *cli, +static NTSTATUS cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -34,7 +34,7 @@ static NTSTATUS cmd_netlogon_logon_ctrl2(struct cli_state *cli, return NT_STATUS_OK; } - result = cli_netlogon_logon_ctrl2(cli, mem_ctx, query_level); + result = rpccli_netlogon_logon_ctrl2(cli, mem_ctx, query_level); if (!NT_STATUS_IS_OK(result)) goto done; @@ -45,7 +45,7 @@ static NTSTATUS cmd_netlogon_logon_ctrl2(struct cli_state *cli, return result; } -static NTSTATUS cmd_netlogon_getdcname(struct cli_state *cli, +static NTSTATUS cmd_netlogon_getdcname(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -57,7 +57,7 @@ static NTSTATUS cmd_netlogon_getdcname(struct cli_state *cli, return NT_STATUS_OK; } - result = cli_netlogon_getdcname(cli, mem_ctx, argv[1], dcname); + result = rpccli_netlogon_getdcname(cli, mem_ctx, cli->cli->desthost, argv[1], dcname); if (!NT_STATUS_IS_OK(result)) goto done; @@ -70,7 +70,7 @@ static NTSTATUS cmd_netlogon_getdcname(struct cli_state *cli, return result; } -static NTSTATUS cmd_netlogon_logon_ctrl(struct cli_state *cli, +static NTSTATUS cmd_netlogon_logon_ctrl(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -166,7 +166,7 @@ static void display_sam_sync(uint32 num_deltas, SAM_DELTA_HDR *hdr_deltas, /* Perform sam synchronisation */ -static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, +static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -174,7 +174,6 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, uint32 database_id = 0, num_deltas; SAM_DELTA_HDR *hdr_deltas; SAM_DELTA_CTR *deltas; - DOM_CRED ret_creds; if (argc > 2) { fprintf(stderr, "Usage: %s [database_id]\n", argv[0]); @@ -184,12 +183,9 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, if (argc == 2) database_id = atoi(argv[1]); - /* on first call the returnAuthenticator is empty */ - memset(&ret_creds, 0, sizeof(ret_creds)); - /* Synchronise sam database */ - result = cli_netlogon_sam_sync(cli, mem_ctx, &ret_creds, database_id, + result = rpccli_netlogon_sam_sync(cli, mem_ctx, database_id, 0, &num_deltas, &hdr_deltas, &deltas); if (!NT_STATUS_IS_OK(result)) @@ -205,7 +201,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, /* Perform sam delta synchronisation */ -static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, +static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -226,7 +222,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, seqnum.low = tmp & 0xffff; seqnum.high = 0; - result = cli_netlogon_sam_deltas(cli, mem_ctx, database_id, + result = rpccli_netlogon_sam_deltas(cli, mem_ctx, database_id, seqnum, &num_deltas, &hdr_deltas, &deltas); @@ -243,7 +239,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, /* Log on a domain user */ -static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, +static NTSTATUS cmd_netlogon_sam_logon(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -252,7 +248,6 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, const char *username, *password; uint32 neg_flags = 0x000001ff; int auth_level = 2; - DOM_CRED ret_creds; /* Check arguments */ @@ -277,12 +272,8 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, /* Perform the sam logon */ - ZERO_STRUCT(ret_creds); + result = rpccli_netlogon_sam_logon(cli, mem_ctx, lp_workgroup(), username, password, logon_type); - result = cli_netlogon_sam_logon(cli, mem_ctx, &ret_creds, username, password, logon_type); - - clnt_deal_with_creds(cli->sess_key, &(cli->clnt_cred), &ret_creds); - if (!NT_STATUS_IS_OK(result)) goto done; @@ -292,12 +283,11 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, /* Change the trust account password */ -static NTSTATUS cmd_netlogon_change_trust_pw(struct cli_state *cli, +static NTSTATUS cmd_netlogon_change_trust_pw(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - DOM_CRED ret_creds; /* Check arguments */ @@ -308,13 +298,9 @@ static NTSTATUS cmd_netlogon_change_trust_pw(struct cli_state *cli, /* Perform the sam logon */ - ZERO_STRUCT(ret_creds); - result = trust_pw_find_change_and_store_it(cli, mem_ctx, lp_workgroup()); - clnt_deal_with_creds(cli->sess_key, &(cli->clnt_cred), &ret_creds); - if (!NT_STATUS_IS_OK(result)) goto done; @@ -329,13 +315,13 @@ struct cmd_set netlogon_commands[] = { { "NETLOGON" }, - { "logonctrl2", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl2, NULL, PI_NETLOGON, "Logon Control 2", "" }, - { "getdcname", RPC_RTYPE_NTSTATUS, cmd_netlogon_getdcname, NULL, PI_NETLOGON, "Get trusted DC name", "" }, - { "logonctrl", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl, NULL, PI_NETLOGON, "Logon Control", "" }, - { "samsync", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_sync, NULL, PI_NETLOGON, "Sam Synchronisation", "" }, - { "samdeltas", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_deltas, NULL, PI_NETLOGON, "Query Sam Deltas", "" }, - { "samlogon", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_logon, NULL, PI_NETLOGON, "Sam Logon", "" }, - { "change_trust_pw", RPC_RTYPE_NTSTATUS, cmd_netlogon_change_trust_pw, NULL, PI_NETLOGON, "Change Trust Account Password", "" }, + { "logonctrl2", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl2, NULL, PI_NETLOGON, NULL, "Logon Control 2", "" }, + { "getdcname", RPC_RTYPE_NTSTATUS, cmd_netlogon_getdcname, NULL, PI_NETLOGON, NULL, "Get trusted DC name", "" }, + { "logonctrl", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl, NULL, PI_NETLOGON, NULL, "Logon Control", "" }, + { "samsync", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_sync, NULL, PI_NETLOGON, NULL, "Sam Synchronisation", "" }, + { "samdeltas", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_deltas, NULL, PI_NETLOGON, NULL, "Query Sam Deltas", "" }, + { "samlogon", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_logon, NULL, PI_NETLOGON, NULL, "Sam Logon", "" }, + { "change_trust_pw", RPC_RTYPE_NTSTATUS, cmd_netlogon_change_trust_pw, NULL, PI_NETLOGON, NULL, "Change Trust Account Password", "" }, { NULL } }; -- cgit From fcceedd67c29bae6941949a16ebef37e95dab601 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 8 Nov 2005 06:19:34 +0000 Subject: r11573: Adding Andrew Bartlett's patch to make machine account logons work if the client gives the MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT or MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT flags. This changes the auth module interface to 2 (from 1). The effect of this is that clients can access resources as a machine account if they set these flags. This is the same as Windows (think of a VPN where the vpn client authenticates itself to a VPN server using machine account credentials - the vpn server checks that the machine password was valid by performing a machine account check with the PDC in the same was as it would a user account check. I may add in a restriction (parameter) to allow this behaviour to be turned off (as it was previously). That may be on by default. Andrew Bartlett please review this change carefully. Jeremy. (This used to be commit d1caef866326346fb191f8129d13d98379f18cd8) --- source3/rpcclient/cmd_netlogon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 153daa5cf2..d8f5a75b54 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -272,7 +272,7 @@ static NTSTATUS cmd_netlogon_sam_logon(struct rpc_pipe_client *cli, /* Perform the sam logon */ - result = rpccli_netlogon_sam_logon(cli, mem_ctx, lp_workgroup(), username, password, logon_type); + result = rpccli_netlogon_sam_logon(cli, mem_ctx, 0, lp_workgroup(), username, password, logon_type); if (!NT_STATUS_IS_OK(result)) goto done; -- cgit From 32cf16f3cfaf52414c324c0a333ff29cb9a326aa Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 13 Nov 2005 11:38:17 +0000 Subject: r11706: Implement dsr_getdcname client code. It's handy: It not only gives you the IP address but also the fqdn of the remote dc and site info. Volker (This used to be commit 62d01ce7e6c14971084c208ab61f379cb172cb22) --- source3/rpcclient/cmd_netlogon.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index d8f5a75b54..20f11bc3c9 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -70,6 +70,35 @@ static NTSTATUS cmd_netlogon_getdcname(struct rpc_pipe_client *cli, return result; } +static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + WERROR result; + char *dcname, *dcaddress; + + if (argc != 2) { + fprintf(stderr, "Usage: %s domainname\n", argv[0]); + return WERR_OK; + } + + result = rpccli_netlogon_dsr_getdcname( + cli, mem_ctx, cli->cli->desthost, argv[1], NULL, NULL, + 0x40000000, &dcname, &dcaddress, NULL, NULL, NULL, NULL, + NULL, NULL, NULL); + + if (W_ERROR_IS_OK(result)) { + printf("Domain %s's DC is called %s at IP %s\n", + argv[1], dcname, dcaddress); + return WERR_OK; + } + + printf("rpccli_netlogon_dsr_getdcname returned %s\n", + nt_errstr(werror_to_ntstatus(result))); + + return result; +} + static NTSTATUS cmd_netlogon_logon_ctrl(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) @@ -317,6 +346,7 @@ struct cmd_set netlogon_commands[] = { { "logonctrl2", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl2, NULL, PI_NETLOGON, NULL, "Logon Control 2", "" }, { "getdcname", RPC_RTYPE_NTSTATUS, cmd_netlogon_getdcname, NULL, PI_NETLOGON, NULL, "Get trusted DC name", "" }, + { "dsr_getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "logonctrl", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl, NULL, PI_NETLOGON, NULL, "Logon Control", "" }, { "samsync", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_sync, NULL, PI_NETLOGON, NULL, "Sam Synchronisation", "" }, { "samdeltas", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_deltas, NULL, PI_NETLOGON, NULL, "Query Sam Deltas", "" }, -- cgit From 63addcb4d7c9c13446d91a0972fe29542a7e1bad Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 22 Nov 2005 14:10:49 +0000 Subject: r11853: Add Dsr_GetSiteName (handy for experimenting with GPOs). Guenther (This used to be commit c54430a7b5e40d3bdf8afdc813eb722c0a3b861e) --- source3/rpcclient/cmd_netlogon.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 20f11bc3c9..9377f8fde8 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -99,6 +99,31 @@ static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli, return result; } +static WERROR cmd_netlogon_dsr_getsitename(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + WERROR result; + char *sitename; + + if (argc != 2) { + fprintf(stderr, "Usage: %s computername\n", argv[0]); + return WERR_OK; + } + + result = rpccli_netlogon_dsr_getsitename(cli, mem_ctx, argv[1], &sitename); + + if (!W_ERROR_IS_OK(result)) { + printf("rpccli_netlogon_dsr_gesitename returned %s\n", + nt_errstr(werror_to_ntstatus(result))); + return result; + } + + printf("Computer %s is on Site: %s\n", argv[1], sitename); + + return WERR_OK; +} + static NTSTATUS cmd_netlogon_logon_ctrl(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) @@ -347,6 +372,7 @@ struct cmd_set netlogon_commands[] = { { "logonctrl2", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl2, NULL, PI_NETLOGON, NULL, "Logon Control 2", "" }, { "getdcname", RPC_RTYPE_NTSTATUS, cmd_netlogon_getdcname, NULL, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "dsr_getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, + { "dsr_getsitename", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getsitename, PI_NETLOGON, NULL, "Get sitename", "" }, { "logonctrl", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl, NULL, PI_NETLOGON, NULL, "Logon Control", "" }, { "samsync", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_sync, NULL, PI_NETLOGON, NULL, "Sam Synchronisation", "" }, { "samdeltas", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_deltas, NULL, PI_NETLOGON, NULL, "Query Sam Deltas", "" }, -- cgit From 99a3f68eb59e7d00c87081ff2f22449ebe4081ed Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 16 Mar 2006 22:54:07 +0000 Subject: r14495: Allow to play with the logon_param flag when testing samlogons. Guenther (This used to be commit 52d721b6384cf6f94e1ebb59d21bf09737a539b5) --- source3/rpcclient/cmd_netlogon.c | 43 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 9377f8fde8..35b8accdb6 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -294,45 +294,44 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli, /* Log on a domain user */ static NTSTATUS cmd_netlogon_sam_logon(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, int argc, - const char **argv) + TALLOC_CTX *mem_ctx, int argc, + const char **argv) { - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - int logon_type = NET_LOGON_TYPE; - const char *username, *password; - uint32 neg_flags = 0x000001ff; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + int logon_type = NET_LOGON_TYPE; + const char *username, *password; int auth_level = 2; + uint32 logon_param = 0; - /* Check arguments */ + /* Check arguments */ - if (argc < 3 || argc > 6) { - fprintf(stderr, "Usage: samlogon " - "[logon_type] [neg flags] [auth level (2 or 3)]\n" - "neg flags being 0x000001ff or 0x6007ffff\n"); - return NT_STATUS_OK; - } + if (argc < 3 || argc > 6) { + fprintf(stderr, "Usage: samlogon " + "[logon_type (1 or 2)] [auth level (2 or 3)] [logon_parameter]\n"); + return NT_STATUS_OK; + } - username = argv[1]; - password = argv[2]; + username = argv[1]; + password = argv[2]; - if (argc >= 4) - sscanf(argv[3], "%i", &logon_type); + if (argc >= 4) + sscanf(argv[3], "%i", &logon_type); if (argc >= 5) - sscanf(argv[4], "%i", &neg_flags); + sscanf(argv[4], "%i", &auth_level); if (argc == 6) - sscanf(argv[5], "%i", &auth_level); + sscanf(argv[5], "%x", &logon_param); - /* Perform the sam logon */ + /* Perform the sam logon */ - result = rpccli_netlogon_sam_logon(cli, mem_ctx, 0, lp_workgroup(), username, password, logon_type); + result = rpccli_netlogon_sam_logon(cli, mem_ctx, logon_param, lp_workgroup(), username, password, logon_type); if (!NT_STATUS_IS_OK(result)) goto done; done: - return result; + return result; } /* Change the trust account password */ -- cgit From 995205fc60f87e1a02aa1c6f309db55ae18e908a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 6 Sep 2006 18:32:20 +0000 Subject: r18188: merge 3.0-libndr branch (This used to be commit 1115745caed3093c25d6be01ffee21819fb0a675) --- source3/rpcclient/cmd_netlogon.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 35b8accdb6..ee0fc2e14c 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -263,7 +263,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli, uint32 database_id, num_deltas, tmp; SAM_DELTA_HDR *hdr_deltas; SAM_DELTA_CTR *deltas; - UINT64_S seqnum; + uint64 seqnum; if (argc != 3) { fprintf(stderr, "Usage: %s database_id seqnum\n", argv[0]); @@ -273,8 +273,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli, database_id = atoi(argv[1]); tmp = atoi(argv[2]); - seqnum.low = tmp & 0xffff; - seqnum.high = 0; + seqnum = tmp & 0xffff; result = rpccli_netlogon_sam_deltas(cli, mem_ctx, database_id, seqnum, &num_deltas, -- cgit From adc299bd0863a42f699874f1933dbace3abea316 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Oct 2006 16:13:10 +0000 Subject: r19143: getdcname on the NETLOGON pipe returns WERROR, not NTSTATUS. Guenther (This used to be commit 44e228ac796fca2db8509915067511ed705032bf) --- source3/rpcclient/cmd_netlogon.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index ee0fc2e14c..1a145711cc 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -45,21 +45,21 @@ static NTSTATUS cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli, return result; } -static NTSTATUS cmd_netlogon_getdcname(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, int argc, - const char **argv) +static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) { fstring dcname; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + WERROR result = WERR_GENERAL_FAILURE; if (argc != 2) { fprintf(stderr, "Usage: %s domainname\n", argv[0]); - return NT_STATUS_OK; + return WERR_OK; } result = rpccli_netlogon_getdcname(cli, mem_ctx, cli->cli->desthost, argv[1], dcname); - if (!NT_STATUS_IS_OK(result)) + if (!W_ERROR_IS_OK(result)) goto done; /* Display results */ @@ -368,7 +368,7 @@ struct cmd_set netlogon_commands[] = { { "NETLOGON" }, { "logonctrl2", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl2, NULL, PI_NETLOGON, NULL, "Logon Control 2", "" }, - { "getdcname", RPC_RTYPE_NTSTATUS, cmd_netlogon_getdcname, NULL, PI_NETLOGON, NULL, "Get trusted DC name", "" }, + { "getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getdcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "dsr_getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "dsr_getsitename", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getsitename, PI_NETLOGON, NULL, "Get sitename", "" }, { "logonctrl", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl, NULL, PI_NETLOGON, NULL, "Logon Control", "" }, -- cgit From 7b84b133fe375e69817fe5c76089f67280507809 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 7 Oct 2006 05:26:21 +0000 Subject: r19161: Add NET_GETANYDCNAME (getdcname only gives the PDC while getanydcname gives just any DC), also make sure to set timeouts in rpcclient accordingly so that we actually get the DC's reply. Guenther (This used to be commit 6091c8152a3998d2503cb0911a217ee904509633) --- source3/rpcclient/cmd_netlogon.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 1a145711cc..5ae449a68c 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -51,14 +51,51 @@ static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli, { fstring dcname; WERROR result = WERR_GENERAL_FAILURE; + int old_timeout; if (argc != 2) { fprintf(stderr, "Usage: %s domainname\n", argv[0]); return WERR_OK; } + /* Make sure to wait for our DC's reply */ + old_timeout = cli_set_timeout(cli->cli, 30000); /* 30 seconds. */ + result = rpccli_netlogon_getdcname(cli, mem_ctx, cli->cli->desthost, argv[1], dcname); + cli_set_timeout(cli->cli, old_timeout); + + if (!W_ERROR_IS_OK(result)) + goto done; + + /* Display results */ + + printf("%s\n", dcname); + + done: + return result; +} + +static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + fstring dcname; + WERROR result = WERR_GENERAL_FAILURE; + int old_timeout; + + if (argc != 2) { + fprintf(stderr, "Usage: %s domainname\n", argv[0]); + return WERR_OK; + } + + /* Make sure to wait for our DC's reply */ + old_timeout = cli_set_timeout(cli->cli, 30000); /* 30 seconds. */ + + result = rpccli_netlogon_getanydcname(cli, mem_ctx, cli->cli->desthost, argv[1], dcname); + + cli_set_timeout(cli->cli, old_timeout); + if (!W_ERROR_IS_OK(result)) goto done; @@ -368,7 +405,8 @@ struct cmd_set netlogon_commands[] = { { "NETLOGON" }, { "logonctrl2", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl2, NULL, PI_NETLOGON, NULL, "Logon Control 2", "" }, - { "getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getdcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, + { "getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getdcname, PI_NETLOGON, NULL, "Get trusted PDC name", "" }, + { "getanydcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getanydcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "dsr_getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "dsr_getsitename", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getsitename, PI_NETLOGON, NULL, "Get sitename", "" }, { "logonctrl", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl, NULL, PI_NETLOGON, NULL, "Logon Control", "" }, -- cgit From fb183ebd9207cac7b98aff9f672c06b0b50609ce Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 16 Oct 2006 23:27:38 +0000 Subject: r19353: Add "timeout" command for rpcclient. Guenther (This used to be commit 4106a56d3f4edb2e07e876204743a1cb028c950a) --- source3/rpcclient/cmd_netlogon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 5ae449a68c..a1093d693f 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -59,7 +59,7 @@ static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli, } /* Make sure to wait for our DC's reply */ - old_timeout = cli_set_timeout(cli->cli, 30000); /* 30 seconds. */ + old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */ result = rpccli_netlogon_getdcname(cli, mem_ctx, cli->cli->desthost, argv[1], dcname); @@ -90,7 +90,7 @@ static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli, } /* Make sure to wait for our DC's reply */ - old_timeout = cli_set_timeout(cli->cli, 30000); /* 30 seconds. */ + old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */ result = rpccli_netlogon_getanydcname(cli, mem_ctx, cli->cli->desthost, argv[1], dcname); -- cgit From aeb834036d5cc576df6b284cebf6f4afcce4dfcc Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 23 Jan 2007 10:51:35 +0000 Subject: r20970: Allow to define workstation for samlogon in rpcclient (for testing). Guenther (This used to be commit 5d4747fdf2e5874cb5d2238ee62e4fcac1676134) --- source3/rpcclient/cmd_netlogon.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index a1093d693f..5a2dd00f98 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -338,11 +338,12 @@ static NTSTATUS cmd_netlogon_sam_logon(struct rpc_pipe_client *cli, const char *username, *password; int auth_level = 2; uint32 logon_param = 0; + const char *workstation = NULL; /* Check arguments */ if (argc < 3 || argc > 6) { - fprintf(stderr, "Usage: samlogon " + fprintf(stderr, "Usage: samlogon [workstation]" "[logon_type (1 or 2)] [auth level (2 or 3)] [logon_parameter]\n"); return NT_STATUS_OK; } @@ -350,18 +351,21 @@ static NTSTATUS cmd_netlogon_sam_logon(struct rpc_pipe_client *cli, username = argv[1]; password = argv[2]; - if (argc >= 4) - sscanf(argv[3], "%i", &logon_type); + if (argc >= 4) + workstation = argv[3]; if (argc >= 5) - sscanf(argv[4], "%i", &auth_level); + sscanf(argv[4], "%i", &logon_type); - if (argc == 6) - sscanf(argv[5], "%x", &logon_param); + if (argc >= 6) + sscanf(argv[5], "%i", &auth_level); + + if (argc == 7) + sscanf(argv[6], "%x", &logon_param); /* Perform the sam logon */ - result = rpccli_netlogon_sam_logon(cli, mem_ctx, logon_param, lp_workgroup(), username, password, logon_type); + result = rpccli_netlogon_sam_logon(cli, mem_ctx, logon_param, lp_workgroup(), username, password, workstation, logon_type); if (!NT_STATUS_IS_OK(result)) goto done; -- cgit From c635c57d75bf627ea8e51a2192290cec1b6c59e8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 9 Feb 2007 05:16:25 +0000 Subject: r21259: Fix coverity bug id #340. No way to process logon parameter as the code was written. Jeremy. (This used to be commit 7f1aee96a09d77de76b2cdbe5c2e6f27e6968b09) --- source3/rpcclient/cmd_netlogon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 5a2dd00f98..7794c80919 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -342,7 +342,7 @@ static NTSTATUS cmd_netlogon_sam_logon(struct rpc_pipe_client *cli, /* Check arguments */ - if (argc < 3 || argc > 6) { + if (argc < 3 || argc > 7) { fprintf(stderr, "Usage: samlogon [workstation]" "[logon_type (1 or 2)] [auth level (2 or 3)] [logon_parameter]\n"); return NT_STATUS_OK; -- cgit From 94e4a468f02bc243b72c7e1ddd5a15facf661ae5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 24 May 2007 23:11:11 +0000 Subject: r23127: Fill in some more netlogon dsgetdcname flavours (netr_DsRGetDCNameEx, netr_DsRGetDCNameEx2) and add new ds request and reply flags, also add some more WERROR codes. Guenther (This used to be commit 37ae7f419702c563bcd0d9c27c02bde7efd34dd7) --- source3/rpcclient/cmd_netlogon.c | 194 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 183 insertions(+), 11 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 7794c80919..93d47eeb83 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -107,35 +107,205 @@ static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli, return result; } +static void display_ds_domain_controller_info(TALLOC_CTX *mem_ctx, const struct DS_DOMAIN_CONTROLLER_INFO *info) +{ + d_printf("domain_controller_name: %s\n", info->domain_controller_name); + d_printf("domain_controller_address: %s\n", info->domain_controller_address); + d_printf("domain_controller_address_type: %d\n", info->domain_controller_address_type); + d_printf("domain_guid: %s\n", GUID_string(mem_ctx, info->domain_guid)); + d_printf("domain_name: %s\n", info->domain_name); + d_printf("dns_forest_name: %s\n", info->dns_forest_name); + d_printf("flags: 0x%08x\n" + "\tIs a PDC: %s\n" + "\tIs a GC of the forest: %s\n" + "\tIs an LDAP server: %s\n" + "\tSupports DS: %s\n" + "\tIs running a KDC: %s\n" + "\tIs running time services: %s\n" + "\tIs the closest DC: %s\n" + "\tIs writable: %s\n" + "\tHas a hardware clock: %s\n" + "\tIs a non-domain NC serviced by LDAP server: %s\n" + "\tDomainControllerName is a DNS name: %s\n" + "\tDomainName is a DNS name: %s\n" + "\tDnsForestName is a DNS name: %s\n", + info->flags, + (info->flags & ADS_PDC) ? "yes" : "no", + (info->flags & ADS_GC) ? "yes" : "no", + (info->flags & ADS_LDAP) ? "yes" : "no", + (info->flags & ADS_DS) ? "yes" : "no", + (info->flags & ADS_KDC) ? "yes" : "no", + (info->flags & ADS_TIMESERV) ? "yes" : "no", + (info->flags & ADS_CLOSEST) ? "yes" : "no", + (info->flags & ADS_WRITABLE) ? "yes" : "no", + (info->flags & ADS_GOOD_TIMESERV) ? "yes" : "no", + (info->flags & ADS_NDNC) ? "yes" : "no", + (info->flags & ADS_DNS_CONTROLLER) ? "yes":"no", + (info->flags & ADS_DNS_DOMAIN) ? "yes":"no", + (info->flags & ADS_DNS_FOREST) ? "yes":"no"); + + d_printf("dc_site_name: %s\n", info->dc_site_name); + d_printf("client_site_name: %s\n", info->client_site_name); +} + static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { WERROR result; - char *dcname, *dcaddress; - - if (argc != 2) { - fprintf(stderr, "Usage: %s domainname\n", argv[0]); + uint32 flags = DS_RETURN_DNS_NAME; + const char *server_name = cli->cli->desthost; + const char *domain_name; + struct GUID domain_guid = GUID_zero(); + struct GUID site_guid = GUID_zero(); + struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; + + if (argc < 2) { + fprintf(stderr, "Usage: %s [domainname] [domain_name] [domain_guid] [site_guid] [flags]\n", argv[0]); return WERR_OK; } - result = rpccli_netlogon_dsr_getdcname( - cli, mem_ctx, cli->cli->desthost, argv[1], NULL, NULL, - 0x40000000, &dcname, &dcaddress, NULL, NULL, NULL, NULL, - NULL, NULL, NULL); + if (argc >= 2) + domain_name = argv[1]; + + if (argc >= 3) { + if (!NT_STATUS_IS_OK(GUID_from_string(argv[2], &domain_guid))) { + return WERR_NOMEM; + } + } + + if (argc >= 4) { + if (!NT_STATUS_IS_OK(GUID_from_string(argv[3], &site_guid))) { + return WERR_NOMEM; + } + } + + if (argc >= 5) + sscanf(argv[4], "%x", &flags); + + result = rpccli_netlogon_dsr_getdcname(cli, mem_ctx, server_name, domain_name, + &domain_guid, &site_guid, flags, + &info); if (W_ERROR_IS_OK(result)) { - printf("Domain %s's DC is called %s at IP %s\n", - argv[1], dcname, dcaddress); + d_printf("DsGetDcName gave\n"); + display_ds_domain_controller_info(mem_ctx, info); return WERR_OK; } printf("rpccli_netlogon_dsr_getdcname returned %s\n", - nt_errstr(werror_to_ntstatus(result))); + dos_errstr(result)); + + return result; +} + +static WERROR cmd_netlogon_dsr_getdcnameex(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + WERROR result; + uint32 flags = DS_RETURN_DNS_NAME; + const char *server_name = cli->cli->desthost; + const char *domain_name; + const char *site_name = NULL; + struct GUID domain_guid = GUID_zero(); + struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; + + if (argc < 2) { + fprintf(stderr, "Usage: %s [domainname] [domain_name] [domain_guid] [site_name] [flags]\n", argv[0]); + return WERR_OK; + } + + if (argc >= 2) + domain_name = argv[1]; + + if (argc >= 3) { + if (!NT_STATUS_IS_OK(GUID_from_string(argv[2], &domain_guid))) { + return WERR_NOMEM; + } + } + + if (argc >= 4) + site_name = argv[3]; + + if (argc >= 5) + sscanf(argv[4], "%x", &flags); + + result = rpccli_netlogon_dsr_getdcnameex(cli, mem_ctx, server_name, domain_name, + &domain_guid, site_name, flags, + &info); + + if (W_ERROR_IS_OK(result)) { + d_printf("DsGetDcNameEx gave\n"); + display_ds_domain_controller_info(mem_ctx, info); + return WERR_OK; + } + + printf("rpccli_netlogon_dsr_getdcnameex returned %s\n", + dos_errstr(result)); + + return result; +} + +static WERROR cmd_netlogon_dsr_getdcnameex2(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + WERROR result; + uint32 flags = DS_RETURN_DNS_NAME; + const char *server_name = cli->cli->desthost; + const char *domain_name; + const char *client_account = NULL; + uint32 mask = 0; + const char *site_name = NULL; + struct GUID domain_guid = GUID_zero(); + struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; + + if (argc < 2) { + fprintf(stderr, "Usage: %s [domainname] [client_account] [acb_mask] [domain_name] [domain_guid] [site_name] [flags]\n", argv[0]); + return WERR_OK; + } + + if (argc >= 2) + client_account = argv[1]; + + if (argc >= 3) + mask = atoi(argv[2]); + + if (argc >= 4) + domain_name = argv[3]; + + if (argc >= 5) { + if (!NT_STATUS_IS_OK(GUID_from_string(argv[4], &domain_guid))) { + return WERR_NOMEM; + } + } + + if (argc >= 6) + site_name = argv[5]; + + if (argc >= 7) + sscanf(argv[6], "%x", &flags); + + result = rpccli_netlogon_dsr_getdcnameex2(cli, mem_ctx, server_name, + client_account, mask, + domain_name, &domain_guid, + site_name, flags, + &info); + + if (W_ERROR_IS_OK(result)) { + d_printf("DsGetDcNameEx2 gave\n"); + display_ds_domain_controller_info(mem_ctx, info); + return WERR_OK; + } + + printf("rpccli_netlogon_dsr_getdcnameex2 returned %s\n", + dos_errstr(result)); return result; } + static WERROR cmd_netlogon_dsr_getsitename(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) @@ -412,6 +582,8 @@ struct cmd_set netlogon_commands[] = { { "getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getdcname, PI_NETLOGON, NULL, "Get trusted PDC name", "" }, { "getanydcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getanydcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "dsr_getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, + { "dsr_getdcnameex", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcnameex, PI_NETLOGON, NULL, "Get trusted DC name", "" }, + { "dsr_getdcnameex2", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcnameex2, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "dsr_getsitename", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getsitename, PI_NETLOGON, NULL, "Get sitename", "" }, { "logonctrl", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl, NULL, PI_NETLOGON, NULL, "Logon Control", "" }, { "samsync", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_sync, NULL, PI_NETLOGON, NULL, "Sam Synchronisation", "" }, -- cgit From d8e454664a97385d798ad53633856044f928a491 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 29 May 2007 15:27:13 +0000 Subject: r23210: Very funny, we thought to use netr_GetDcName (e.g. in winbind) but were using netr_GetDcAnyName all the time (which is the correct thing to do). Fix the naming and opcode mixup in all branches. Guenther (This used to be commit def6464c872a5939f0028837254f2c019d2d71c8) --- source3/rpcclient/cmd_netlogon.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 93d47eeb83..d78b7fc26e 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -45,9 +45,9 @@ static NTSTATUS cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli, return result; } -static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, int argc, - const char **argv) +static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) { fstring dcname; WERROR result = WERR_GENERAL_FAILURE; @@ -61,7 +61,7 @@ static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli, /* Make sure to wait for our DC's reply */ old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */ - result = rpccli_netlogon_getdcname(cli, mem_ctx, cli->cli->desthost, argv[1], dcname); + result = rpccli_netlogon_getanydcname(cli, mem_ctx, cli->cli->desthost, argv[1], dcname); cli_set_timeout(cli->cli, old_timeout); @@ -76,27 +76,27 @@ static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli, return result; } -static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, int argc, - const char **argv) +static NTSTATUS cmd_netlogon_getdcname(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) { fstring dcname; - WERROR result = WERR_GENERAL_FAILURE; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; int old_timeout; if (argc != 2) { fprintf(stderr, "Usage: %s domainname\n", argv[0]); - return WERR_OK; + return NT_STATUS_OK; } /* Make sure to wait for our DC's reply */ old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */ - result = rpccli_netlogon_getanydcname(cli, mem_ctx, cli->cli->desthost, argv[1], dcname); + result = rpccli_netlogon_getdcname(cli, mem_ctx, cli->cli->desthost, argv[1], dcname); cli_set_timeout(cli->cli, old_timeout); - if (!W_ERROR_IS_OK(result)) + if (!NT_STATUS_IS_OK(result)) goto done; /* Display results */ @@ -579,8 +579,8 @@ struct cmd_set netlogon_commands[] = { { "NETLOGON" }, { "logonctrl2", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl2, NULL, PI_NETLOGON, NULL, "Logon Control 2", "" }, - { "getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getdcname, PI_NETLOGON, NULL, "Get trusted PDC name", "" }, { "getanydcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getanydcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, + { "getdcname", RPC_RTYPE_NTSTATUS, cmd_netlogon_getdcname, NULL, PI_NETLOGON, NULL, "Get trusted PDC name", "" }, { "dsr_getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "dsr_getdcnameex", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcnameex, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "dsr_getdcnameex2", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcnameex2, PI_NETLOGON, NULL, "Get trusted DC name", "" }, -- cgit From d807dec0f465c8735bd4964b196ff6109d8df408 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 29 May 2007 17:57:52 +0000 Subject: r23219: Two warnings (This used to be commit eccd50abdaed3e4e06cc5da5473ca1beeb3fc49a) --- source3/rpcclient/cmd_netlogon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index d78b7fc26e..77f01e8885 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -254,7 +254,7 @@ static WERROR cmd_netlogon_dsr_getdcnameex2(struct rpc_pipe_client *cli, WERROR result; uint32 flags = DS_RETURN_DNS_NAME; const char *server_name = cli->cli->desthost; - const char *domain_name; + const char *domain_name = NULL; const char *client_account = NULL; uint32 mask = 0; const char *site_name = NULL; -- cgit From 1ea5dfae043da76183191c10bcadbd77e14d1fff Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Jun 2007 10:29:46 +0000 Subject: r23380: netr_getdcname returns WERROR not NTSTATUS. Guenther (This used to be commit 5e75ea7f2b568d76c8ced5f43171741532cc97c2) --- source3/rpcclient/cmd_netlogon.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 77f01e8885..93b900e25e 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -76,17 +76,17 @@ static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli, return result; } -static NTSTATUS cmd_netlogon_getdcname(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, int argc, - const char **argv) +static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) { fstring dcname; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + WERROR result = WERR_GENERAL_FAILURE; int old_timeout; if (argc != 2) { fprintf(stderr, "Usage: %s domainname\n", argv[0]); - return NT_STATUS_OK; + return WERR_OK; } /* Make sure to wait for our DC's reply */ @@ -96,7 +96,7 @@ static NTSTATUS cmd_netlogon_getdcname(struct rpc_pipe_client *cli, cli_set_timeout(cli->cli, old_timeout); - if (!NT_STATUS_IS_OK(result)) + if (!W_ERROR_IS_OK(result)) goto done; /* Display results */ @@ -580,7 +580,7 @@ struct cmd_set netlogon_commands[] = { { "logonctrl2", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl2, NULL, PI_NETLOGON, NULL, "Logon Control 2", "" }, { "getanydcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getanydcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, - { "getdcname", RPC_RTYPE_NTSTATUS, cmd_netlogon_getdcname, NULL, PI_NETLOGON, NULL, "Get trusted PDC name", "" }, + { "getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getdcname, PI_NETLOGON, NULL, "Get trusted PDC name", "" }, { "dsr_getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "dsr_getdcnameex", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcnameex, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "dsr_getdcnameex2", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcnameex2, PI_NETLOGON, NULL, "Get trusted DC name", "" }, -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/rpcclient/cmd_netlogon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 93b900e25e..85afb00e0b 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -6,7 +6,7 @@ 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, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/rpcclient/cmd_netlogon.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 85afb00e0b..b22de0bb54 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -15,8 +15,7 @@ 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 . */ #include "includes.h" -- cgit From 84bce05e71720a54aa87900bd6550576317d52cb Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 28 Aug 2007 15:01:23 +0000 Subject: r24742: Add experimental DsGetDcName() call (will be used by krb5 locator for fine grained KDC DNS queries). Guenther (This used to be commit 3263cd680fe429430d789b284464fca72ef45719) --- source3/rpcclient/cmd_netlogon.c | 61 ++++++++++------------------------------ 1 file changed, 15 insertions(+), 46 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index b22de0bb54..dd8cb6afc5 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -106,47 +106,6 @@ static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli, return result; } -static void display_ds_domain_controller_info(TALLOC_CTX *mem_ctx, const struct DS_DOMAIN_CONTROLLER_INFO *info) -{ - d_printf("domain_controller_name: %s\n", info->domain_controller_name); - d_printf("domain_controller_address: %s\n", info->domain_controller_address); - d_printf("domain_controller_address_type: %d\n", info->domain_controller_address_type); - d_printf("domain_guid: %s\n", GUID_string(mem_ctx, info->domain_guid)); - d_printf("domain_name: %s\n", info->domain_name); - d_printf("dns_forest_name: %s\n", info->dns_forest_name); - d_printf("flags: 0x%08x\n" - "\tIs a PDC: %s\n" - "\tIs a GC of the forest: %s\n" - "\tIs an LDAP server: %s\n" - "\tSupports DS: %s\n" - "\tIs running a KDC: %s\n" - "\tIs running time services: %s\n" - "\tIs the closest DC: %s\n" - "\tIs writable: %s\n" - "\tHas a hardware clock: %s\n" - "\tIs a non-domain NC serviced by LDAP server: %s\n" - "\tDomainControllerName is a DNS name: %s\n" - "\tDomainName is a DNS name: %s\n" - "\tDnsForestName is a DNS name: %s\n", - info->flags, - (info->flags & ADS_PDC) ? "yes" : "no", - (info->flags & ADS_GC) ? "yes" : "no", - (info->flags & ADS_LDAP) ? "yes" : "no", - (info->flags & ADS_DS) ? "yes" : "no", - (info->flags & ADS_KDC) ? "yes" : "no", - (info->flags & ADS_TIMESERV) ? "yes" : "no", - (info->flags & ADS_CLOSEST) ? "yes" : "no", - (info->flags & ADS_WRITABLE) ? "yes" : "no", - (info->flags & ADS_GOOD_TIMESERV) ? "yes" : "no", - (info->flags & ADS_NDNC) ? "yes" : "no", - (info->flags & ADS_DNS_CONTROLLER) ? "yes":"no", - (info->flags & ADS_DNS_DOMAIN) ? "yes":"no", - (info->flags & ADS_DNS_FOREST) ? "yes":"no"); - - d_printf("dc_site_name: %s\n", info->dc_site_name); - d_printf("client_site_name: %s\n", info->client_site_name); -} - static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) @@ -160,7 +119,8 @@ static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli, struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; if (argc < 2) { - fprintf(stderr, "Usage: %s [domainname] [domain_name] [domain_guid] [site_guid] [flags]\n", argv[0]); + fprintf(stderr, "Usage: %s [domain_name] [domain_guid] " + "[site_guid] [flags]\n", argv[0]); return WERR_OK; } @@ -181,7 +141,9 @@ static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli, if (argc >= 5) sscanf(argv[4], "%x", &flags); - + + debug_dsdcinfo_flags(1,flags); + result = rpccli_netlogon_dsr_getdcname(cli, mem_ctx, server_name, domain_name, &domain_guid, &site_guid, flags, &info); @@ -211,7 +173,8 @@ static WERROR cmd_netlogon_dsr_getdcnameex(struct rpc_pipe_client *cli, struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; if (argc < 2) { - fprintf(stderr, "Usage: %s [domainname] [domain_name] [domain_guid] [site_name] [flags]\n", argv[0]); + fprintf(stderr, "Usage: %s [domain_name] [domain_guid] " + "[site_name] [flags]\n", argv[0]); return WERR_OK; } @@ -230,6 +193,8 @@ static WERROR cmd_netlogon_dsr_getdcnameex(struct rpc_pipe_client *cli, if (argc >= 5) sscanf(argv[4], "%x", &flags); + debug_dsdcinfo_flags(1,flags); + result = rpccli_netlogon_dsr_getdcnameex(cli, mem_ctx, server_name, domain_name, &domain_guid, site_name, flags, &info); @@ -261,7 +226,9 @@ static WERROR cmd_netlogon_dsr_getdcnameex2(struct rpc_pipe_client *cli, struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; if (argc < 2) { - fprintf(stderr, "Usage: %s [domainname] [client_account] [acb_mask] [domain_name] [domain_guid] [site_name] [flags]\n", argv[0]); + fprintf(stderr, "Usage: %s [client_account] [acb_mask] " + "[domain_name] [domain_guid] [site_name] " + "[flags]\n", argv[0]); return WERR_OK; } @@ -270,7 +237,7 @@ static WERROR cmd_netlogon_dsr_getdcnameex2(struct rpc_pipe_client *cli, if (argc >= 3) mask = atoi(argv[2]); - + if (argc >= 4) domain_name = argv[3]; @@ -286,6 +253,8 @@ static WERROR cmd_netlogon_dsr_getdcnameex2(struct rpc_pipe_client *cli, if (argc >= 7) sscanf(argv[6], "%x", &flags); + debug_dsdcinfo_flags(1,flags); + result = rpccli_netlogon_dsr_getdcnameex2(cli, mem_ctx, server_name, client_account, mask, domain_name, &domain_guid, -- cgit From c97fe37ea3d92a631e8da17c21dafae1db15e97b Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 21 Sep 2007 14:37:35 +0000 Subject: r25294: Tidy up callers of unistr2_to_ascii() to pass sizeof(target_area) to the maxeln parameter instead of sizeof(target_area) - 1 (or even sizeof(fstring) - 1 in some places. I hope these were really all there were. Michael (This used to be commit 9a28be220df622322857dfe102fa35e108f932dc) --- source3/rpcclient/cmd_netlogon.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index dd8cb6afc5..6acac8273c 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -338,25 +338,25 @@ static void display_sam_sync(uint32 num_deltas, SAM_DELTA_HDR *hdr_deltas, case SAM_DELTA_DOMAIN_INFO: unistr2_to_ascii(name, &deltas[i].domain_info.uni_dom_name, - sizeof(name) - 1); + sizeof(name)); printf("Domain: %s\n", name); break; case SAM_DELTA_GROUP_INFO: unistr2_to_ascii(name, &deltas[i].group_info.uni_grp_name, - sizeof(name) - 1); + sizeof(name)); printf("Group: %s\n", name); break; case SAM_DELTA_ACCOUNT_INFO: unistr2_to_ascii(name, &deltas[i].account_info.uni_acct_name, - sizeof(name) - 1); + sizeof(name)); printf("Account: %s\n", name); break; case SAM_DELTA_ALIAS_INFO: unistr2_to_ascii(name, &deltas[i].alias_info.uni_als_name, - sizeof(name) - 1); + sizeof(name)); printf("Alias: %s\n", name); break; case SAM_DELTA_ALIAS_MEM: { -- cgit From 2e07c2ade89f4ff281c61f74cb88e09990cf5f46 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 15 Dec 2007 22:47:30 +0100 Subject: s/sid_to_string/sid_to_fstring/ least surprise for callers (This used to be commit eb523ba77697346a365589101aac379febecd546) --- source3/rpcclient/cmd_netlogon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 6acac8273c..e997bb5090 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -365,7 +365,7 @@ static void display_sam_sync(uint32 num_deltas, SAM_DELTA_HDR *hdr_deltas, for (j = 0; j < alias->num_members; j++) { fstring sid_str; - sid_to_string(sid_str, &alias->sids[j].sid); + sid_to_fstring(sid_str, &alias->sids[j].sid); printf("%s\n", sid_str); } -- cgit From 8ded1df76739363259edce0515b097510e342595 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 21 Dec 2007 15:12:40 +0100 Subject: Kill fstring in getdcname & getanydcname return. Guenther (This used to be commit b7383818168863a7ba43c2456f8c44e96e76707a) --- source3/rpcclient/cmd_netlogon.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index e997bb5090..2c1f7e0f11 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -48,7 +48,7 @@ static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { - fstring dcname; + char *dcname = NULL; WERROR result = WERR_GENERAL_FAILURE; int old_timeout; @@ -60,7 +60,7 @@ static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli, /* Make sure to wait for our DC's reply */ old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */ - result = rpccli_netlogon_getanydcname(cli, mem_ctx, cli->cli->desthost, argv[1], dcname); + result = rpccli_netlogon_getanydcname(cli, mem_ctx, cli->cli->desthost, argv[1], &dcname); cli_set_timeout(cli->cli, old_timeout); @@ -79,7 +79,7 @@ static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { - fstring dcname; + char *dcname = NULL; WERROR result = WERR_GENERAL_FAILURE; int old_timeout; @@ -91,7 +91,7 @@ static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli, /* Make sure to wait for our DC's reply */ old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */ - result = rpccli_netlogon_getdcname(cli, mem_ctx, cli->cli->desthost, argv[1], dcname); + result = rpccli_netlogon_getdcname(cli, mem_ctx, cli->cli->desthost, argv[1], &dcname); cli_set_timeout(cli->cli, old_timeout); -- cgit From 96b41578a7a4270274a6e1d97cd53a4fb42505d1 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 24 Jan 2008 23:38:43 +0100 Subject: Add cmd_netlogon_gettrustrid() to rpcclient. Guenther (This used to be commit 231a4d051f24af7cf5bf13d7dd613f33dc06f21a) --- source3/rpcclient/cmd_netlogon.c | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 2c1f7e0f11..64c8b75cd8 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -539,6 +539,47 @@ static NTSTATUS cmd_netlogon_change_trust_pw(struct rpc_pipe_client *cli, return result; } +static WERROR cmd_netlogon_gettrustrid(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; + WERROR werr = WERR_GENERAL_FAILURE; + const char *server_name = cli->cli->desthost; + const char *domain_name = lp_workgroup(); + uint32_t rid = 0; + + if (argc < 1 || argc > 3) { + fprintf(stderr, "Usage: %s \n", + argv[0]); + return WERR_OK; + } + + if (argc >= 2) { + server_name = argv[1]; + } + + if (argc >= 3) { + domain_name = argv[2]; + } + + status = rpccli_netr_LogonGetTrustRid(cli, mem_ctx, + server_name, + domain_name, + &rid, + &werr); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + + if (W_ERROR_IS_OK(werr)) { + printf("Rid: %d\n", rid); + } + done: + return werr; +} + + /* List of commands exported by this module */ @@ -558,6 +599,7 @@ struct cmd_set netlogon_commands[] = { { "samdeltas", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_deltas, NULL, PI_NETLOGON, NULL, "Query Sam Deltas", "" }, { "samlogon", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_logon, NULL, PI_NETLOGON, NULL, "Sam Logon", "" }, { "change_trust_pw", RPC_RTYPE_NTSTATUS, cmd_netlogon_change_trust_pw, NULL, PI_NETLOGON, NULL, "Change Trust Account Password", "" }, + { "gettrustrid", RPC_RTYPE_WERROR, NULL, cmd_netlogon_gettrustrid, PI_NETLOGON, NULL, "Get trust rid", "" }, { NULL } }; -- cgit From a059d24488979cea047d88e0a2ace340553e801e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 25 Jan 2008 16:35:09 +0100 Subject: Add cmd_netlogon_dsr_enumtrustdom() to rpcclient. Guenther (This used to be commit cb44c901c1bc66da9f3636020401238ce0005105) --- source3/rpcclient/cmd_netlogon.c | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 64c8b75cd8..ed38378353 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -579,6 +579,53 @@ static WERROR cmd_netlogon_gettrustrid(struct rpc_pipe_client *cli, return werr; } +static WERROR cmd_netlogon_dsr_enumtrustdom(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; + WERROR werr = WERR_GENERAL_FAILURE; + const char *server_name = cli->cli->desthost; + uint32_t trust_flags = NETR_TRUST_FLAG_IN_FOREST; + struct netr_DomainTrustList trusts; + + if (argc < 1 || argc > 3) { + fprintf(stderr, "Usage: %s \n", + argv[0]); + return WERR_OK; + } + + if (argc >= 2) { + server_name = argv[1]; + } + + if (argc >= 3) { + sscanf(argv[2], "%x", &trust_flags); + } + + status = rpccli_netr_DsrEnumerateDomainTrusts(cli, mem_ctx, + server_name, + trust_flags, + &trusts, + &werr); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + + if (W_ERROR_IS_OK(werr)) { + int i; + + printf("%d domains returned\n", trusts.count); + + for (i=0; i Date: Fri, 25 Jan 2008 21:17:44 +0100 Subject: Use rpccli_netr_DsRGetDCNameEx and rpccli_netr_DsRGetDCNameEx2 in rpcclient. Guenther (This used to be commit 2caed3f816d29bd7dfa36df3ddd6aeba5bbfa252) --- source3/rpcclient/cmd_netlogon.c | 133 +++++++++++++++++++++++++++++---------- 1 file changed, 99 insertions(+), 34 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index ed38378353..93d28e3c74 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -165,12 +165,13 @@ static WERROR cmd_netlogon_dsr_getdcnameex(struct rpc_pipe_client *cli, const char **argv) { WERROR result; - uint32 flags = DS_RETURN_DNS_NAME; + NTSTATUS status; + uint32_t flags = DS_RETURN_DNS_NAME; const char *server_name = cli->cli->desthost; const char *domain_name; const char *site_name = NULL; struct GUID domain_guid = GUID_zero(); - struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; + struct netr_DsRGetDCNameInfo *info = NULL; if (argc < 2) { fprintf(stderr, "Usage: %s [domain_name] [domain_guid] " @@ -178,8 +179,7 @@ static WERROR cmd_netlogon_dsr_getdcnameex(struct rpc_pipe_client *cli, return WERR_OK; } - if (argc >= 2) - domain_name = argv[1]; + domain_name = argv[1]; if (argc >= 3) { if (!NT_STATUS_IS_OK(GUID_from_string(argv[2], &domain_guid))) { @@ -187,26 +187,34 @@ static WERROR cmd_netlogon_dsr_getdcnameex(struct rpc_pipe_client *cli, } } - if (argc >= 4) + if (argc >= 4) { site_name = argv[3]; + } - if (argc >= 5) + if (argc >= 5) { sscanf(argv[4], "%x", &flags); + } debug_dsdcinfo_flags(1,flags); - result = rpccli_netlogon_dsr_getdcnameex(cli, mem_ctx, server_name, domain_name, - &domain_guid, site_name, flags, - &info); + status = rpccli_netr_DsRGetDCNameEx(cli, mem_ctx, + server_name, + domain_name, + &domain_guid, + site_name, + flags, + &info, + &result); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } - if (W_ERROR_IS_OK(result)) { - d_printf("DsGetDcNameEx gave\n"); - display_ds_domain_controller_info(mem_ctx, info); - return WERR_OK; + if (!W_ERROR_IS_OK(result)) { + return result; } - printf("rpccli_netlogon_dsr_getdcnameex returned %s\n", - dos_errstr(result)); + d_printf("DsRGetDCNameEx gave %s\n", + NDR_PRINT_STRUCT_STRING(mem_ctx, netr_DsRGetDCNameInfo, info)); return result; } @@ -216,14 +224,15 @@ static WERROR cmd_netlogon_dsr_getdcnameex2(struct rpc_pipe_client *cli, const char **argv) { WERROR result; - uint32 flags = DS_RETURN_DNS_NAME; + NTSTATUS status; + uint32_t flags = DS_RETURN_DNS_NAME; const char *server_name = cli->cli->desthost; const char *domain_name = NULL; const char *client_account = NULL; - uint32 mask = 0; + uint32_t mask = 0; const char *site_name = NULL; struct GUID domain_guid = GUID_zero(); - struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; + struct netr_DsRGetDCNameInfo *info = NULL; if (argc < 2) { fprintf(stderr, "Usage: %s [client_account] [acb_mask] " @@ -232,14 +241,17 @@ static WERROR cmd_netlogon_dsr_getdcnameex2(struct rpc_pipe_client *cli, return WERR_OK; } - if (argc >= 2) + if (argc >= 2) { client_account = argv[1]; + } - if (argc >= 3) + if (argc >= 3) { mask = atoi(argv[2]); + } - if (argc >= 4) + if (argc >= 4) { domain_name = argv[3]; + } if (argc >= 5) { if (!NT_STATUS_IS_OK(GUID_from_string(argv[4], &domain_guid))) { @@ -247,28 +259,36 @@ static WERROR cmd_netlogon_dsr_getdcnameex2(struct rpc_pipe_client *cli, } } - if (argc >= 6) + if (argc >= 6) { site_name = argv[5]; + } - if (argc >= 7) + if (argc >= 7) { sscanf(argv[6], "%x", &flags); + } debug_dsdcinfo_flags(1,flags); - result = rpccli_netlogon_dsr_getdcnameex2(cli, mem_ctx, server_name, - client_account, mask, - domain_name, &domain_guid, - site_name, flags, - &info); + status = rpccli_netr_DsRGetDCNameEx2(cli, mem_ctx, + server_name, + client_account, + mask, + domain_name, + &domain_guid, + site_name, + flags, + &info, + &result); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } - if (W_ERROR_IS_OK(result)) { - d_printf("DsGetDcNameEx2 gave\n"); - display_ds_domain_controller_info(mem_ctx, info); - return WERR_OK; + if (!W_ERROR_IS_OK(result)) { + return result; } - printf("rpccli_netlogon_dsr_getdcnameex2 returned %s\n", - dos_errstr(result)); + d_printf("DsRGetDCNameEx2 gave %s\n", + NDR_PRINT_STRUCT_STRING(mem_ctx, netr_DsRGetDCNameInfo, info)); return result; } @@ -627,6 +647,51 @@ static WERROR cmd_netlogon_dsr_enumtrustdom(struct rpc_pipe_client *cli, return werr; } +static WERROR cmd_netlogon_deregisterdnsrecords(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; + WERROR werr = WERR_GENERAL_FAILURE; + const char *server_name = cli->cli->desthost; + const char *domain = lp_workgroup(); + const char *dns_host = NULL; + + if (argc < 1 || argc > 4) { + fprintf(stderr, "Usage: %s " + "\n", argv[0]); + return WERR_OK; + } + + if (argc >= 2) { + server_name = argv[1]; + } + + if (argc >= 3) { + domain = argv[2]; + } + + if (argc >= 4) { + dns_host = argv[3]; + } + + status = rpccli_netr_DsrDeregisterDNSHostRecords(cli, mem_ctx, + server_name, + domain, + NULL, + NULL, + dns_host, + &werr); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + + if (W_ERROR_IS_OK(werr)) { + printf("success\n"); + } + done: + return werr; +} /* List of commands exported by this module */ -- cgit From 4fd374f06302db5811693fefae6294fad98ef2e4 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 25 Jan 2008 21:21:33 +0100 Subject: Add cmd_netlogon_dsr_getforesttrustinfo and deregisterdnsrecords to rpcclient. Guenther (This used to be commit 227f5755c8844dbff8d66adec3d7fd94b583358f) --- source3/rpcclient/cmd_netlogon.c | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 93d28e3c74..731c3de268 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -693,6 +693,53 @@ static WERROR cmd_netlogon_deregisterdnsrecords(struct rpc_pipe_client *cli, return werr; } +static WERROR cmd_netlogon_dsr_getforesttrustinfo(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; + WERROR werr = WERR_GENERAL_FAILURE; + const char *server_name = cli->cli->desthost; + const char *trusted_domain_name = NULL; + struct lsa_ForestTrustInformation *info = NULL; + uint32_t flags = 0; + + if (argc < 1 || argc > 4) { + fprintf(stderr, "Usage: %s " + "\n", argv[0]); + return WERR_OK; + } + + if (argc >= 2) { + server_name = argv[1]; + } + + if (argc >= 3) { + trusted_domain_name = argv[2]; + } + + if (argc >= 4) { + sscanf(argv[3], "%x", &flags); + } + + status = rpccli_netr_DsRGetForestTrustInformation(cli, mem_ctx, + server_name, + trusted_domain_name, + flags, + &info, + &werr); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + + if (W_ERROR_IS_OK(werr)) { + printf("success\n"); + } + done: + return werr; +} + + /* List of commands exported by this module */ struct cmd_set netlogon_commands[] = { @@ -706,6 +753,7 @@ struct cmd_set netlogon_commands[] = { { "dsr_getdcnameex", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcnameex, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "dsr_getdcnameex2", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcnameex2, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "dsr_getsitename", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getsitename, PI_NETLOGON, NULL, "Get sitename", "" }, + { "dsr_getforesttrustinfo", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getforesttrustinfo, PI_NETLOGON, NULL, "Get Forest Trust Info", "" }, { "logonctrl", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl, NULL, PI_NETLOGON, NULL, "Logon Control", "" }, { "samsync", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_sync, NULL, PI_NETLOGON, NULL, "Sam Synchronisation", "" }, { "samdeltas", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_deltas, NULL, PI_NETLOGON, NULL, "Query Sam Deltas", "" }, @@ -713,6 +761,7 @@ struct cmd_set netlogon_commands[] = { { "change_trust_pw", RPC_RTYPE_NTSTATUS, cmd_netlogon_change_trust_pw, NULL, PI_NETLOGON, NULL, "Change Trust Account Password", "" }, { "gettrustrid", RPC_RTYPE_WERROR, NULL, cmd_netlogon_gettrustrid, PI_NETLOGON, NULL, "Get trust rid", "" }, { "dsr_enumtrustdom", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_enumtrustdom, PI_NETLOGON, NULL, "Enumerate trusted domains", "" }, + { "deregisterdnsrecords", RPC_RTYPE_WERROR, NULL, cmd_netlogon_deregisterdnsrecords, PI_NETLOGON, NULL, "Deregister DNS records", "" }, { NULL } }; -- cgit From e7b2be804bdee210c64e0f2e54f7395338f42060 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 29 Jan 2008 15:05:56 +0100 Subject: Remove last caller of rpccli_ds_enum_domain_trusts(). I added an alias in rpcclient's netlogon command table. Guenther (This used to be commit 1a900e08e92484407d69661517f08e675a3c352a) --- source3/rpcclient/cmd_netlogon.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 731c3de268..38df7c1660 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -761,6 +761,7 @@ struct cmd_set netlogon_commands[] = { { "change_trust_pw", RPC_RTYPE_NTSTATUS, cmd_netlogon_change_trust_pw, NULL, PI_NETLOGON, NULL, "Change Trust Account Password", "" }, { "gettrustrid", RPC_RTYPE_WERROR, NULL, cmd_netlogon_gettrustrid, PI_NETLOGON, NULL, "Get trust rid", "" }, { "dsr_enumtrustdom", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_enumtrustdom, PI_NETLOGON, NULL, "Enumerate trusted domains", "" }, + { "dsenumdomtrusts", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_enumtrustdom, PI_NETLOGON, NULL, "Enumerate all trusted domains in an AD forest", "" }, { "deregisterdnsrecords", RPC_RTYPE_WERROR, NULL, cmd_netlogon_deregisterdnsrecords, PI_NETLOGON, NULL, "Deregister DNS records", "" }, { NULL } -- cgit From af92bf934ed7614ab0aa41015e296924823a0a5f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 30 Jan 2008 02:08:23 +0100 Subject: Add netrenumtrusteddomains() and netrenumtrusteddomainsex() cmds to rpcclient. Guenther (This used to be commit 6bbe0fde6ebb5c1ea00ea24d3bdbffbf6f246bd6) --- source3/rpcclient/cmd_netlogon.c | 71 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 38df7c1660..aad538a0ee 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -739,6 +739,75 @@ static WERROR cmd_netlogon_dsr_getforesttrustinfo(struct rpc_pipe_client *cli, return werr; } +static WERROR cmd_netlogon_enumtrusteddomains(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; + WERROR werr = WERR_GENERAL_FAILURE; + const char *server_name = cli->cli->desthost; + struct netr_Blob blob; + + + if (argc < 1 || argc > 3) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return WERR_OK; + } + + if (argc >= 2) { + server_name = argv[1]; + } + + status = rpccli_netr_NetrEnumerateTrustedDomains(cli, mem_ctx, + server_name, + &blob, + &werr); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + + if (W_ERROR_IS_OK(werr)) { + printf("success\n"); + dump_data(1, blob.data, blob.length); + } + done: + return werr; +} + +static WERROR cmd_netlogon_enumtrusteddomainsex(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; + WERROR werr = WERR_GENERAL_FAILURE; + const char *server_name = cli->cli->desthost; + struct netr_DomainTrustList list; + + if (argc < 1 || argc > 3) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return WERR_OK; + } + + if (argc >= 2) { + server_name = argv[1]; + } + + status = rpccli_netr_NetrEnumerateTrustedDomainsEx(cli, mem_ctx, + server_name, + &list, + &werr); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + + if (W_ERROR_IS_OK(werr)) { + printf("success\n"); + } + done: + return werr; +} + + /* List of commands exported by this module */ @@ -763,6 +832,8 @@ struct cmd_set netlogon_commands[] = { { "dsr_enumtrustdom", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_enumtrustdom, PI_NETLOGON, NULL, "Enumerate trusted domains", "" }, { "dsenumdomtrusts", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_enumtrustdom, PI_NETLOGON, NULL, "Enumerate all trusted domains in an AD forest", "" }, { "deregisterdnsrecords", RPC_RTYPE_WERROR, NULL, cmd_netlogon_deregisterdnsrecords, PI_NETLOGON, NULL, "Deregister DNS records", "" }, + { "netrenumtrusteddomains", RPC_RTYPE_WERROR, NULL, cmd_netlogon_enumtrusteddomains, PI_NETLOGON, NULL, "Enumerate trusted domains", "" }, + { "netrenumtrusteddomainsex", RPC_RTYPE_WERROR, NULL, cmd_netlogon_enumtrusteddomainsex, PI_NETLOGON, NULL, "Enumerate trusted domains", "" }, { NULL } }; -- cgit From bca0ef0ed769bfbee6e7041aae8256be872813c7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 7 Feb 2008 10:24:18 +0100 Subject: Use rpccli_netr_GetAnyDCName and rpccli_netr_GetDCName everywhere. Guenther (This used to be commit 8abeea9922ac09e7307730ee7695453718356873) --- source3/rpcclient/cmd_netlogon.c | 52 ++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 18 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index aad538a0ee..e1d13d3b1d 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -48,8 +48,9 @@ static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { - char *dcname = NULL; - WERROR result = WERR_GENERAL_FAILURE; + const char *dcname = NULL; + WERROR werr; + NTSTATUS status; int old_timeout; if (argc != 2) { @@ -60,27 +61,35 @@ static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli, /* Make sure to wait for our DC's reply */ old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */ - result = rpccli_netlogon_getanydcname(cli, mem_ctx, cli->cli->desthost, argv[1], &dcname); - + status = rpccli_netr_GetAnyDCName(cli, mem_ctx, + cli->cli->desthost, + argv[1], + &dcname, + &werr); cli_set_timeout(cli->cli, old_timeout); - if (!W_ERROR_IS_OK(result)) - goto done; + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + if (!W_ERROR_IS_OK(werr)) { + return werr; + } /* Display results */ printf("%s\n", dcname); - done: - return result; + return werr; } -static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, int argc, +static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, const char **argv) { - char *dcname = NULL; - WERROR result = WERR_GENERAL_FAILURE; + const char *dcname = NULL; + NTSTATUS status; + WERROR werr; int old_timeout; if (argc != 2) { @@ -91,19 +100,26 @@ static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli, /* Make sure to wait for our DC's reply */ old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */ - result = rpccli_netlogon_getdcname(cli, mem_ctx, cli->cli->desthost, argv[1], &dcname); - + status = rpccli_netr_GetDcName(cli, mem_ctx, + cli->cli->desthost, + argv[1], + &dcname, + &werr); cli_set_timeout(cli->cli, old_timeout); - if (!W_ERROR_IS_OK(result)) - goto done; + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + if (!W_ERROR_IS_OK(werr)) { + return werr; + } /* Display results */ printf("%s\n", dcname); - done: - return result; + return werr; } static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli, -- cgit From 5881a7f679a34253bc5bd55cc2e61c0d36790fd9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 7 Feb 2008 10:39:08 +0100 Subject: Use rpccli_netr_DsRGetSiteName() in rpcclient. Guenther (This used to be commit 609c40fdd9b4c94cdf5b25cd6ac39a2a57432e0d) --- source3/rpcclient/cmd_netlogon.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index e1d13d3b1d..ecd033f39d 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -314,20 +314,27 @@ static WERROR cmd_netlogon_dsr_getsitename(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { - WERROR result; - char *sitename; + WERROR werr; + NTSTATUS status; + const char *sitename = NULL; if (argc != 2) { fprintf(stderr, "Usage: %s computername\n", argv[0]); return WERR_OK; } - result = rpccli_netlogon_dsr_getsitename(cli, mem_ctx, argv[1], &sitename); + status = rpccli_netr_DsRGetSiteName(cli, mem_ctx, + argv[1], + &sitename, + &werr); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } - if (!W_ERROR_IS_OK(result)) { + if (!W_ERROR_IS_OK(werr)) { printf("rpccli_netlogon_dsr_gesitename returned %s\n", - nt_errstr(werror_to_ntstatus(result))); - return result; + nt_errstr(werror_to_ntstatus(werr))); + return werr; } printf("Computer %s is on Site: %s\n", argv[1], sitename); -- cgit From e88eb3ed16ce5ddcf795322cfd2bd6ac555ce5d5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 23:28:02 +0100 Subject: Use rpccli_netr_DsRGetDCName() in rpcclient and winbindd. Guenther (This used to be commit 4f3e97cbae3df8e12db37b8a8a0eaee947fa723a) --- source3/rpcclient/cmd_netlogon.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index ecd033f39d..a752003e8d 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -126,13 +126,14 @@ static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { - WERROR result; + NTSTATUS result; + WERROR werr = WERR_OK; uint32 flags = DS_RETURN_DNS_NAME; const char *server_name = cli->cli->desthost; const char *domain_name; struct GUID domain_guid = GUID_zero(); struct GUID site_guid = GUID_zero(); - struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; + struct netr_DsRGetDCNameInfo *info = NULL; if (argc < 2) { fprintf(stderr, "Usage: %s [domain_name] [domain_guid] " @@ -160,20 +161,25 @@ static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli, debug_dsdcinfo_flags(1,flags); - result = rpccli_netlogon_dsr_getdcname(cli, mem_ctx, server_name, domain_name, - &domain_guid, &site_guid, flags, - &info); + result = rpccli_netr_DsRGetDCName(cli, mem_ctx, + server_name, + domain_name, + &domain_guid, + &site_guid, + flags, + &info, + &werr); - if (W_ERROR_IS_OK(result)) { - d_printf("DsGetDcName gave\n"); - display_ds_domain_controller_info(mem_ctx, info); + if (W_ERROR_IS_OK(werr)) { + d_printf("DsGetDcName gave: %s\n", + NDR_PRINT_STRUCT_STRING(mem_ctx, netr_DsRGetDCNameInfo, info)); return WERR_OK; } printf("rpccli_netlogon_dsr_getdcname returned %s\n", - dos_errstr(result)); + dos_errstr(werr)); - return result; + return werr; } static WERROR cmd_netlogon_dsr_getdcnameex(struct rpc_pipe_client *cli, -- cgit From c6acbc16a6c6dca611a624a5e9c502dfcac92f93 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 30 Jan 2008 23:43:57 +0100 Subject: Use rpccli_netr_LogonControl() in rpcclient. Guenther (This used to be commit d54456f3c42f123af5516c6f75c87b279fdc775f) --- source3/rpcclient/cmd_netlogon.c | 56 ++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 17 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index a752003e8d..b1753575f5 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -348,30 +348,52 @@ static WERROR cmd_netlogon_dsr_getsitename(struct rpc_pipe_client *cli, return WERR_OK; } -static NTSTATUS cmd_netlogon_logon_ctrl(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, int argc, - const char **argv) +static WERROR cmd_netlogon_logon_ctrl(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) { -#if 0 - uint32 query_level = 1; -#endif - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; + WERROR werr; + const char *logon_server = cli->cli->desthost; + enum netr_LogonControlCode function_code = 1; + uint32_t level = 1; + union netr_CONTROL_QUERY_INFORMATION info; + + if (argc > 4) { + fprintf(stderr, "Usage: %s " + "\n", argv[0]); + return WERR_OK; + } - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", argv[0]); - return NT_STATUS_OK; + if (argc >= 2) { + logon_server = argv[1]; } -#if 0 - result = cli_netlogon_logon_ctrl(cli, mem_ctx, query_level); - if (!NT_STATUS_IS_OK(result)) { - goto done; + if (argc >= 3) { + function_code = atoi(argv[2]); + } + + if (argc >= 4) { + level = atoi(argv[3]); + } + + status = rpccli_netr_LogonControl(cli, mem_ctx, + logon_server, + function_code, + level, + &info, + &werr); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + if (!W_ERROR_IS_OK(werr)) { + return werr; } -#endif /* Display results */ - return result; + return werr; } /* Display sam synchronisation information */ @@ -852,7 +874,7 @@ struct cmd_set netlogon_commands[] = { { "dsr_getdcnameex2", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcnameex2, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "dsr_getsitename", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getsitename, PI_NETLOGON, NULL, "Get sitename", "" }, { "dsr_getforesttrustinfo", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getforesttrustinfo, PI_NETLOGON, NULL, "Get Forest Trust Info", "" }, - { "logonctrl", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl, NULL, PI_NETLOGON, NULL, "Logon Control", "" }, + { "logonctrl", RPC_RTYPE_WERROR, NULL, cmd_netlogon_logon_ctrl, PI_NETLOGON, NULL, "Logon Control", "" }, { "samsync", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_sync, NULL, PI_NETLOGON, NULL, "Sam Synchronisation", "" }, { "samdeltas", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_deltas, NULL, PI_NETLOGON, NULL, "Query Sam Deltas", "" }, { "samlogon", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_logon, NULL, PI_NETLOGON, NULL, "Sam Logon", "" }, -- cgit From 6f05330e4a831058d02506d04f89b8cc10fa238b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 22:54:43 +0100 Subject: Fix logonctrl2 command in rpcclient. Guenther (This used to be commit c58be24cd43092e5ebf7aa84f167a5cc8344edfc) --- source3/rpcclient/cmd_netlogon.c | 70 +++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 15 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index b1753575f5..0efee845f4 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -21,27 +21,68 @@ #include "includes.h" #include "rpcclient.h" -static NTSTATUS cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, int argc, - const char **argv) +static WERROR cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) { - uint32 query_level = 1; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; + WERROR werr; + const char *logon_server = cli->cli->desthost; + enum netr_LogonControlCode function_code = NETLOGON_CONTROL_REDISCOVER; + uint32_t level = 1; + union netr_CONTROL_DATA_INFORMATION data; + union netr_CONTROL_QUERY_INFORMATION query; + const char *domain = "BER"; - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", argv[0]); - return NT_STATUS_OK; + if (argc > 5) { + fprintf(stderr, "Usage: %s " + " \n", argv[0]); + return WERR_OK; + } + + if (argc >= 2) { + logon_server = argv[1]; } - result = rpccli_netlogon_logon_ctrl2(cli, mem_ctx, query_level); + if (argc >= 3) { + function_code = atoi(argv[2]); + } - if (!NT_STATUS_IS_OK(result)) - goto done; + if (argc >= 4) { + level = atoi(argv[3]); + } + + if (argc >= 5) { + domain = argv[4]; + } + + switch (function_code) { + case NETLOGON_CONTROL_REDISCOVER: + case NETLOGON_CONTROL_TC_QUERY: + data.domain = domain; + break; + default: + break; + } + + status = rpccli_netr_LogonControl2(cli, mem_ctx, + logon_server, + function_code, + level, + &data, + &query, + &werr); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + if (!W_ERROR_IS_OK(werr)) { + return werr; + } /* Display results */ - done: - return result; + return werr; } static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli, @@ -859,14 +900,13 @@ static WERROR cmd_netlogon_enumtrusteddomainsex(struct rpc_pipe_client *cli, } - /* List of commands exported by this module */ struct cmd_set netlogon_commands[] = { { "NETLOGON" }, - { "logonctrl2", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl2, NULL, PI_NETLOGON, NULL, "Logon Control 2", "" }, + { "logonctrl2", RPC_RTYPE_WERROR, NULL, cmd_netlogon_logon_ctrl2, PI_NETLOGON, NULL, "Logon Control 2", "" }, { "getanydcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getanydcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getdcname, PI_NETLOGON, NULL, "Get trusted PDC name", "" }, { "dsr_getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, -- cgit From f9d992827a0935a21a1bf09a12ffd0146880fdc5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 01:45:07 +0100 Subject: Remove accidential commit. Guenther (This used to be commit 2ab1167e156e989f4b60fcb4dbc7d7eefc64bed0) --- source3/rpcclient/cmd_netlogon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 0efee845f4..ac27d387ce 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -32,7 +32,7 @@ static WERROR cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli, uint32_t level = 1; union netr_CONTROL_DATA_INFORMATION data; union netr_CONTROL_QUERY_INFORMATION query; - const char *domain = "BER"; + const char *domain = lp_workgroup(); if (argc > 5) { fprintf(stderr, "Usage: %s " -- cgit From 013a15a1b8b1b2e410582d6b97831bbb45d06c79 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 13:55:18 +0100 Subject: Use rpccli_netr_DatabaseDeltas() in rpcclient. Guenther (This used to be commit 72ad42fee30242eb57ae0db825127fdb8f9375fd) --- source3/rpcclient/cmd_netlogon.c | 246 +++++++++++++++++++++++++-------------- 1 file changed, 159 insertions(+), 87 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index ac27d387ce..cf52da7c9f 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -439,70 +439,117 @@ static WERROR cmd_netlogon_logon_ctrl(struct rpc_pipe_client *cli, /* Display sam synchronisation information */ -static void display_sam_sync(uint32 num_deltas, SAM_DELTA_HDR *hdr_deltas, - SAM_DELTA_CTR *deltas) +static void display_sam_sync(struct netr_DELTA_ENUM_ARRAY *r) { - fstring name; - uint32 i, j; - - for (i = 0; i < num_deltas; i++) { - switch (hdr_deltas[i].type) { - case SAM_DELTA_DOMAIN_INFO: - unistr2_to_ascii(name, - &deltas[i].domain_info.uni_dom_name, - sizeof(name)); - printf("Domain: %s\n", name); - break; - case SAM_DELTA_GROUP_INFO: - unistr2_to_ascii(name, - &deltas[i].group_info.uni_grp_name, - sizeof(name)); - printf("Group: %s\n", name); - break; - case SAM_DELTA_ACCOUNT_INFO: - unistr2_to_ascii(name, - &deltas[i].account_info.uni_acct_name, - sizeof(name)); - printf("Account: %s\n", name); - break; - case SAM_DELTA_ALIAS_INFO: - unistr2_to_ascii(name, - &deltas[i].alias_info.uni_als_name, - sizeof(name)); - printf("Alias: %s\n", name); - break; - case SAM_DELTA_ALIAS_MEM: { - SAM_ALIAS_MEM_INFO *alias = &deltas[i].als_mem_info; - - for (j = 0; j < alias->num_members; j++) { - fstring sid_str; - - sid_to_fstring(sid_str, &alias->sids[j].sid); - - printf("%s\n", sid_str); - } - break; - } - case SAM_DELTA_GROUP_MEM: { - SAM_GROUP_MEM_INFO *group = &deltas[i].grp_mem_info; - - for (j = 0; j < group->num_members; j++) - printf("rid 0x%x, attrib 0x%08x\n", - group->rids[j], group->attribs[j]); - break; - } - case SAM_DELTA_MODIFIED_COUNT: { - SAM_DELTA_MOD_COUNT *mc = &deltas[i].mod_count; - - printf("sam sequence update: 0x%04x\n", mc->seqnum); - break; - } - default: - printf("unknown delta type 0x%02x\n", - hdr_deltas[i].type); - break; - } - } + uint32_t i, j; + + for (i=0; i < r->num_deltas; i++) { + + union netr_DELTA_UNION u = r->delta_enum[i].delta_union; + union netr_DELTA_ID_UNION id = r->delta_enum[i].delta_id_union; + + switch (r->delta_enum[i].delta_type) { + case NETR_DELTA_DOMAIN: + printf("Domain: %s\n", + u.domain->domain_name.string); + break; + case NETR_DELTA_GROUP: + printf("Group: %s\n", + u.group->group_name.string); + break; + case NETR_DELTA_DELETE_GROUP: + printf("Delete Group: %d\n", + u.delete_account.unknown); + break; + case NETR_DELTA_RENAME_GROUP: + printf("Rename Group: %s -> %s\n", + u.rename_group->OldName.string, + u.rename_group->NewName.string); + break; + case NETR_DELTA_USER: + printf("Account: %s\n", + u.user->account_name.string); + break; + case NETR_DELTA_DELETE_USER: + printf("Delete User: %d\n", + id.rid); + break; + case NETR_DELTA_RENAME_USER: + printf("Rename user: %s -> %s\n", + u.rename_user->OldName.string, + u.rename_user->NewName.string); + break; + case NETR_DELTA_GROUP_MEMBER: + for (j=0; j < u.group_member->num_rids; j++) { + printf("rid 0x%x, attrib 0x%08x\n", + u.group_member->rids[j], + u.group_member->attribs[j]); + } + break; + case NETR_DELTA_ALIAS: + printf("Alias: %s\n", + u.alias->alias_name.string); + break; + case NETR_DELTA_DELETE_ALIAS: + printf("Delete Alias: %d\n", + r->delta_enum[i].delta_id_union.rid); + break; + case NETR_DELTA_RENAME_ALIAS: + printf("Rename alias: %s -> %s\n", + u.rename_alias->OldName.string, + u.rename_alias->NewName.string); + break; + case NETR_DELTA_ALIAS_MEMBER: + for (j=0; j < u.alias_member->sids.num_sids; j++) { + fstring sid_str; + sid_to_fstring(sid_str, + u.alias_member->sids.sids[j].sid); + printf("%s\n", sid_str); + } + break; + case NETR_DELTA_POLICY: + printf("Policy\n"); + break; + case NETR_DELTA_TRUSTED_DOMAIN: + printf("Trusted Domain: %s\n", + u.trusted_domain->domain_name.string); + break; + case NETR_DELTA_DELETE_TRUST: + printf("Delete Trust: %d\n", + u.delete_trust.unknown); + break; + case NETR_DELTA_ACCOUNT: + printf("Account\n"); + break; + case NETR_DELTA_DELETE_ACCOUNT: + printf("Delete Account: %d\n", + u.delete_account.unknown); + break; + case NETR_DELTA_SECRET: + printf("Secret\n"); + break; + case NETR_DELTA_DELETE_SECRET: + printf("Delete Secret: %d\n", + u.delete_secret.unknown); + break; + case NETR_DELTA_DELETE_GROUP2: + printf("Delete Group2: %s\n", + u.delete_group->account_name); + break; + case NETR_DELTA_DELETE_USER2: + printf("Delete User2: %s\n", + u.delete_user->account_name); + break; + case NETR_DELTA_MODIFY_COUNT: + printf("sam sequence update: 0x%016llx\n", + (unsigned long long) *u.modified_count); + break; + default: + printf("unknown delta type 0x%02x\n", + r->delta_enum[i].delta_type); + break; + } + } } /* Perform sam synchronisation */ @@ -534,7 +581,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli, /* Display results */ - display_sam_sync(num_deltas, hdr_deltas, deltas); +/* display_sam_sync(num_deltas, hdr_deltas, deltas); */ done: return result; @@ -542,38 +589,63 @@ static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli, /* Perform sam delta synchronisation */ -static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, int argc, - const char **argv) +static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - uint32 database_id, num_deltas, tmp; - SAM_DELTA_HDR *hdr_deltas; - SAM_DELTA_CTR *deltas; - uint64 seqnum; + uint32_t tmp; + const char *logon_server = cli->cli->desthost; + const char *computername = global_myname(); + struct netr_Authenticator credential; + struct netr_Authenticator return_authenticator; + enum netr_SamDatabaseID database_id = SAM_DATABASE_DOMAIN; + uint64_t sequence_num; + + if (argc != 3) { + fprintf(stderr, "Usage: %s database_id seqnum\n", argv[0]); + return NT_STATUS_OK; + } - if (argc != 3) { - fprintf(stderr, "Usage: %s database_id seqnum\n", argv[0]); - return NT_STATUS_OK; - } + database_id = atoi(argv[1]); + tmp = atoi(argv[2]); - database_id = atoi(argv[1]); - tmp = atoi(argv[2]); + sequence_num = tmp & 0xffff; - seqnum = tmp & 0xffff; + do { + struct netr_DELTA_ENUM_ARRAY *delta_enum_array = NULL; - result = rpccli_netlogon_sam_deltas(cli, mem_ctx, database_id, - seqnum, &num_deltas, - &hdr_deltas, &deltas); + netlogon_creds_client_step(cli->dc, &credential); - if (!NT_STATUS_IS_OK(result)) - goto done; + result = rpccli_netr_DatabaseDeltas(cli, mem_ctx, + logon_server, + computername, + &credential, + &return_authenticator, + database_id, + &sequence_num, + &delta_enum_array, + 0xffff); - /* Display results */ + /* Check returned credentials. */ + if (!netlogon_creds_client_check(cli->dc, + &return_authenticator.cred)) { + DEBUG(0,("credentials chain check failed\n")); + return NT_STATUS_ACCESS_DENIED; + } + + if (NT_STATUS_IS_ERR(result)) { + break; + } + + /* Display results */ + + display_sam_sync(delta_enum_array); + + TALLOC_FREE(delta_enum_array); + + } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)); - display_sam_sync(num_deltas, hdr_deltas, deltas); - - done: return result; } -- cgit From eafec423b78f91f97793e26b6dd0c2a27c557d19 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 14:11:20 +0100 Subject: Use rpccli_netr_DatabaseSync2() in rpcclient. Guenther (This used to be commit 042173b00e023b4d4e7739524e24baa8803850bd) --- source3/rpcclient/cmd_netlogon.c | 59 ++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 15 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index cf52da7c9f..49098b12e4 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -554,37 +554,66 @@ static void display_sam_sync(struct netr_DELTA_ENUM_ARRAY *r) /* Perform sam synchronisation */ -static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli, +static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - uint32 database_id = 0, num_deltas; - SAM_DELTA_HDR *hdr_deltas; - SAM_DELTA_CTR *deltas; + const char *logon_server = cli->cli->desthost; + const char *computername = global_myname(); + struct netr_Authenticator credential; + struct netr_Authenticator return_authenticator; + enum netr_SamDatabaseID database_id = SAM_DATABASE_DOMAIN; + uint16_t restart_state = 0; + uint32_t sync_context = 0; if (argc > 2) { fprintf(stderr, "Usage: %s [database_id]\n", argv[0]); return NT_STATUS_OK; } - if (argc == 2) - database_id = atoi(argv[1]); + if (argc == 2) { + database_id = atoi(argv[1]); + } + + /* Synchronise sam database */ + + do { + struct netr_DELTA_ENUM_ARRAY *delta_enum_array = NULL; - /* Synchronise sam database */ + netlogon_creds_client_step(cli->dc, &credential); - result = rpccli_netlogon_sam_sync(cli, mem_ctx, database_id, - 0, &num_deltas, &hdr_deltas, &deltas); + result = rpccli_netr_DatabaseSync2(cli, mem_ctx, + logon_server, + computername, + &credential, + &return_authenticator, + database_id, + restart_state, + &sync_context, + &delta_enum_array, + 0xffff); - if (!NT_STATUS_IS_OK(result)) - goto done; + /* Check returned credentials. */ + if (!netlogon_creds_client_check(cli->dc, + &return_authenticator.cred)) { + DEBUG(0,("credentials chain check failed\n")); + return NT_STATUS_ACCESS_DENIED; + } - /* Display results */ + if (NT_STATUS_IS_ERR(result)) { + break; + } -/* display_sam_sync(num_deltas, hdr_deltas, deltas); */ + /* Display results */ - done: - return result; + display_sam_sync(delta_enum_array); + + TALLOC_FREE(delta_enum_array); + + } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)); + + return result; } /* Perform sam delta synchronisation */ -- cgit From 7269a504fdd06fbbe24c2df8e084b41382d71269 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 19:38:48 +0100 Subject: Add my copyright. Guenther (This used to be commit d078a8757182d84dfd3307a2e1b751cf173aaa97) --- source3/rpcclient/cmd_netlogon.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 49098b12e4..95d79b5825 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -3,6 +3,7 @@ RPC pipe client Copyright (C) Tim Potter 2000 + Copyright (C) Guenther Deschner 2008 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 -- cgit From 2a2188591b5ed922d09dc723adcf10f8b8f5e5a0 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 19 Apr 2008 21:56:43 +0200 Subject: Add "desthost" to rpc_pipe_client This reduces the dependency on cli_state (This used to be commit 783afab9c891dd7bcb78895b2a639b6f3a0edf5b) --- source3/rpcclient/cmd_netlogon.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 95d79b5825..a30dd740e2 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -28,7 +28,7 @@ static WERROR cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli, { NTSTATUS status = NT_STATUS_UNSUCCESSFUL; WERROR werr; - const char *logon_server = cli->cli->desthost; + const char *logon_server = cli->desthost; enum netr_LogonControlCode function_code = NETLOGON_CONTROL_REDISCOVER; uint32_t level = 1; union netr_CONTROL_DATA_INFORMATION data; @@ -104,7 +104,7 @@ static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli, old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */ status = rpccli_netr_GetAnyDCName(cli, mem_ctx, - cli->cli->desthost, + cli->desthost, argv[1], &dcname, &werr); @@ -143,7 +143,7 @@ static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli, old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */ status = rpccli_netr_GetDcName(cli, mem_ctx, - cli->cli->desthost, + cli->desthost, argv[1], &dcname, &werr); @@ -171,7 +171,7 @@ static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli, NTSTATUS result; WERROR werr = WERR_OK; uint32 flags = DS_RETURN_DNS_NAME; - const char *server_name = cli->cli->desthost; + const char *server_name = cli->desthost; const char *domain_name; struct GUID domain_guid = GUID_zero(); struct GUID site_guid = GUID_zero(); @@ -231,7 +231,7 @@ static WERROR cmd_netlogon_dsr_getdcnameex(struct rpc_pipe_client *cli, WERROR result; NTSTATUS status; uint32_t flags = DS_RETURN_DNS_NAME; - const char *server_name = cli->cli->desthost; + const char *server_name = cli->desthost; const char *domain_name; const char *site_name = NULL; struct GUID domain_guid = GUID_zero(); @@ -290,7 +290,7 @@ static WERROR cmd_netlogon_dsr_getdcnameex2(struct rpc_pipe_client *cli, WERROR result; NTSTATUS status; uint32_t flags = DS_RETURN_DNS_NAME; - const char *server_name = cli->cli->desthost; + const char *server_name = cli->desthost; const char *domain_name = NULL; const char *client_account = NULL; uint32_t mask = 0; @@ -396,7 +396,7 @@ static WERROR cmd_netlogon_logon_ctrl(struct rpc_pipe_client *cli, { NTSTATUS status = NT_STATUS_UNSUCCESSFUL; WERROR werr; - const char *logon_server = cli->cli->desthost; + const char *logon_server = cli->desthost; enum netr_LogonControlCode function_code = 1; uint32_t level = 1; union netr_CONTROL_QUERY_INFORMATION info; @@ -560,7 +560,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli, const char **argv) { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - const char *logon_server = cli->cli->desthost; + const char *logon_server = cli->desthost; const char *computername = global_myname(); struct netr_Authenticator credential; struct netr_Authenticator return_authenticator; @@ -625,7 +625,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli, { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; uint32_t tmp; - const char *logon_server = cli->cli->desthost; + const char *logon_server = cli->desthost; const char *computername = global_myname(); struct netr_Authenticator credential; struct netr_Authenticator return_authenticator; @@ -759,7 +759,7 @@ static WERROR cmd_netlogon_gettrustrid(struct rpc_pipe_client *cli, { NTSTATUS status = NT_STATUS_UNSUCCESSFUL; WERROR werr = WERR_GENERAL_FAILURE; - const char *server_name = cli->cli->desthost; + const char *server_name = cli->desthost; const char *domain_name = lp_workgroup(); uint32_t rid = 0; @@ -799,7 +799,7 @@ static WERROR cmd_netlogon_dsr_enumtrustdom(struct rpc_pipe_client *cli, { NTSTATUS status = NT_STATUS_UNSUCCESSFUL; WERROR werr = WERR_GENERAL_FAILURE; - const char *server_name = cli->cli->desthost; + const char *server_name = cli->desthost; uint32_t trust_flags = NETR_TRUST_FLAG_IN_FOREST; struct netr_DomainTrustList trusts; @@ -847,7 +847,7 @@ static WERROR cmd_netlogon_deregisterdnsrecords(struct rpc_pipe_client *cli, { NTSTATUS status = NT_STATUS_UNSUCCESSFUL; WERROR werr = WERR_GENERAL_FAILURE; - const char *server_name = cli->cli->desthost; + const char *server_name = cli->desthost; const char *domain = lp_workgroup(); const char *dns_host = NULL; @@ -893,7 +893,7 @@ static WERROR cmd_netlogon_dsr_getforesttrustinfo(struct rpc_pipe_client *cli, { NTSTATUS status = NT_STATUS_UNSUCCESSFUL; WERROR werr = WERR_GENERAL_FAILURE; - const char *server_name = cli->cli->desthost; + const char *server_name = cli->desthost; const char *trusted_domain_name = NULL; struct lsa_ForestTrustInformation *info = NULL; uint32_t flags = 0; @@ -939,7 +939,7 @@ static WERROR cmd_netlogon_enumtrusteddomains(struct rpc_pipe_client *cli, { NTSTATUS status = NT_STATUS_UNSUCCESSFUL; WERROR werr = WERR_GENERAL_FAILURE; - const char *server_name = cli->cli->desthost; + const char *server_name = cli->desthost; struct netr_Blob blob; @@ -974,7 +974,7 @@ static WERROR cmd_netlogon_enumtrusteddomainsex(struct rpc_pipe_client *cli, { NTSTATUS status = NT_STATUS_UNSUCCESSFUL; WERROR werr = WERR_GENERAL_FAILURE; - const char *server_name = cli->cli->desthost; + const char *server_name = cli->desthost; struct netr_DomainTrustList list; if (argc < 1 || argc > 3) { -- cgit From e1102b8f48aeebe7d4e730d2b432a1503b425210 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 19 Apr 2008 23:27:35 +0200 Subject: Introduce rpccli_set_timeout() Reduce dependency on "cli" member of rpc_pipe_client struct (This used to be commit 2e4c1ba38963cffe4c3f25ab24bc28975f2fc291) --- source3/rpcclient/cmd_netlogon.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index a30dd740e2..12d8cf3052 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -101,14 +101,15 @@ static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli, } /* Make sure to wait for our DC's reply */ - old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */ + old_timeout = rpccli_set_timeout(cli, 30000); /* 30 seconds. */ + rpccli_set_timeout(cli, MAX(old_timeout, 30000)); /* At least 30 sec */ status = rpccli_netr_GetAnyDCName(cli, mem_ctx, cli->desthost, argv[1], &dcname, &werr); - cli_set_timeout(cli->cli, old_timeout); + rpccli_set_timeout(cli, old_timeout); if (!NT_STATUS_IS_OK(status)) { return ntstatus_to_werror(status); @@ -140,14 +141,15 @@ static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli, } /* Make sure to wait for our DC's reply */ - old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */ + old_timeout = rpccli_set_timeout(cli, 30000); /* 30 seconds. */ + rpccli_set_timeout(cli, MAX(30000, old_timeout)); /* At least 30 sec */ status = rpccli_netr_GetDcName(cli, mem_ctx, cli->desthost, argv[1], &dcname, &werr); - cli_set_timeout(cli->cli, old_timeout); + rpccli_set_timeout(cli, old_timeout); if (!NT_STATUS_IS_OK(status)) { return ntstatus_to_werror(status); -- cgit From 82b5f54f96b1161b8357a69b985c75f2853573ef Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Jul 2008 18:17:52 +0200 Subject: Refactoring: rpcclient uses ndr_syntax_id instead of pipe_idx (This used to be commit 85db87c451dacf80e9575c04e9e08c625b3f1199) --- source3/rpcclient/cmd_netlogon.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'source3/rpcclient/cmd_netlogon.c') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 12d8cf3052..87ba65c14b 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -1010,25 +1010,25 @@ struct cmd_set netlogon_commands[] = { { "NETLOGON" }, - { "logonctrl2", RPC_RTYPE_WERROR, NULL, cmd_netlogon_logon_ctrl2, PI_NETLOGON, NULL, "Logon Control 2", "" }, - { "getanydcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getanydcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, - { "getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getdcname, PI_NETLOGON, NULL, "Get trusted PDC name", "" }, - { "dsr_getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, - { "dsr_getdcnameex", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcnameex, PI_NETLOGON, NULL, "Get trusted DC name", "" }, - { "dsr_getdcnameex2", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcnameex2, PI_NETLOGON, NULL, "Get trusted DC name", "" }, - { "dsr_getsitename", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getsitename, PI_NETLOGON, NULL, "Get sitename", "" }, - { "dsr_getforesttrustinfo", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getforesttrustinfo, PI_NETLOGON, NULL, "Get Forest Trust Info", "" }, - { "logonctrl", RPC_RTYPE_WERROR, NULL, cmd_netlogon_logon_ctrl, PI_NETLOGON, NULL, "Logon Control", "" }, - { "samsync", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_sync, NULL, PI_NETLOGON, NULL, "Sam Synchronisation", "" }, - { "samdeltas", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_deltas, NULL, PI_NETLOGON, NULL, "Query Sam Deltas", "" }, - { "samlogon", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_logon, NULL, PI_NETLOGON, NULL, "Sam Logon", "" }, - { "change_trust_pw", RPC_RTYPE_NTSTATUS, cmd_netlogon_change_trust_pw, NULL, PI_NETLOGON, NULL, "Change Trust Account Password", "" }, - { "gettrustrid", RPC_RTYPE_WERROR, NULL, cmd_netlogon_gettrustrid, PI_NETLOGON, NULL, "Get trust rid", "" }, - { "dsr_enumtrustdom", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_enumtrustdom, PI_NETLOGON, NULL, "Enumerate trusted domains", "" }, - { "dsenumdomtrusts", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_enumtrustdom, PI_NETLOGON, NULL, "Enumerate all trusted domains in an AD forest", "" }, - { "deregisterdnsrecords", RPC_RTYPE_WERROR, NULL, cmd_netlogon_deregisterdnsrecords, PI_NETLOGON, NULL, "Deregister DNS records", "" }, - { "netrenumtrusteddomains", RPC_RTYPE_WERROR, NULL, cmd_netlogon_enumtrusteddomains, PI_NETLOGON, NULL, "Enumerate trusted domains", "" }, - { "netrenumtrusteddomainsex", RPC_RTYPE_WERROR, NULL, cmd_netlogon_enumtrusteddomainsex, PI_NETLOGON, NULL, "Enumerate trusted domains", "" }, + { "logonctrl2", RPC_RTYPE_WERROR, NULL, cmd_netlogon_logon_ctrl2, &ndr_table_netlogon.syntax_id, NULL, "Logon Control 2", "" }, + { "getanydcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getanydcname, &ndr_table_netlogon.syntax_id, NULL, "Get trusted DC name", "" }, + { "getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getdcname, &ndr_table_netlogon.syntax_id, NULL, "Get trusted PDC name", "" }, + { "dsr_getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcname, &ndr_table_netlogon.syntax_id, NULL, "Get trusted DC name", "" }, + { "dsr_getdcnameex", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcnameex, &ndr_table_netlogon.syntax_id, NULL, "Get trusted DC name", "" }, + { "dsr_getdcnameex2", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcnameex2, &ndr_table_netlogon.syntax_id, NULL, "Get trusted DC name", "" }, + { "dsr_getsitename", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getsitename, &ndr_table_netlogon.syntax_id, NULL, "Get sitename", "" }, + { "dsr_getforesttrustinfo", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getforesttrustinfo, &ndr_table_netlogon.syntax_id, NULL, "Get Forest Trust Info", "" }, + { "logonctrl", RPC_RTYPE_WERROR, NULL, cmd_netlogon_logon_ctrl, &ndr_table_netlogon.syntax_id, NULL, "Logon Control", "" }, + { "samsync", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_sync, NULL, &ndr_table_netlogon.syntax_id, NULL, "Sam Synchronisation", "" }, + { "samdeltas", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_deltas, NULL, &ndr_table_netlogon.syntax_id, NULL, "Query Sam Deltas", "" }, + { "samlogon", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_logon, NULL, &ndr_table_netlogon.syntax_id, NULL, "Sam Logon", "" }, + { "change_trust_pw", RPC_RTYPE_NTSTATUS, cmd_netlogon_change_trust_pw, NULL, &ndr_table_netlogon.syntax_id, NULL, "Change Trust Account Password", "" }, + { "gettrustrid", RPC_RTYPE_WERROR, NULL, cmd_netlogon_gettrustrid, &ndr_table_netlogon.syntax_id, NULL, "Get trust rid", "" }, + { "dsr_enumtrustdom", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_enumtrustdom, &ndr_table_netlogon.syntax_id, NULL, "Enumerate trusted domains", "" }, + { "dsenumdomtrusts", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_enumtrustdom, &ndr_table_netlogon.syntax_id, NULL, "Enumerate all trusted domains in an AD forest", "" }, + { "deregisterdnsrecords", RPC_RTYPE_WERROR, NULL, cmd_netlogon_deregisterdnsrecords, &ndr_table_netlogon.syntax_id, NULL, "Deregister DNS records", "" }, + { "netrenumtrusteddomains", RPC_RTYPE_WERROR, NULL, cmd_netlogon_enumtrusteddomains, &ndr_table_netlogon.syntax_id, NULL, "Enumerate trusted domains", "" }, + { "netrenumtrusteddomainsex", RPC_RTYPE_WERROR, NULL, cmd_netlogon_enumtrusteddomainsex, &ndr_table_netlogon.syntax_id, NULL, "Enumerate trusted domains", "" }, { NULL } }; -- cgit