'======================================================================================= ' ' AUTHOR: Anthony Drewery ' ' DATE: 10th October 2006 ' ' COMMENT: Exports a list of SMTP proxy addreses addresses '======================================================================================= Const ForWriting = 2 'Path for the output file filePath = "C:\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 = ";(&(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 For Each Address In arrProxyAddresses If left(Address,5)= "smtp:" Then objTextFile.writeLine(FoundObject.Displayname & vbTab & Address) End if Next rs.MoveNext Wend MsgBox "Processing complete!"