#!/usr/bin/perl -w

use Win32::NetAdmin;

$status = Win32::NetAdmin::GetDomainController('', '', $pdc );

if ($status) {
   print "Primary Domain Controller is: $pdc\n";
} else {
   print_error();
}

sub print_error {
    print Win32::FormatMessage( Win32::GetLastError() );
}