Skip to content

Getting Password last set for a user in Active Directory

To see when the user has last changed the password you can use the below command in Php

$user = $_SERVER['AUTH_USER'];
$domain = getenv('USERDOMAIN');
$users=explode("\\",$user);
$UserId=$users[1];
exec("NET USER /DOMAIN ".$UserID." 2>1",$output);
$PasswordLastSet=$output[10];
//You can use the below code to see the full details
print_r($output)