Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: How can I get which Windows domain an IP belongs to?

by idsfa (Vicar)
on Oct 13, 2003 at 21:36 UTC ( #298954=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://298954]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2016-09-27 09:03 GMT
Find Nodes?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:

    Results (500 votes). Check out past polls.