http://qs1969.pair.com?node_id=298954


in reply to How can I get which Windows domain an IP belongs to?

The easy way. (untested)

use Net::NBName; my $nb = Net::NBName->new; while(my $addr=<>) { chomp $addr; my $ns = $nb->node_status($addr); if ($ns) { ($dom) = grep {$_->suffix == '\0' && $_->G eq "GROUP"} $ns->names(); print "$addr ".$dom->name()."$/"; } }

The hard way (without CPAN). (tested)

while(my $addr=<>) { my $domain = "(undetermined)"; chomp $addr; open(NMB,"nbtstat -A $addr |"); while(<NMB>) { ($domain) = m/(\w+)/ if (/GROUP/ && /<1E>/); } close NMB; print "$addr $domain$/"; }

Remember, when you stare long into the abyss, you could have been home eating ice cream.