Set sender restrictions (VBScript)

This code can be found in Chapter 5 of Exchange Server Cookbook

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the VBScript code from this site.

' This script was originally published in the Exchange Cookbook,
' (http://www.exchangebookcook.com). Written by Paul Robichaux, 
' Missy Koslosky, and Devin Ganger. Redistributed with permission 
' of the publisher, O'Reilly & Associates.

' This code configures the sender restrictions on a group object.
' ------ SCRIPT CONFIGURATION ------
const cdoexmAccept = 0                  ' Included senders
const cdoexmReject = 1                  ' Excluded senders
strGroupDN         = "<GroupParentDN>"  ' e.g. cn=Staff,dc=3sharp,dc=com
intSize = 0
Dim arrAddress(2)				' put allowed senders here
arrAddress(0) = <EmailAddress1>
arrAddress(1) = <EmailAddress2>
' ------ END CONFIGURATION ------

' Prepare the address list array
' Create the group object
set objGroup = GetObject("LDAP://" & strGroupDN)
Wscript.Echo "Updating sender restrictions for " & objGroup.Name & ":"
' Set the type of sender restriction
objGroup.RestrictedAddresses = cdoexmAccept
' Enumerate the address list, then place it on the group object
Wscript.Echo "Only the following senders can send to the group:"
For Each strAddress in objGroup.RestrictedAddressList
   Wscript.Echo arrAddress(intSize)
   intSize = intSize + 1
Next
objGroup.RestrictedAddressList = arrAddress
' Write the update object data back to the directory
objGroup.SetInfo
WScript.Echo "Set sender restrictions on " & strGroupDN

This code has been viewed 1073 times.

New from the creators of TechTasks.com: StatSheet.com