HOWTO: Find Password Last Changed Date Using ADSIID: Q192949
|
The Active Directory Service Interfaces (ADSI) Windows NT provider does not support the PasswordLastChanged Property of an IADsUser object. You can compute this date by subtracting the password expiration period (converted to days) from the password expiration date to get the last change date. Note that for users whose passwords never expire, the PasswordExpirationDate will be in the past and the computation still works correctly.
The following Visual Basic code illustrates this:
Dim adsUser As IADsUser
Dim strDomain As String
Dim strUser As String
Set adsUser = GetObject("WinNT://" + strDomain + "/" + strUser + _
",user")
Debug.Print "Password Expired on : " + _
CStr(adsUser.PasswordExpirationDate + _
adsUser.Get("MaxPasswordAge") / (3600& * 24))
Active Directory Service Interfaces (ADSI) documentation is available in the Platform SDK section of MSDN and in a help file you can download from the following Web site:
http://www.microsoft.com/backoffice/downloads/moreinfo/adsi2.asp
Additional query words:
Keywords : kbnetwork kbADSI kbAPI kbSDKPlatform kbGrpNet
Version : WINDOWS:95; winnt:4.0
Platform : WINDOWS winnt
Issue type : kbhowto
Last Reviewed: March 27, 1999