'Path for the output file filePath = "d:\AllSMTPProxies.txt"
'Setup output file Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.OpenTextFile(filepath, ForWriting, True)
'Create Objects for LDAP Queries Set rootDSE = GetObject("LDAP://RootDSE") DomainContainer = rootDSE.Get("defaultNamingContext")
Set conn = CreateObject("ADODB.Connection") conn.Provider = "ADSDSOObject" conn.Open "ADs Provider"
'LDAP query for all mail users strLDAP = "<LDAP://" & DomainContainer & ">;(&(mailnickname=*)(objectCategory=person)(objectClass=user));adspath;subtree"
'Get query results and output to file Set oComm = CreateObject("ADODB.Command") oComm.ActiveConnection = conn oComm.CommandText = strLDAP oComm.Properties("Sort on") = "DisplayName" oComm.Properties("Page size") = 1500
Set rs = oComm.Execute
While Not rs.EOF
Set FoundObject = GetObject (rs.Fields(0).Value)
arrProxyAddresses = FoundObject.proxyAddresses
If IsArray(FoundObject.proxyAddresses) Then
add="" For Each Address In arrProxyAddresses If InStr(Address, strX400Search) <> 0 Then 'wscript.echo "X400 Address" else If left(Address,4)= "SIP:" or left(Address,4)= "sip:" Then else add=add&address&vbTab End if End if Next objTextFile.writeLine(FoundObject.Displayname & vbTab & add) else objTextFile.writeLine(FoundObject.Displayname & vbTab & arrProxyAddresses) end if