Listing 1. Querying for All DCs in a Domain use strict; use Net::DNS; Begin comment # Specify the domain name on the command line # or use the default. End comment my $domain = $ARGV[0] || 'amer.xyz.com'; print "Querying for Domain Controllers in $domain\n"; # Begin callout A my $res = Net::DNS::Resolver->new(); # End callout A # Using nameservers() is optional. # Begin callout B # $res->nameservers(‘17.70.16.18’); # End callout B # Begin callout C my $query = $res->search("_ldap._tcp.dc._msdcs.$domain", "SRV"); # End callout C if ($query) { # Begin callout D foreach my $rr ($query->answer) { # End callout D next unless $rr->type eq "SRV"; print $rr->target,"\n"; } } else { die "DNS query failed: ", $res->errorstring, "\n"; }