Microsoft KB Archive/922258

= How to use a VBScript to write proxy addresses to an Ldifde.exe-compatible import file in Exchange Server 2003 =

Article ID: 922258

Article Last Modified on 10/25/2007

-

APPLIES TO


 * Microsoft Exchange Server 2003 Enterprise Edition
 * Microsoft Exchange Server 2003 Standard Edition

-





INTRODUCTION
This article discusses how to use a Microsoft Exchange Server 2003 VBScript that performs the following operations:
 * Connects to the default naming context in the Active Directory directory service
 * Extracts e-mail proxy addresses
 * Writes the proxy addresses to an Ldifde.exe-compatible import file

This script can be used to back up and to restore e-mail proxy addresses for objects that are defined as exempt from the Exchange Server Recipient Update Service. This script can also restore e-mail proxy addresses that were not generated by the Recipient Update Service.



MORE INFORMATION
To use the VBScript, follow these steps:   Open a text editor, copy the following text to a new file, and then save the new file as Proxydump.vbs. ' --- Start script ---

' ' This script will connect to your default naming context ' in Active Directory and build an ldifde.exe import file ' for all users and their e-mail addresses. ' The default file name is userProxyAddresses.ldf ' ' --- ' ' Copyright (C) 2006 Microsoft Corporation ' You have a royalty-free right to use, modify, ' reproduce and distribute this sample application ' (or any modified version) in any way you find useful, ' provided that you agree that Microsoft has no warranty, ' obligations or liability for results produced by this or ' your sample application. ' ' - Dim exportFileName Dim count Dim FileObject Dim LogFile Dim Connection Dim Command Dim RecordSet Const Writable = 2 exportFileName = InputBox(&quot;Enter an name for the ldifde import file;&quot; & _ &quot; .ldf will be added to the file name.&quot;, &quot;e-mail address import generator&quot;,_ &quot;userProxyAddresses&quot;) count = 0

Set FileObject  = CreateObject(&quot;Scripting.FileSystemObject&quot;) Set LogFile                         = FileObject.OpenTextFile(exportFileName & _ &quot;.ldf&quot;, Writable, True) Set Connection = CreateObject(&quot;ADODB.Connection&quot;) Set Command                  = CreateObject(&quot;ADODB.Command&quot;) Set RecordSet  = CreateObject(&quot;ADODB.RecordSet&quot;)

With Connection .Provider            = &quot;ADsDSOObject&quot; .Open &quot;Active Directory Provider&quot; End With

Set Command.ActiveConnection = Connection Set objRootDSE = GetObject(&quot;LDAP://rootDSE&quot;) Command.CommandText = &quot;;(&(objectCategory=user)(proxyAddresses=*))&quot; & _ &quot;;distinguishedName,mail,proxyAddresses;subtree&quot;

Set RecordSet  = Command.Execute

While Not RecordSet.EOF

On Error Resume Next strUserDN                          = RecordSet.Fields(&quot;distinguishedName&quot;) strMail                                 = RecordSet.Fields(&quot;mail&quot;) strProxyAddress = RecordSet.Fields(&quot;proxyAddresses&quot;) LogFile.Write &quot;dn: &quot; & strUserDN & vbCrLf LogFile.Write &quot;changetype: modify&quot; & vbCrLf LogFile.Write &quot;replace: mail&quot; & vbCrLf LogFile.Write &quot;mail: &quot; & strMail & vbCrLf LogFile.Write &quot;-&quot; & vbCrLf & vbCrLf

LogFile.Write &quot;dn: &quot; & strUserDN & vbCrLf LogFile.Write &quot;changetype: modify&quot; & vbCrLf LogFile.Write &quot;replace: proxyAddresses&quot; & vbCrLf

For Each Item in strProxyAddress strTempAddr = Item LogFile.Write &quot;proxyAddresses: &quot; & Item & vbCrLf count = count + 1 Next

LogFile.Write &quot;-&quot; & vbCrLf & vbCrLf

RecordSet.MoveNext

Wend

LogFile.Close

msgbox &quot;Exported &quot; & count & &quot; users and &quot; & _ &quot;their e-mail addresses to &quot; _ & exportFileName & &quot;.ldf&quot;

Set objRootDSE = Nothing Set FileObject  = Nothing Set LogFile         = Nothing Set Connection = Nothing Set Command  = Nothing Set RecordSet  = Nothing ‘ --- end script ---  Locate and then double-click the file that you saved. Enter the name of the Ldifde import file, and then click OK. The default name for this file is UserProxyAddresses.ldf.

Note Ldifde.exe is a command-line tool that imports and exports Active Directory information. Ldifde.exe is included in Microsoft Windows Server 2003 and in Microsoft Windows 2000 Server. When the script is completed, a message is displayed that includes the number of users whose e-mail proxy addresses were exported. The Ldifde import file is ready to be imported. To import the UserProxyAddresses.ldf file, follow these steps:  Click Start, click Run, type cmd in the Open box, and then click OK.</li> Change to the drive location in which the script was saved.</li> Type ldifde -i -f userProxyAddresses.ldf, and then click OK.</li> When the command succeeds, close the command prompt.</li></ol> </li></ol>

For more information about how to use the Ldifde.exe command-line tool, click the following article number to view the article in the Microsoft Knowledge Base:

237677 Using LDIFDE to import and export directory objects to Active Directory

For more information about Ldifde.exe, visit the following Microsoft Web site:

http://technet2.microsoft.com/windowsserver/en/library/32872283-3722-4D9B-925A-82C516A1CA141033.mspx

For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:

328738 How the Recipient Update Service applies recipient policies

820381 The secondary SMTP proxy e-mail address is not stamped on migrated objects

821743 The gatewayProxy attribute on the Recipient Update Service object is not cleared

Additional query words: xadm

Keywords: kbdirectory kbhowto kbinfo KB922258

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.