Obtener la fecha de expiracion de los passwords

Para obtener la fecha de expiracion de los password del usuario se puede utilizar el siguiente codigo.

'========================================
' First, get the domain policy.
'========================================
Dim oDomain As IADsContainer
Dim oUser As IADsUser
Dim maxPwdAge As LargeInteger

'========================================
' Declaring numDays as Currency, due to a
' large number calculation.
'========================================
Dim numDays As Currency

strDomainDN = "YOURDOMAIN"
strUserDN = strDomainDN & "/CN=John Doe,CN=Users,DC=YOURDOMAIN,DC=COM"

Set oDomain = GetObject("LDAP://" & strDomainDN)
Set maxPwdAge = oDomain.Get("maxPwdAge")

'========================================
' Calculate the number of days that are
' held in this value.
'========================================
numDays = ((maxPwdAge.HighPart * 2 ^ 32) + _
maxPwdAge.LowPart) / -864000000000@
Debug.Print "Maximum Password Age: " & numDays

'========================================
' Determine the last time that the user
' changed his or her password.
'========================================
Set oUser = GetObject("LDAP://" & strUserDN)

'========================================
' Add the number of days to the last time
' the password was set.
'========================================
whenPasswordExpires = DateAdd("d", numDays, oUser.PasswordLastChanged)

Debug.Print "Password Last Changed: " & oUser.PasswordLastChanged
Debug.Print "Password Expires On: " & whenPasswordExpires

'========================================
' Clean up.
'========================================
Set oUser = Nothing
Set maxPwdAge = Nothing
Set oDomain = Nothing

http://support.microsoft.com/kb/323750

Comments

Popular posts from this blog

Cómo identificar consultas más pesadas en SQL Server

Power View en SQL Server 2012 Primer Entrega

Machine Learning Services con SQL Server Managed Instance