From 75c346e70c83f7386ecd2f10fe155c4a4dfd47de Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Sat, 7 Oct 2000 15:56:36 +0000 Subject: added samr_set_user_info and info_2. cleanup of create_user cleanup of rid/sid mix in samr. now we only have sid. some prs_align() missing in parse_samr.c a small debug change in srv_pipe.c You still can't change a user's password in this commit. Will be availble in the next one. J.F. (This used to be commit b655bc281fa183b1827a946ada1fcf500fb93aea) --- source3/libsmb/smbencrypt.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'source3/libsmb/smbencrypt.c') diff --git a/source3/libsmb/smbencrypt.c b/source3/libsmb/smbencrypt.c index b927e193dd..16f2493947 100644 --- a/source3/libsmb/smbencrypt.c +++ b/source3/libsmb/smbencrypt.c @@ -228,3 +228,47 @@ BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[ return True; } +/*********************************************************** + decode a password buffer +************************************************************/ +BOOL decode_pw_buffer(const char buffer[516], char *new_pwrd, + int new_pwrd_size, uint32 *new_pw_len) +{ + int uni_pw_len=0; + char *pw; + /* + Warning !!! : This function is called from some rpc call. + The password IN the buffer is a UNICODE string. + The password IN new_pwrd is an ASCII string + If you reuse that code somewhere else check first. + */ + + + /* + * The length of the new password is in the last 4 bytes of + * the data buffer. + */ + + *new_pw_len = IVAL(buffer, 512); + +#ifdef DEBUG_PASSWORD + dump_data(100, buffer, 516); +#endif + + if ((*new_pw_len) < 0 || (*new_pw_len) > new_pwrd_size - 1) { + DEBUG(0, ("decode_pw_buffer: incorrect password length (%d).\n", (*new_pw_len))); + return False; + } + + uni_pw_len = *new_pw_len; + *new_pw_len /= 2; + pw = dos_unistrn2((uint16 *)(&buffer[512 - uni_pw_len]), uni_pw_len); + memcpy(new_pwrd, pw, *new_pw_len + 1); + +#ifdef DEBUG_PASSWORD + dump_data(100, new_pwrd, (*new_pw_len)); +#endif + + return True; +} + -- cgit