To use the VBScript, follow these steps:
1. | 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("Enter an name for the ldifde import file;" & _
" .ldf will be added to the file name.", "e-mail address import generator",_
"userProxyAddresses")
count = 0
Set FileObject = CreateObject("Scripting.FileSystemObject")
Set LogFile = FileObject.OpenTextFile(exportFileName & _
".ldf", Writable, True)
Set Connection = CreateObject("ADODB.Connection")
Set Command = CreateObject("ADODB.Command")
Set RecordSet = CreateObject("ADODB.RecordSet")
With Connection
.Provider = "ADsDSOObject"
.Open "Active Directory Provider"
End With
Set Command.ActiveConnection = Connection
Set objRootDSE = GetObject("LDAP://rootDSE")
Command.CommandText = "<LDAP://" & _
objRootDSE.Get("defaultNamingContext")_
& ">;(&(objectCategory=user)(proxyAddresses=*))" & _
";distinguishedName,mail,proxyAddresses;subtree"
Set RecordSet = Command.Execute
While Not RecordSet.EOF
On Error Resume Next
strUserDN = RecordSet.Fields("distinguishedName")
strMail = RecordSet.Fields("mail")
strProxyAddress = RecordSet.Fields("proxyAddresses")
LogFile.Write "dn: " & strUserDN & vbCrLf
LogFile.Write "changetype: modify" & vbCrLf
LogFile.Write "replace: mail" & vbCrLf
LogFile.Write "mail: " & strMail & vbCrLf
LogFile.Write "-" & vbCrLf & vbCrLf
LogFile.Write "dn: " & strUserDN & vbCrLf
LogFile.Write "changetype: modify" & vbCrLf
LogFile.Write "replace: proxyAddresses" & vbCrLf
For Each Item in strProxyAddress
strTempAddr = Item
LogFile.Write "proxyAddresses: " & Item & vbCrLf
count = count + 1
Next
LogFile.Write "-" & vbCrLf & vbCrLf
RecordSet.MoveNext
Wend
LogFile.Close
msgbox "Exported " & count & " users and " & _
"their e-mail addresses to " _
& exportFileName & ".ldf"
Set objRootDSE = Nothing
Set FileObject = Nothing
Set LogFile = Nothing
Set Connection = Nothing
Set Command = Nothing
Set RecordSet = Nothing
� --- end script ---
|
2. | Locate and then double-click the file that you saved. |
3. | 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. |
4. | 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. |
5. | To import the UserProxyAddresses.ldf file, follow these steps:a. | Click Start, click Run, type cmd in the Open box, and then click OK.
| b. | Change to the drive location in which the script was saved.
| c. | Type ldifde -i -f userProxyAddresses.ldf, and then click OK.
| d. | When the command succeeds, close the command prompt. |
|
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:
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