You can read Dave Roth's articles published in the Windows IT Pro magazine (formally known as Windows .NET Magazine) that use Perl to accomplish interesting tasks.
Our Administrator's Handbook book is here and not a moment too soon! Win32 Perl Scripting: Administrator's Handbook
Available at Amazon.com
The 2nd edition of our Win32 Perl Programming: Standard Extensions is available.
Check out our recommended reading list.
Back to the Script Repository
You can download the script here.
use Win32::OLE; #requires Exchange 2000 post-SP3 hotfix as described in article: # http://support.microsoft.com/default.aspx?scid=kb;en-us;810913 # on the client you want to retrieve the info from # as well as the Exchange 2000 client tools (possibly, I'm not sure this though) if (scalar(@ARGV) != 2) { $exch_server = "EXCHSERVER";#change to your specific server name $dom_controller = "DOMAINCONTROLLER";#change to your specific server name } $objDsIpSec = Win32::OLE->new("ExIpSec.ExIpSecurity"); if (Win32::OLE->LastError() !=0) { print "Error creating new object (did you install the hotfix?)\n"; } $objDsIpSec->BindToSmtpVsi($exch_server, 1, $dom_controller); if (Win32::OLE->LastError() !=0) { print "Error binding to SMTP virtual server\n"; $objDsIpSec->ReleaseBinding();#let go of the binding, you're done now exit; } $objDsIpSec->GetIpSecurityList(); if (Win32::OLE->LastError() !=0) { print "Error Getting IP Security List\n"; $objDsIpSec->ReleaseBinding();#let go of the binding, you're done now exit; } if ($objDsIpSec->{GrantByDefault} == 1) { print "SMTP Access is granted by Default\n"; my @listToDisplayIp = $objDsIpSec->{IpDeny}; if (scalar(@listToDisplayIp[0]) > 0) { print "Deny list (IPs):\n"; foreach $val (@{@listToDisplayIp[0]}) { print " IP = $val\n"; } #push(@{@listToDisplayIp[0]},'192.168.4.1'); #push(@{@listToDisplayIp[0]},'192.168.5.1,255.255.255.0'); #$objDsIpSec->{'IpDeny'}=@listToDisplayIp[0]; #$objDsIpSec->WriteList(); } else { print " -No IP Denies are listed\n"; } my @listToDisplayDNS = $objDsIpSec->{DomainDeny}; if (scalar(@listToDisplayDNS[0]) > 0) { print "Deny list (DNS names):\n"; foreach $val (@{@listToDisplayDNS[0]}) { print " domain = $val\n"; } } else { print " -No DNS Denies are listed\n"; } } else { print "SMTP Access is denied by Default (wow, that's strict)\n"; } $objDsIpSec->ReleaseBinding();#let go of the binding, you're done now
Note: Neither Roth Consulting nor its affiliates are responsible for problems resulting from the misuse, modification or execution of any of the scripts on this web site. It is best that the the user read over the script carefully to insure that the code is not harmful to his environment.
This page has been viewed 1 times.