I was still going through the script , but it seems the script as is only
prints out Domain controllers.. and also it died on me when i did not
provide any domain arguments.. my suggestion is to use the lanman module as
used in the script.. after much research .. found some documentation on the
lanman module here
http://www.cs.umd.edu/~marcolo/work/lanman.html
-----Original Message-----
From: Jos� Greg�rio [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 25, 2001 11:17 AM
To: Bullock, Howard A.; [EMAIL PROTECTED]
Subject: RE: Get Users.
Importance: High
Can I use the code above for get users from a DC (Domain Controller) ?
Thanks.
-----Original Message-----
From: Bullock, Howard A. [mailto:[EMAIL PROTECTED]]
Sent: quinta-feira, 25 de Outubro de 2001 16:23
To: 'Sibi John'; Perl (E-mail)
Subject: RE: Get Users.
Try this. It uses the Lanman module.
use Win32::Lanman;
use strict;
#===========================================================================
===
my $Program = "EnumerateNT.pl";
my $Version = "1.00";
my $Author = "Howard A. Bullock";
my $Created = "10-Sep-1999";
my $LastModified = "11-Sep-1999";
#===========================================================================
===
#
# This program enumerates visible NT servers by domain and role.
#
# Syntax: 'perl EnumerateNT.pl [Domain_name] [Domain_name] ...'
#
# Without the Domain_name parameter, all known domains are processed.
#
# The results are displayed to STDOUT and to the file 'EnumerateNT.log' in
the
# current directory.
#
#
============================================================================
======
print "\n------------------------------------------------------\n";
print "Program Name: $Program\n";
print " Version: $Version\n";
print " Author: $Author\n";
print " Created: $Created Last Modified: $LastModified\n\n";
if ($#ARGV <0) {
print "\nReporting servers and roles for ALL domains.\n";
} else {
print "\nReporting servers and roles for domains: @ARGV\n";
}
print "------------------------------------------------------\n\n";
my ($a, $cnt, $i, $keys, $domain, $server);
my @info = ();
my %machines = {};
my $err =0;
open(LOG, ">EnumerateNT.log") || die "Can not open log file in the current
directory!\n";
if ($#ARGV < 0) {
$domain = "amp01";
if(!Win32::Lanman::NetServerEnum("", $domain, SV_TYPE_DOMAIN_ENUM,
\@info))
{
$a = "$domain Error: " . Win32::Lanman::GetLastError();
map {print $_; print LOG $_;} "$a\n";
exit 1;
}
foreach $domain (@info)
{
($cnt, %machines) = &EnumDomain(${$domain}{'name'});
$i++;
$a += $cnt;
if ($machines{${$domain}{'name'}}{'PDC'} !~ s/\\\\//)
{$err++;}
map {print $_; print LOG $_;}
"${$domain}{'name'}\tPDC\t$machines{${$domain}{'name'}}{'PDC'}\n";
if ($machines{${$domain}{'name'}}{'BDC'} =~ /Error/i) {
map {print $_; print LOG $_;}
"${$domain}{'name'}\tBDC\t$machines{${$domain}{'name'}}{'BDC'}\n";
} else {
foreach $server (sort keys
%{$machines{${$domain}{'name'}}{'BDC'}}) {
map {print $_; print LOG $_;}
"${$domain}{'name'}\tBDC\t$server\n";
}
}
if ($machines{${$domain}{'name'}}{'SRV'} =~ /Error/i) {
map {print $_; print LOG $_;}
"${$domain}{'name'}\tSRV\t$machines{${$domain}{'name'}}{'SRV'}\n";
} else {
foreach $server (sort keys
%{$machines{${$domain}{'name'}}{'SRV'}}) {
map {print $_; print LOG $_;}
"${$domain}{'name'}\tSRV\t$server\n";
}
}
print "\n";
}
}
else {
foreach $domain (@ARGV) {
($cnt, %machines) = &EnumDomain($domain);
$i++;
$a += $cnt;
if ($machines{$domain}{'PDC'} !~ s/\\\\//) { $err++;}
map {print $_; print LOG $_;}
"$domain\tPDC\t$machines{$domain}{'PDC'}\n";
if ($machines{$domain}{'BDC'} =~ /Error/i) {
map {print $_; print LOG $_;}
"$domain\tBDC\t$machines{$domain}{'BDC'}\n";
} else {
foreach $server (sort keys
%{$machines{$domain}{'BDC'}}) {
map {print $_; print LOG $_;}
"$domain\tBDC\t$server\n";
}
}
if ($machines{$domain}{'SRV'} =~ /Error/i) {
map {print $_; print LOG $_;}
"$domain\tSRV\t$machines{$domain}{'SRV'}\n";
} else {
foreach $server (sort keys
%{$machines{$domain}{'SRV'}}) {
map {print $_; print LOG $_;}
"$domain\tSRV\t$server\n";
}
}
print "\n";
print LOG "\n";
}
}
print "Number of domains: $i\n";
print "Number of servers: $a\n";
print "Number of domain errors: $err\n";
print LOG "Number of domains: $i\n";
print LOG "Number of servers: $a\n";
print LOG "Number of domain errors: $err\n";
close LOG;
sub EnumDomain {
my $domain = shift;
my @info = ();
my %machines = {};
my $i = 0;
my $pdcname;
# Get PDC for domain.
if(!Win32::Lanman::NetGetDCName("", $domain, \$pdcname)) {
if(!Win32::Lanman::NetGetDCName("\\\\ambdc005", $domain,
\$pdcname)) {
$machines{$domain}{'PDC'} = "Error: " .
Win32::Lanman::GetLastError();
return ($i, %machines);
}
}
$machines{$domain}{'PDC'} = $pdcname;
$i++;
# Get BDCs
if(!Win32::Lanman::NetServerEnum($pdcname, $domain,
SV_TYPE_DOMAIN_BAKCTRL, \@info)) {
$machines{$domain}{'BDC'} = "Error: " .
Win32::Lanman::GetLastError();
}
foreach $server (@info) {
$i++;
$machines{$domain}{'BDC'}{${$server}{'name'}} = 1;
}
# Get Servers
if(!Win32::Lanman::NetServerEnum($pdcname, $domain,
SV_TYPE_SERVER_NT, \@info)) {
$machines{$domain}{'SRV'} = "Error: " .
Win32::Lanman::GetLastError();
}
foreach $server (@info)
{
$i++;
$machines{$domain}{'SRV'}{${$server}{'name'}} = 1;
}
return ($i, %machines);
}
-----Original Message-----
From: Sibi John [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 25, 2001 11:20 AM
To: Perl (E-mail)
Subject: Get Users.
Does anybody know how if there is anything in the Win32 module which will
allow u to get the computer names in the local network , just like NET
VIEW does . I could find how to get the users , but not the computers..
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin