#  DisplayADSIDomains.pl
#  Example 9.3:
#  ----------------------------------------
#  From "Win32 Perl Scripting: Administrators Handbook" by Dave Roth
#  Published by New Riders Publishing.
#  ISBN # 1-57870-215-1
#
#  This script displays the domains visible to the local machine by using
#  ADSI.
#
print "From the book 'Win32 Perl Scripting: The Administrator's Handbook' by Dave Roth\n\n";


use Win32::OLE qw( in );

$ADsPath = "WinNT:";
if( $AD = Win32::OLE->GetObject( $ADsPath ) )
{
    my $iCount = 0;
    print "Available domains:\n";
    foreach my $Domain ( in( $AD ) )
    {
        print "\t" . ++$iCount . ") $Domain->{Name}\n";
    }
}
