summaryrefslogtreecommitdiff
path: root/source3/rpc_client/cli_login.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-04-28 01:24:40 +0000
committerJeremy Allison <jra@samba.org>1998-04-28 01:24:40 +0000
commit22abe47e29bf25a52e39026d03e38b49bab25ac9 (patch)
tree7b0eae817e17fe6817a3ef4a52d52f64389d4423 /source3/rpc_client/cli_login.c
parentb8fff2cc4e3d2903bc009bf2f46459855dad526e (diff)
downloadsamba-22abe47e29bf25a52e39026d03e38b49bab25ac9.tar.gz
samba-22abe47e29bf25a52e39026d03e38b49bab25ac9.tar.bz2
samba-22abe47e29bf25a52e39026d03e38b49bab25ac9.zip
First version that compiles. Much more to do.....
Jeremy. (This used to be commit 45393a19adb31820725fbdfaaf7ab64793fc9bc5)
Diffstat (limited to 'source3/rpc_client/cli_login.c')
-rw-r--r--source3/rpc_client/cli_login.c132
1 files changed, 35 insertions, 97 deletions
diff --git a/source3/rpc_client/cli_login.c b/source3/rpc_client/cli_login.c
index ad176ffe8f..fe00c39e4c 100644
--- a/source3/rpc_client/cli_login.c
+++ b/source3/rpc_client/cli_login.c
@@ -24,6 +24,8 @@
#include "nterr.h"
extern int DEBUGLEVEL;
+extern fstring global_myworkgroup;
+extern pstring global_myname;
/****************************************************************************
Initialize domain session credentials.
@@ -34,17 +36,8 @@ BOOL cli_nt_setup_creds(struct cli_state *cli, unsigned char mach_pwd[16])
DOM_CHAL clnt_chal;
DOM_CHAL srv_chal;
- DOM_CHAL auth2_srv_chal;
-
UTIME zerotime;
- RPC_IFACE abstract;
- RPC_IFACE transfer;
-
- /******************** initialise ********************************/
-
- zerotime.time = 0;
-
/******************* Request Challenge ********************/
generate_random_buffer( clnt_chal.data, 8, False);
@@ -52,26 +45,30 @@ BOOL cli_nt_setup_creds(struct cli_state *cli, unsigned char mach_pwd[16])
/* send a client challenge; receive a server challenge */
if (!cli_net_req_chal(cli, &clnt_chal, &srv_chal))
{
- DEBUG(0,("do_nt_session_open: request challenge failed\n"));
+ DEBUG(0,("cli_nt_setup_creds: request challenge failed\n"));
return False;
}
/**************** Long-term Session key **************/
/* calculate the session key */
- cred_session_key(&clnt_chal, &srv_chal, mach_pwd, sess_key);
- bzero(sess_key+8, 8);
+ cred_session_key(&clnt_chal, &srv_chal, mach_pwd, cli->sess_key);
+ bzero(cli->sess_key+8, 8);
/******************* Authenticate 2 ********************/
/* calculate auth-2 credentials */
- cred_create(sess_key, &clnt_chal, zerotime, &(clnt_cred->challenge));
+ zerotime.time = 0;
+ cred_create(cli->sess_key, &clnt_chal, zerotime, &(cli->clnt_cred.challenge));
+
+ /*
+ * Send client auth-2 challenge.
+ * Receive an auth-2 challenge response and check it.
+ */
- /* send client auth-2 challenge; receive an auth-2 challenge */
- if (!cli_net_auth2(cli, SEC_CHAN_WKSTA, 0x000001ff,
- &(cli->clnt_cred->challenge), &auth2_srv_chal))
+ if (!cli_net_auth2(cli, SEC_CHAN_WKSTA, 0x000001ff, &srv_chal))
{
- DEBUG(0,("do_nt_session_open: auth2 challenge failed\n"));
+ DEBUG(0,("cli_nt_setup_creds: auth2 challenge failed\n"));
return False;
}
@@ -128,7 +125,7 @@ BOOL do_nt_srv_pwset(struct cli_state *cli,
void make_nt_login_interactive(NET_ID_INFO_CTR *ctr,
uchar sess_key[16],
- char *workgroup, char *myhostname,
+ char *domain, char *myhostname,
uint32 smb_userid, char *username)
{
/****************** SAM Info Preparation *******************/
@@ -154,103 +151,44 @@ void make_nt_login_interactive(NET_ID_INFO_CTR *ctr,
ctr->switch_value = 1;
/* this is used in both the SAM Logon and the SAM Logoff */
- make_id_info1(&ctr->auth.id1, workgroup, 0,
+ make_id_info1(&ctr->auth.id1, domain, 0,
smb_userid, 0, username, myhostname,
sess_key, lm_owf_user_pwd, nt_owf_user_pwd);
}
#endif
/****************************************************************************
- make network sam login info
- ****************************************************************************/
-
-void make_nt_login_network(NET_ID_INFO_CTR *ctr, uint32 smb_userid, char *username,
- char lm_chal[8], char lm_chal_resp[24],
- char nt_chal_resp[24])
-{
- /* indicate a "network" login */
- ctr->switch_value = 2;
-
- /* this is used in both the SAM Logon and the SAM Logoff */
- make_id_info2(&ctr->auth.id2, myworkgroup, 0, smb_userid, 0,
- username, myhostname,
- lm_chal, lm_chal_resp, nt_chal_resp);
-}
-
-/****************************************************************************
NT login.
****************************************************************************/
-BOOL cli_nt_login(struct cli_state *cli,
- DOM_CRED *clnt_cred, DOM_CRED *rtn_cred,
- NET_ID_INFO_CTR *ctr, NET_USER_INFO_3 *user_info3)
+BOOL cli_nt_login_network(struct cli_state *cli, char *domain, char *username,
+ uint32 smb_userid_low, char lm_chal[8], char lm_chal_resp[24],
+ char nt_chal_resp[24],
+ NET_ID_INFO_CTR *ctr, NET_USER_INFO_3 *user_info3)
{
- DOM_CRED sam_logon_rtn_cred;
- DOM_CRED cred;
- fstring dest_srv;
- fstring my_host_name;
+ DEBUG(5,("cli_nt_login_network: %d\n", __LINE__));
- DEBUG(5,("do_nt_login: %d\n", __LINE__));
-
- /*********************** SAM Logon **********************/
-
- cli->clnt_cred->timestamp.time = time(NULL);
-
- memcpy(&cred, cli->clnt_cred, sizeof(cred));
-
- /* calculate sam logon credentials */
- cred_create(sess_key, &(cli->clnt_cred->challenge),
- cred.timestamp, &(cred.challenge));
-
- strcpy(dest_srv, "\\\\");
- strcat(dest_srv, dest_host);
- strupper(dest_srv);
+ /* indicate a "network" login */
+ ctr->switch_value = NET_LOGON_TYPE;
- fstrcpy(my_host_name, myhostname);
- strupper(my_host_name);
+ /* Create the structure needed for SAM logon. */
+ make_id_info2(&ctr->auth.id2, domain, 0,
+ smb_userid_low, 0,
+ username, global_myname,
+ lm_chal, lm_chal_resp, nt_chal_resp);
- /* send client sam-logon challenge */
- return cli_net_sam_logon(cli, dest_srv, my_host_name,
- &cred, &sam_logon_rtn_cred,
- ctr->switch_value, ctr, 3, user_info3,
- rtn_cred);
+ /* Send client sam-logon request - update credentials on success. */
+ return cli_net_sam_logon(cli, ctr, user_info3);
}
/****************************************************************************
-nt sam logoff
+NT Logoff.
****************************************************************************/
-BOOL cli_nt_logoff(struct cli_state *cli, DOM_CRED *rtn_cred,
- NET_ID_INFO_CTR *ctr, char *dest_host, char *myhostname)
+BOOL cli_nt_logoff(struct cli_state *cli, NET_ID_INFO_CTR *ctr)
{
- DOM_CRED sam_logoff_rtn_cred;
- DOM_CRED cred;
- fstring dest_srv;
- fstring my_host_name;
-
- DEBUG(5,("do_nt_logoff: %d\n", __LINE__));
-
- /*********************** SAM Logoff *********************/
-
- clnt_cred->timestamp.time = time(NULL);
-
- memcpy(&cred, cli->clnt_cred, sizeof(cred));
-
- /* calculate sam logoff credentials */
- cred_create(sess_key, &(cli->clnt_cred->challenge),
- cred.timestamp, &(cred.challenge));
-
- strcpy(dest_srv, "\\\\");
- strcat(dest_srv, dest_host);
- strupper(dest_srv);
-
- fstrcpy(my_host_name, myhostname);
- strupper(my_host_name);
+ DEBUG(5,("cli_nt_logoff: %d\n", __LINE__));
- /* send client sam-logoff challenge; receive a sam-logoff challenge */
- return cli_net_sam_logoff(cli, fnum, sess_key, clnt_cred,
- dest_srv, my_host_name,
- &cred, &sam_logoff_rtn_cred,
- ctr->switch_value, ctr, 3,
- rtn_cred);
+ /* Send client sam-logoff request - update credentials on success. */
+ return cli_net_sam_logoff(cli, ctr);
}