Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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 chilling in the Monastery: (10)
As of 2016-10-24 11:41 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (305 votes). Check out past polls.