List delegates (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 lists the delegates, if any, for the selected
' mailbox.
' ------ SCRIPT CONFIGURATION ------
 strDCName = "<serverName>"	' e.g. "batman"
 strUserName = "/cn=<userName>,<container>,<domainDN>" 
 ' e.g. "/cn=David P. Robichaux, CN=Users, dc=robichaux, dc=net" ' ------ END CONFIGURATION ---------

' find the target user
 strQuery = "LDAP://" & strDCName & strUserName
 Set theUser = GetObject(strQuery) 
 WScript.echo "Mailbox " & strUserName
 On Error Resume Next
 	
	delegateList = theUser.Get("publicDelegates")
	If Err.Number <> -2147463155 Then
		wscript.echo "has these delegates:"
	    For Each Desc In delegateList
	        WScript.Echo "  " & desc
	    Next
	Else
	    WScript.Echo "+ Has no delegates"
	End If
	
	delegateList = theUser.Get("publicDelegatesBL")
 	
	If Err.Number <> -2147463155 Then
	    wscript.echo "+ is a delegate of"
	    For Each Desc In delegateList
	        WScript.Echo "  " & desc
	    Next
	Else
	    WScript.Echo "+ Not a delegate for anyone"
	End If

This code has been viewed 2176 times.

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