On error resume next
set objFSO = CreateObject("Scripting.FileSystemObject")
set objInputFile = objFSO.openTextFile("C:\Documents and Settings\Desktop\scripts\success\in.txt",1)
set objOutputFile = objFSO.CreateTextFile("C:\Documents and Settings\Desktop\scripts\success\TEXT.TXT",True)
Set con = CreateObject("ADODB.Connection")
Set com = CreateObject("ADODB.Command")
con.provider = "ADsDSOObject"
con.open "Active Directory Provider"
com.ActiveConnection = con
com.Properties("searchscope") = 2
com.Properties("Page Size") = 100000
While Not objInputFile.AtEndofStream
str = objInputFile.readline
msgbox str
strSQL="select distinguishedName,pwdlastSet from 'LDAP://dc=ABC,dc=com' where objectClass='user' and cn='" & Trim(str) & "'"
com.CommandText = strSQL
Set rs = com.Execute
if Not rs.EOF then
msgbox "j"
Set objUser = GetObject("WinNT://ABC.com/" & rs("cn"))
objOutputFile.WriteLine rs("cn") & "|" & objUser.PasswordExpirationDate
End If
Wend
msgbox "done"
set RootDSE = Nothing
set con = Nothing
set objUser = Nothing
set objFSO = CreateObject("Scripting.FileSystemObject")
set objInputFile = objFSO.openTextFile("C:\Documents and Settings\Desktop\scripts\success\in.txt",1)
set objOutputFile = objFSO.CreateTextFile("C:\Documents and Settings\Desktop\scripts\success\TEXT.TXT",True)
Set con = CreateObject("ADODB.Connection")
Set com = CreateObject("ADODB.Command")
con.provider = "ADsDSOObject"
con.open "Active Directory Provider"
com.ActiveConnection = con
com.Properties("searchscope") = 2
com.Properties("Page Size") = 100000
While Not objInputFile.AtEndofStream
str = objInputFile.readline
msgbox str
strSQL="select distinguishedName,pwdlastSet from 'LDAP://dc=ABC,dc=com' where objectClass='user' and cn='" & Trim(str) & "'"
com.CommandText = strSQL
Set rs = com.Execute
if Not rs.EOF then
msgbox "j"
Set objUser = GetObject("WinNT://ABC.com/" & rs("cn"))
objOutputFile.WriteLine rs("cn") & "|" & objUser.PasswordExpirationDate
End If
Wend
msgbox "done"
set RootDSE = Nothing
set con = Nothing
set objUser = Nothing
No comments:
Post a Comment