Show 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 script hides the selected object from all address lists

' This code displays 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
' ------ END CONFIGURATION ------

' Prepare the address list array
Dim arrAddress()
intSize = 0

' Create the group object
set objGroup = GetObject("LDAP://" & strGroupDN) 
Wscript.Echo "Sender restrictions for " & objGroup.Name & "."

' Is the address list empty? If so, there are no restrictions.
' If not, determine the type and enumerate using a dynamic array since we
' do not know how many items there are in it.
If IsNull(objGroup.RestrictedAddressList) Then
   Wscript.Echo "There are no sender restrictions on this group."
Else
   If objGroup.RestrictedAddresses = cdoexmAccept Then
     Wscript.Echo "The following senders can send to the group:"
   Else
     Wscript.Echo "The following senders cannot send to the group:"
   End If
   For Each strAddress in objGroup.RestrictedAddressList
     ReDim Preserve arrAddress(intSize)
     arrAddress(intSize) = strAddress
     Wscript.Echo arrAddress(intSize)
     intSize = intSize + 1
   Next
End If

This code has been viewed 945 times.

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