On 2011-01-08 Patrick Ben Koetter wrote: > * Eero Volotinen <eero.voloti...@iki.fi>: >> Does this still works for windows 2008 ad? : >> http://postfix.state-of-mind.de/patrick.koetter/mailrelay/#d0e149 >> >> or is there better way to do it? > > The script is old. You are probably better off, if you use ldifde.exe > to query the AD and get LDIF as export format. The rest is sed awk > magic.
That is one option. The VBScript below should work too. ----8<---- Const OutputFile = "virtual.txt" Set rootDSE = GetObject("LDAP://RootDSE") ' open ADO connection Set adoConn = CreateObject("ADODB.Connection") adoConn.Provider = "ADsDSOObject" adoConn.Open "Active Directory Provider" Set adoCmd = CreateObject("ADODB.Command") adoCmd.ActiveConnection = adoConn adoCmd.CommandText = "<LDAP://" & rootDSE.Get("defaultNamingContext") _ & ">;(&(objectCategory=person)(objectClass=user));" _ & "distinguishedName,proxyAddresses;subtree" adoCmd.Properties("Page Size") = 100 adoCmd.Properties("Timeout") = 30 adoCmd.Properties("Cache Results") = False Set addresses = CreateObject("Scripting.Dictionary") ' enumerate all users from AD store all smtp addresses in a dictionary ' (to avoid duplicates) Set adoRS = adoCmd.Execute Do Until adoRS.EOF If Not IsNull(adoRS.Fields("proxyAddresses").Value) Then For Each addr In adoRS.Fields("proxyAddresses").Value If Left(LCase(addr), 5) = "smtp:" And Not addresses.Exists(addr) Then addresses.Add Mid(addr, 6) & " OK", True End If Next End If adoRS.MoveNext Loop adoRS.Close adoConn.Close ' create output file with Unix line breaks Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile(OutputFile, 2, True) f.Write Join(addresses, vbLf) f.Close WScript.Echo "Finished." ---->8---- Regards Ansgar Wiechers -- "Abstractions save us time working, but they don't save us time learning." --Joel Spolsky