# 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 ------
use Win32::OLE;
$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;
$theUser = Win32::OLE->GetObject($strQuery);
print "Mailbox $strUserName\n";
$delegateList = $theUser->Get('publicDelegates');
if ((0 + Win32::OLE::LastError()) != -2147463155) {
print "has these delegates:\n";
foreach my $Desc (@{$delegateList}) {
print " $desc\n";
}
}
else {
print "+ Has no delegates\n";
}
$delegateList = $theUser->Get('publicDelegatesBL');
if ((0 + Win32::OLE::LastError()) != -2147463155) {
print "+ is a delegate of\n";
foreach my $Desc (@{$delegateList}) {
print " $desc\n";
}
}
else {
print "+ Not a delegate for anyone\n";
}
|