Hello,

I've managed to reduce some code I have been using to
an acceptable minimum that will allow duplication of
the problem I'm seeing.  The code is only 40 lines.
The code below has an array initialized with some
windows machine names.  The code attempts to attach to
the registry of each machine.  These machines are all
active on the network.  I have remote registry access
to the first two machines in the array but not the
rest.  I'm hoping it should be fairly easy for someone
to duplicate this situation.
Anyway, the actaul problem I'm experiencing is that if
I do not have permission to connect to a remote
registry the code should - after about 35 seconds -
print "unable to connect to registry!" and then move
on to the next machine.  It does this fine.
However if I uncomment the line that reads:
$text_sid = SID_bin2text($sid);
the code is then stuck when attempting to connect to
the registry of a machine I do not have rights to. It
sits there forever and I don't get the "unable to
connect to registry!" message.
How can I fix this problem?

Thanks,
PJ

code is below
***********
use Win32::TieRegistry( Delimiter=>"#" );
use Win32;

$nodename = $ENV{COMPUTERNAME};
$domain = "dpcdom";
@node_list = ("adledsu11", "adldpca03",
"dpc011510141", "dpc011510143", "dpc011510157");
foreach $node (@node_list) {
        print "\n$node\n";
        undef $hkey_connect;
        $Register =
"SYSTEM#CurrentControlSet#Control#ProductOptions";
        if ($nodename eq $node) {
                $hkey_connect = $Registry->{"LMachine#"};
        } else {
                $hkey_connect = $Registry->Connect($node,
"LMachine#", {Access=>KEY_READ});
        }
        if ($hkey_connect) {
                print "successful connection to $node ...\n";
                $server_role =
$hkey_connect->{"$Register#ProductType"};
                print " server_role is $server_role\n";
# # # Get Administrator account text SID
                if ($server_role eq "Primary Domain Controller" or
$server_role eq "Domain Controller") {
                        Win32::LookupAccountName("\\\\$node", $domain,
$garbage, $sid, $sid_type);
                } else {
                        Win32::LookupAccountName("\\\\$node", $node,
$garbage, $sid, $sid_type);
                }
                my $text_sid = "default";
#               $text_sid = SID_bin2text($sid);
                print " text_sid is $text_sid\n";
        } else {
                print "unable to connect to registry!\n";
        }
}

sub SID_bin2text {
  my($bin) = @_;
  my ($Revision, $SubAuthorityCount,
@IdentifierAuthorities) = unpack("CCnnn", $bin);
  ($IdentifierAuthorities[0] ||
$IdentifierAuthorities[1]) and return;
  my($temp, $temp2, @SubAuthorities) =
unpack("VVV$SubAuthorityCount",$bin);
  return
"S-$Revision-$IdentifierAuthorities[2]-".join("-",@SubAuthorities);
}
***********


Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to