PDA

View Full Version : change password programmatically


denniss
21 Aug 2006, 21:07
Hi,

I'm using vB 3.5.4. I want to change a user's password 'programmatically' (ie from a php program on the same host, but outside vB).

How do I do that?

Dennis

Billspaintball
24 Aug 2006, 02:39
Hi,

I'm using vB 3.5.4. I want to change a user's password 'programmatically' (ie from a php program on the same host, but outside vB).

How do I do that?

Dennis
You cant.

The vB password is encripted.
If you try and change it outside of vB, then vB will not authenticate the new password.

Zachery
24 Aug 2006, 06:13
You cant.

The vB password is encripted.
If you try and change it outside of vB, then vB will not authenticate the new password.
This is not true, the password is _not_ encrypted, its hashed twice with a salt once.



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



i believe I've got marco to thank for this one.

Billspaintball
24 Aug 2006, 08:20
This is not true, the password is _not_ encrypted, its hashed twice with a salt once.
Sorry, bad choice of term on my part.
Maybe I should have just said its not plain text.

denniss
25 Aug 2006, 18:47
By 'outside vB' I mean programmatically through the vB API, but not a vB page per se.

so I am trying to use a function to change the password and I get this error:

Fatal error: Call to a member function query_first() on a non-object in /usr/local/apache/htdocs/forum/includes/functions.php on line 1600

the function body is this:

function changepassword($newpw) {
global $vbulletin;
$vbuser =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY);
$vbuser->set_existing($vbulletin->userinfo);

$vbuser->set('password', $newpw);

if ($vbuser->errors) {
foreach ($vbuser->errors as $error) {
echo "<br> error: $error";
}
} else {
// no errors, so save new vbuser.
$vbuserid = $vbuser->save();

}
}