Sorry, I just found this code snippet I had tucked away. Having it is one thing, knowing where you put it is another! :)
use Win32; use Win32::NetAdmin; use strict; my @all; Win32::NetAdmin::GetServers(undef, "MYDOMAIN", SV_TYPE_ALL, \@all); foreach my $computer(sort @all){ my ($name,$domain,$sid,$stype); Win32::LookupAccountName("\\\\$computer", $computer, $domain, $sid, $stype); my($Revision, $SubAuthorityCount,@IdentifierAuthorities) = unpack("CCnnn", $sid); my($temp, $temp2, @SubAuthorities) = unpack("VVV$SubAuthorityCount",$sid); print "\n$computer,S-$Revision-$IdentifierAuthorities[2]-".join("-",@SubAuthor ities); } -----Original Message----- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Barry Brevik Sent: Wednesday, July 18, 2012 2:45 PM To: Cordoni, Ray; perl Win32-users Subject: RE: Help with LookupAccountSID (again) Ay Caramba!! I thank you for the post, but my skills are too low to reverse that monstrosity! Barry Brevik -----Original Message----- From: Cordoni, Ray [mailto:rcord...@richmond.ca] Sent: Wednesday, July 18, 2012 11:38 AM To: Barry Brevik; perl Win32-users Subject: RE: Help with LookupAccountSID (again) Not sure if this helps, but long ago I had to convert a binary SID to a string - exactly the opposite of what you want! Here is the perl routine: ######################################################################## ######## # Translate binary objectsid to string value # ######################################################################## ######## sub SidToString { (my $sid) = @_; my $sid_str_hex = "S"; my $loop; return undef unless unpack("C", substr($sid, 0, 1)) == 1; return undef unless length($sid) == 8 + 4 * unpack("C", substr($sid, 1, 1)); for $loop (0 .. unpack("C", substr($sid, 1, 1)) - 1) { $sid_str_hex .= "-" . substr(unpack("H*", substr($sid, 4 * $loop + 8, 4)), 6, 2) . substr(unpack("H*", substr($sid, 4 * $loop + 8, 4)), 4, 2) . substr(unpack("H*", substr($sid, 4 * $loop + 8, 4)), 2, 2) . substr(unpack("H*", substr($sid, 4 * $loop + 8, 4)), 0, 2); } $sid_str_hex =~ s/-0*/-/g; return $sid_str_hex; } - Raymond Cordoni Manager of Web, GIS and Database City of Richmond - Information Technology 604-276-4003 rcord...@richmond.ca -----Original Message----- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Barry Brevik Sent: Wednesday, 18 July 2012 11:30 To: perl Win32-users Subject: Help with LookupAccountSID (again) Previously I had asked for help with Win32::LookupAccountSID(). Specifically, the call requires that the SID be in a binary format. One helpful user pointed me to this: http://code.activestate.com/lists/perl-win32-users/26301/ All of that works, except the article's author is first getting the binary SID from the Win32::LookupAccountName() call, which is a chicken and egg thing. I need to know how to convert a SID like this: '{S-1-5-21-1406052347-744958519-16733337701-1424}' ...into its equivalent binary form for use in the Win32::LookupAccountSID() call. Does anyone out there know how to do this? TIA, Barry Brevik _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs