Displays password-related attributes for an individual user account.
Const ADS_UF_PASSWORD_EXPIRED = &h800000Const ADS_ACETYPE_ACCESS_DENIED_OBJECT = &H6Const CHANGE_PASSWORD_GUID = "{ab721a53-1e2f-11d0-9819-00aa0040529b}"Set objHash = CreateObject("Scripting.Dictionary")objHash.Add "ADS_UF_PASSWD_NOTREQD", &h00020objHash.Add "ADS_UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED", &h0080objHash.Add "ADS_UF_DONT_EXPIRE_PASSWD", &h10000Set objUser = GetObject _("LDAP://CN=MyerKen,OU=management,DC=Fabrikam,DC=com")intUserAccountControl = objUser.Get("userAccountControl")Set objUserNT = GetObject("WinNT://fabrikam/myerken")intUserFlags = objUserNT.Get("userFlags")If ADS_UF_PASSWORD_EXPIRED And intUserFlags ThenblnExpiredFlag = TrueWscript.Echo "ADS_UF_PASSWORD_EXPIRED is enabled"ElseWscript.Echo "ADS_UF_PASSWORD_EXPIRED is disabled"End IfFor Each Key In objHash.KeysIf objHash(Key) And intUserAccountControl ThenWScript.Echo Key & " is enabled"ElseWScript.Echo Key & " is disabled"End IfNextSet objSD = objUser.Get("nTSecurityDescriptor")Set objDACL = objSD.DiscretionaryAclFor Each Ace In objDACLIf ((Ace.AceType = ADS_ACETYPE_ACCESS_DENIED_OBJECT) And _(LCase(Ace.ObjectType) = CHANGE_PASSWORD_GUID)) ThenblnACEPresent = TrueEnd IfNextIf blnACEPresent ThenWscript.Echo "ADS_UF_PASSWD_CANT_CHANGE is enabled"ElseWscript.Echo "ADS_UF_PASSWD_CANT_CHANGE is disabled"End IfIf blnExpiredFlag = True ThenWscript.echo "pwdLastSet is null"ElseWscript.echo "pwdLastSet is " & objUser.PasswordLastChangedEnd If
This is a VB Script, this can be used by saving the file in .vbs file