Passwd_Driver_Pspasswd
extends Passwd_Driver
in package
The PSPasswd class changes a user's password on any Windows Machine (NT+) using the pspasswd free utility available at Sysinternals website: http://www.sysinternals.com/ntw2k/freeware/pspasswd.shtml
IMPORTANT!
This driver should be used only as a last resort when there's no possibility of using the ADSI or LDAP drivers, which are far more secure and fast. This driver needs administrative credentials exposed on the backends.php file, which is required by the pspasswd.exe tool. It's an alternative driver that should be avoided, but could also be the only option for a few scenarios. (eg: When you don't have ADSI or LDAP support)
Sample backend configuration:
$backends['pspasswd'] = array(
'name' => 'Sample pspasswd backend',
'preferred' => 'localhost',
'policy' => array(
'minLength' => 8,
'maxLength' => 14
),
'driver' => 'pspasswd',
'params' => array(
'server' => 'YOUR_SERVER_NAME',
'bin' => 'DRIVE:\DIR\pspasswd.exe', // Notice: "\"
'admusr' => 'Administrator',
'admpwd' => 'Password',
'domain' => 'YOUR_DOMAIN_NAME'
)
);
Backend parameters:
server = Machine where you want to change the password (Required) bin = Full pathname of the pspasswd.exe program (Required) admusr = User with administrative privileges (Required) admpwd = Password of the administrative user (Required) domain = Windows domain name (Optional)
For example: Passing a NT4 PDC server name to the server parameter means you can change the user's password on that NT4 Domain.
Special thanks to Mark Russinovich (mark@sysinternals.com) for the tool and helping me solve some questions about it.
Tags
Table of Contents
- $_params : array<string|int, mixed>
- Hash containing configuration parameters.
- __construct() : mixed
- Constructor.
- changePassword() : mixed
- Changes the user's password.
- _changePassword() : mixed
- Changes the user's password.
- _comparePasswords() : mixed
- Compares a plaintext password with an encrypted password.
- _encryptPassword() : string
- Encrypts a password.
Properties
$_params
Hash containing configuration parameters.
protected
array<string|int, mixed>
$_params
= array()
Methods
__construct()
Constructor.
public
__construct([array<string|int, mixed> $params = array() ]) : mixed
Parameters
- $params : array<string|int, mixed> = array()
-
A hash containing connection parameters.
Return values
mixed —changePassword()
Changes the user's password.
public
changePassword(string $user, string $oldpass, string $newpass) : mixed
Parameters
- $user : string
-
The user for which to change the password.
- $oldpass : string
-
The old (current) user password.
- $newpass : string
-
The new user password to set.
Tags
Return values
mixed —_changePassword()
Changes the user's password.
protected
_changePassword(mixed $user, mixed $oldpass, mixed $newpass) : mixed
Parameters
- $user : mixed
-
The user for which to change the password (converted to backend username).
- $oldpass : mixed
-
The old (current) user password.
- $newpass : mixed
-
The new user password to set.
Return values
mixed —_comparePasswords()
Compares a plaintext password with an encrypted password.
protected
_comparePasswords(string $encrypted, string $plaintext) : mixed
Parameters
- $encrypted : string
-
An encrypted password.
- $plaintext : string
-
An unencrypted password.
Tags
Return values
mixed —_encryptPassword()
Encrypts a password.
protected
_encryptPassword(string $plaintext) : string
Parameters
- $plaintext : string
-
A plaintext password.
Return values
string —The encrypted password.