2008/04/28

LDAP ADSI 공급자를 사용하여 암호 만료 날짜를 확인하는 Vbscript

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

'========================================
' First, get the domain policy.
'========================================

Dim oDomain
Dim oUser
Dim maxPwdAge
Dim numDays

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 = CCur((maxPwdAge.HighPart * 2 ^ 32) + _
                maxPwdAge.LowPart) / CCur(-864000000000)
WScript.Echo "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)

WScript.Echo "Password Last Changed: " & oUser.PasswordLastChanged
WScript.Echo "Password Expires On: " & whenPasswordExpires

'========================================
' Clean up.
'========================================

Set oUser = Nothing
Set maxPwdAge = Nothing
Set oDomain = Nothing

WScript.Echo "Done"


댓글 없음:

댓글 쓰기

가장 많이 본 글