Google
Search WWW Search msexchangetips.blogspot.com

Thursday, July 06, 2006

Exchange: Exporting SMTP Proxies

One common request from Exchange administrators is how to export SMTP proxies. Below is a sample script to export SMTP proxies into a LDF file.


''''''''''''''''''''''''''''''''''''''''''''''''''''''
' DumpProxy.vbs '
' '
' James Chong, MCSE + Messaging '
' '
' (dumps existing proxy addresses to an ldf file) '
' '
''''''''''''''''''''''''''''''''''''''''''''''''''''''
Const Writable = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLog = objFSO.OpenTextFile("c:\proxydump.ldf", Writable, True)
Set cn = CreateObject("ADODB.Connection")
Set cm = CreateObject("ADODB.Command")
Set rs = CreateObject("ADODB.RecordSet")

With cn
.Provider = "ADsDSOObject"
.Open "Active Directory Provider"
End With
Set cm.ActiveConnection = cn

cm.CommandText = "<;(&(objectClass=user)(proxyAddresses=*));SAMAccountName,mail,proxyAddresses;subtree">LDAP://mydc.mydomain.com>;(&(objectClass=user)(proxyAddresses=*));SAMAccountName,mail,proxyAddresses;subtree"
Set rs = cm.Execute

While Not rs.EOF
On Error Resume Next
strUserDN = rs.Fields("samaccountname")
strMail = rs.Fields("mail")
strProxyAddress = rs.Fields("proxyAddresses")
objLog.Write "dn: " & strUserDN & vbCrLf
objLog.Write "changetype: modify" & vbCrLf
objLog.Write "replace: mail" & vbCrLf
objLog.Write "mail: " & strMail & vbCrLf
objLog.Write "-" & vbCrLf & vbCrLf
objLog.Write "dn: " & strUserDN & vbCrLf
objLog.Write "changetype: modify" & vbCrLf
objLog.Write "replace: proxyAddresses" & vbCrLf
For Each Item in strProxyAddress
strTempAddr = Item
objLog.Write "proxyAddresses: " & Item & vbCrLf
Next
objLog.Write "-" & vbCrLf & vbCrLf
rs.MoveNext
Wend

objLog.Close
msgbox "Export Complete to c:\proxydump.lfd"


James Chong (MVP)
MCITP | EMA; MCSE | M+, S+
Security+, Project+, ITIL
msexchangetips.blogspot.com

1 Comments:

Anonymous catfish said...

one particular line got screwed up, I believe it should be:

cm.CommandText = "<LDAP://mydc.mydomain.com>;(&(objectClass=user)(proxyAddresses=*));SAMAccountName,mail,proxyAddresses;subtree"

8:49 PM  

Post a Comment

<< Home

xml:lang="en" lang="en"> MS Exchange Tips: Exchange: Exporting SMTP Proxies