diff options
Diffstat (limited to 'source3/rpc_client')
-rw-r--r-- | source3/rpc_client/cli_connect.c | 42 | ||||
-rw-r--r-- | source3/rpc_client/cli_login.c | 28 |
2 files changed, 64 insertions, 6 deletions
diff --git a/source3/rpc_client/cli_connect.c b/source3/rpc_client/cli_connect.c index fc6f5c8c44..6b7fba41c5 100644 --- a/source3/rpc_client/cli_connect.c +++ b/source3/rpc_client/cli_connect.c @@ -50,6 +50,20 @@ void init_connections(void) num_cons = 0; } +static void free_con_array(uint32 num_entries, struct cli_connection **entries) +{ + void(*fn)(void*) = (void(*)(void*))&cli_connection_free; + free_void_array(num_entries, (void**)entries, *fn); +} + +static struct cli_connection* add_con_to_array(uint32 *len, + struct cli_connection ***array, + struct cli_connection *con) +{ + return (struct cli_connection*)add_item_to_array(len, + (void***)array, (void*)con); + +} void free_connections(void) { free_con_array(num_cons, con_list); @@ -286,6 +300,10 @@ policy handle. ****************************************************************************/ BOOL cli_get_con_sesskey(struct cli_connection *con, uchar sess_key[16]) { + if (con == NULL) + { + return False; + } memcpy(sess_key, con->cli->sess_key, sizeof(con->cli->sess_key)); return True; @@ -295,6 +313,30 @@ BOOL cli_get_con_sesskey(struct cli_connection *con, uchar sess_key[16]) get a user session key associated with a connection associated with a policy handle. ****************************************************************************/ +BOOL cli_con_get_srvname(struct cli_connection *con, char *srv_name) +{ + if (con == NULL) + { + return False; + } + + if (strnequal("\\\\", con->cli->desthost, 2)) + { + fstrcpy(srv_name, con->cli->desthost); + } + else + { + fstrcpy(srv_name, "\\\\"); + fstrcat(srv_name, con->cli->desthost); + } + + return True; +} + +/**************************************************************************** +get a user session key associated with a connection associated with a +policy handle. +****************************************************************************/ BOOL cli_get_sesskey(const POLICY_HND *pol, uchar sess_key[16]) { struct cli_connection *con = NULL; diff --git a/source3/rpc_client/cli_login.c b/source3/rpc_client/cli_login.c index 6bb9fed063..832731d92d 100644 --- a/source3/rpc_client/cli_login.c +++ b/source3/rpc_client/cli_login.c @@ -29,10 +29,11 @@ extern int DEBUGLEVEL; Initialize domain session credentials. ****************************************************************************/ -uint32 cli_nt_setup_creds( const char* srv_name, const char* myhostname, +uint32 cli_nt_setup_creds( char* servers, const char* myhostname, const char* trust_acct, unsigned char trust_pwd[16], - uint16 sec_chan) + uint16 sec_chan, + char *srv_name) { DOM_CHAL clnt_chal; DOM_CHAL srv_chal; @@ -41,12 +42,25 @@ uint32 cli_nt_setup_creds( const char* srv_name, const char* myhostname, uint8 sess_key[16]; DOM_CRED clnt_cred; + /******************* make connection **********************/ + struct cli_connection *con = NULL; + + if (!cli_connection_init_list(servers, PIPE_NETLOGON, &con)) + { + return False; + } + + if (!cli_con_get_srvname(con, srv_name)) + { + return False; + } + /******************* Request Challenge ********************/ generate_random_buffer( clnt_chal.data, 8, False); /* send a client challenge; receive a server challenge */ - ret = cli_net_req_chal(srv_name, myhostname, &clnt_chal, &srv_chal); + ret = cli_net_req_chal(servers, myhostname, &clnt_chal, &srv_chal); if (ret != 0) { DEBUG(1,("cli_nt_setup_creds: request challenge failed\n")); @@ -233,7 +247,7 @@ BOOL cli_nt_logoff(const char* srv_name, const char* myhostname, /**************************************************************************** NT SAM database sync ****************************************************************************/ -BOOL net_sam_sync(const char* srv_name, const char* myhostname, +BOOL net_sam_sync(char* servers, const char* myhostname, const char* trust_acct, uchar trust_passwd[16], SAM_DELTA_HDR hdr_deltas[MAX_SAM_DELTAS], @@ -241,15 +255,17 @@ BOOL net_sam_sync(const char* srv_name, const char* myhostname, uint32 *num_deltas) { BOOL res = True; + fstring srv_name; *num_deltas = 0; DEBUG(5,("Attempting SAM sync with PDC: %s\n", srv_name)); - res = res ? cli_nt_setup_creds( srv_name, myhostname, + res = res ? cli_nt_setup_creds( servers, myhostname, trust_acct, - trust_passwd, SEC_CHAN_BDC) == 0x0 : False; + trust_passwd, SEC_CHAN_BDC, + srv_name) == 0x0 : False; memset(trust_passwd, 0, 16); |