Export (0) Print
Expand All

Determining When a Password Was Last Set

Microsoft® Windows® 2000 Scripting Guide

To determine when a password will expire, it is important to know when the password was last set. Determining when a password was last set requires that you read the pwdLastSet attribute.

You can use the PasswordLastChanged property of the IADsUser interface to determine the last time that a user changed his or her user account password.

Scripting Steps

Listing 7.5 contains a script that checks the exact date and time when a user account password was last changed. To carry out this task, the script performs the following steps:

  1. Bind to the user account object by using the GetObject function and the LDAP provider.

  2. Create a variable, and initialize it to the value returned by the PasswordLastChanged property of the IADsUser interface.

  3. Display the date and time when the password was last set.

Listing 7.5 Determining When a Password Was Last Set

  
1
2
3
4


Set objUser = GetObject _
 ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
dtmValue = objUser.PasswordLastChanged
Wscript.Echo "Password was last set: " & dtmValue

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft