Google
Search WWW Search msexchangetips.blogspot.com

Monday, August 28, 2006

Exchange: Exporting SMTP Proxies Part 2

Summary:

The following script will export SMTP proxies from the specific OU's that you designate rather than exporting the entire domain.

You can also download this file from our ftp site at:

ftp://ftp.smtp25.org/[ James Chong Scripts ]


Dim x, zz
Set objRoot = GetObject("LDAP://RootDSE")
Set fso = CreateObject("Scripting.FileSystemObject")
Set txtstream = fso.CreateTextFile("c:\testfile.txt", True)
strDNC = objRoot.Get("DefaultNamingContext")
Set objOU = GetObject("LDAP://cn=users,dc=corp,dc=company,dc=net")
Call enummembers(objOU)
Set objOU = GetObject("LDAP://cn=builtin,dc=corp,dc=company,dc=net")
Call enummembers(objOU)

Call enummembers(objOU)
Sub enumMembers(objOU)
On Error Resume Next
Dim Secondary(20) ' Variable to store the Array of 2ndary email alias's
For Each objMember In objOU ' go through the collection

If ObjMember.Class = "user" Then ' if not User object, move on.

' I set AD properties to variables so if needed you could do Null checks or add if/then's to this code
' this was done so the script could be modified easier.

EmailAddr = objMember.mail

zz = 1 ' Counter for array of 2ndary email addresses
For each email in ObjMember.proxyAddresses
If Left (email,5) = "SMTP:" Then
Primary = Mid (email,6) ' if SMTP is all caps, then it's the Primary
ElseIf Left (email,5) = "smtp:" Then
Secondary(zz) = Mid (email,6) ' load the list of 2ndary SMTP emails into Array.
zz = zz + 1
End If
Next


txtstream.write Primary & vbcrlf

' Write out the Array for the 2ndary email addresses.
For ll = 1 To 20


txtstream.write Secondary(ll) & vbcrlf


Next
' Blank out Variables in case the next object doesn't have a value for the property

Primary = "-"
For ll = 1 To 20
Secondary(ll) = ""
Next
End If


' If the AD enumeration runs into an OU object, call the Sub again to itinerate


If objMember.Class = "organizationalUnit" or OBjMember.Class = "container" Then
enumMembers (objMember)
End If

Next
End Sub

txtstream.close

Const ForReading = 1
Const ForWriting = 2

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Testfile.txt", ForReading)


Do Until objFile.AtEndOfStream
strLine = objFile.Readline
strLine = Trim(strLine)
If Len(strLine) > 0 Then
strNewContents = strNewContents & strLine & vbCrLf
End If
Loop

objFile.Close

Set objFile = objFSO.OpenTextFile("C:\Testfile.txt", ForWriting)
objFile.Write strNewContents
objFile.Close

MsgBox "Done" ' show that script is complete



James Chong
MCSE M+, S+, MCTS, Security+
msexchangetips.blogspot.com


How useful was this article? Want to see a tip not listed? Please leave a comment.

5 Comments:

Anonymous Anonymous said...

This is a wonderful blog with an useful points that will be great use.
web design company

12:03 AM  
Anonymous palmcop said...

It can't succeed in fact, that is what I think.

1:19 AM  
Blogger raybanoutlet001 said...

fitflops
ugg boots
new balance outlet
michael kors outlet online
ugg outlet
nike air huarache
san francisco 49ers jerseys
nhl jerseys
washington redskins jerseys
jordan shoes
2017.6.6

11:00 PM  
Blogger Unknown said...

HOW MIKE LARRY LOAN FIRM GRANTED ME A BUSINESS LOAN!!!
Hello everyone, I am Evans Torttor from USA and want to use this medium to express gratitude to MIKE LARRY for fulfilling his promise by granting me a loan, i was stuck in a financial situation and needed to refinance and pay my bills as well as start up a Business. I tried seeking for loans from various loan firms both private and corporate organizations but never succeeded and most banks declined my credit request. But as God would have it, i was introduced by a friend named Esther to MIKE LARRY LOAN FIRM and undergone the due process of obtaining a loan from the company, to my greatest surprise within 48hrs just like my friend Esther said, i was also granted a loan of $387,000.00 USD; So my advise to everyone who desires a loan, "if you must contact any firm with reference to securing a loan online with low interest rate of 3% and better repayment plans/schedule, please contact MIKE LARRY LOAN FIRM. Besides, he doesn't know that am doing this but due to the joy in me, i'm so happy and wish to let people know more about this great company whom truly give out loans, it is my prayer that GOD should bless them more as they put smiles on peoples faces. You can contact them via email on {mikelarryloanfirmworldwide@yahoo.com}

8:39 PM  
Blogger Abel Chadwick said...

Are you an individual businessman or a business organisation that wishes to expand in business ??, we offer financial instrument such as BGs, SBLCs,MTNs, LCs, CDs and others on lease and sales at a rate of 4%+2% of the face value and reasonable conditionfrom a genuine provider. You are at liberty to engage our leased facilities into trade programs as well as in signatory project(s) such as Aviation, Agriculture, Petroleum, Telecommunication and any other project(s) etc.

Contact : Mr. Abel Chadwick
Contact Email: abelbroker9000@gmail.com
Whatsapp : +380 50 922 4887

With our financial/bank instrument you can establish line of credit with your bank and/or secure loan for your projects in which our bank instrument will serve collateral in your bank to fund your project.

We deliver with time and precision as set forth in the agreement. Our terms and Conditions are reasonable and we work directly with issuing bank lease providers, this instrument can be monetized on your behalf for upto 100% funding. Intermediaries/Consultants/Brokers are welcome to bring their clients and are 100% protected. In complete confidence, we will work together for the benefits of all parties involved.

All relevant business information will be provided upon request.

BROKERS ARE WELCOME & 100% PROTECTED!!!

If Interested kindly contact me via

Email:~ abelbroker9000@gmail.com

serious enquiry only.

6:04 AM  

Post a Comment

<< Home

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