On error resume next
set objFSO = CreateObject("Scripting.FileSystemObject")
'set objInputFile = objFSO.openTextFile("C:\Documents and Settings\Desktop\scripts\in.txt",1)
set objOutputFile = objFSO.CreateTextFile("C:\Documents and Settings\Desktop\scripts\Text2.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
strSQL="select cn,distinguishedName,UserPrincipalName,samAccountName from 'LDAP://xyz.abc.com' where objectclass='user'and objectclass <>'computer' "
com.CommandText = strSQL
set rs = com.Execute
While Not rs.EOF
dim UPN
UPN = rs("samAccountName")
strSQL = "select distinguishedName,cn,samAccountName,userPrincipalName from 'LDAP://abc.com/dc=abc,dc=com' where objectClass='user' and objectClass <>'computer' and samAccountName='" & Trim(UPN) & "'"
com.CommandText = strSQL
set rs1 = com.Execute
if err.Number <> 0 then
objOutputFile.WriteLine rs1("samAccountName")
end if
rs.movenext
Wend
msgbox "done"
set RootDSE = Nothing
set con = Nothing
set objUser = Nothing
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment