RE: Help with LookupAccountSID (again)
Wow, that looks very promising. I'll try it tonight and write my results back tomorrow. Pure Perl. I guess that I should have looked at Win::32::Security::SID instead of just dismissing it over worries that it would not be supported by modern versions of Perl. I expected it to make some kind of call into an XS module or something. Thank you for posting, Barry Brevik -Original Message- From: Steven Manross [mailto:ste...@manross.net] Sent: Wednesday, July 18, 2012 5:07 PM To: Barry Brevik; perl Win32-users Subject: RE: Help with LookupAccountSID (again) What about the following... Excerpt from: http://cpansearch.perl.org/src/TEVERETT/Win32-Security-0.50/lib/Win32/Se curity/SID.pm [>] -- 8<-(snip) ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Help with LookupAccountSID (again)
What about the following... Excerpt from: http://cpansearch.perl.org/src/TEVERETT/Win32-Security-0.50/lib/Win32/Se curity/SID.pm sub ConvertStringSidToSid { my($text) = @_; my(@Values) = split(/\-/, $text); (shift(@Values) eq 'S' && scalar(@Values) >= 3) or return; my $Revision = shift(@Values); my $IdentifierAuthority = shift(@Values); if (substr($IdentifierAuthority, 0, 2) eq '0x') { $IdentifierAuthority = pack("H12", substr($IdentifierAuthority, 2)); } else { $IdentifierAuthority = pack("nN", 0, $IdentifierAuthority); } return pack("CCa6V*", $Revision, scalar(@Values), $IdentifierAuthority, @Values); } -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 11:30 AM 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-1677701-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
RE: Help with LookupAccountSID (again)
Thank you again. I saw that, but it looks like it might not be available to Perl 5.14 and I am looking to upgrade. Barry Brevik -Original Message- From: Howard Tanner [mailto:tan...@optonline.net] Sent: Wednesday, July 18, 2012 12:11 PM To: Barry Brevik Cc: Perl-Win32-Users@listserv.ActiveState.com Subject: RE: Help with LookupAccountSID (again) Found a Perl solution. Here you go: http://search.cpan.org/dist/Win32-Security/lib/Win32/Security/SID.pm -Original Message- From: Barry Brevik [mailto:bbre...@stellarmicro.com] Sent: Wednesday, July 18, 2012 2:46 PM To: Howard Tanner; Perl-Win32-Users@listserv.ActiveState.com Subject: RE: Help with LookupAccountSID (again) I tried to implement that call using Win32::API, but I just don't know enough about Windows to make it work. Thank you for posting, Barry Brevik -Original Message- From: Howard Tanner [mailto:tan...@optonline.net] Sent: Wednesday, July 18, 2012 11:31 AM To: Barry Brevik; Perl-Win32-Users@listserv.ActiveState.com Subject: RE: Help with LookupAccountSID (again) Sorry, forgot to copy the group. Here's what I sent to Barry: The Win32 API to do that is ConvertStringSidToSid: http://msdn.microsoft.com/en-us/library/windows/desktop/aa376402(v=vs.85 ).as px My Perl isn't strong enough to know how to call this from Perl, but I'm sure someone stronger in Perl could handle it. -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:30 PM 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-1677701-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
RE: Help with LookupAccountSID (again)
Found a Perl solution. Here you go: http://search.cpan.org/dist/Win32-Security/lib/Win32/Security/SID.pm -Original Message- From: Barry Brevik [mailto:bbre...@stellarmicro.com] Sent: Wednesday, July 18, 2012 2:46 PM To: Howard Tanner; Perl-Win32-Users@listserv.ActiveState.com Subject: RE: Help with LookupAccountSID (again) I tried to implement that call using Win32::API, but I just don't know enough about Windows to make it work. Thank you for posting, Barry Brevik -Original Message- From: Howard Tanner [mailto:tan...@optonline.net] Sent: Wednesday, July 18, 2012 11:31 AM To: Barry Brevik; Perl-Win32-Users@listserv.ActiveState.com Subject: RE: Help with LookupAccountSID (again) Sorry, forgot to copy the group. Here's what I sent to Barry: The Win32 API to do that is ConvertStringSidToSid: http://msdn.microsoft.com/en-us/library/windows/desktop/aa376402(v=vs.85 ).as px My Perl isn't strong enough to know how to call this from Perl, but I'm sure someone stronger in Perl could handle it. -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:30 PM 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-1677701-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
RE: Help with LookupAccountSID (again)
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-1677701-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
RE: Help with LookupAccountSID (again)
I tried to implement that call using Win32::API, but I just don't know enough about Windows to make it work. Thank you for posting, Barry Brevik -Original Message- From: Howard Tanner [mailto:tan...@optonline.net] Sent: Wednesday, July 18, 2012 11:31 AM To: Barry Brevik; Perl-Win32-Users@listserv.ActiveState.com Subject: RE: Help with LookupAccountSID (again) Sorry, forgot to copy the group. Here's what I sent to Barry: The Win32 API to do that is ConvertStringSidToSid: http://msdn.microsoft.com/en-us/library/windows/desktop/aa376402(v=vs.85 ).as px My Perl isn't strong enough to know how to call this from Perl, but I'm sure someone stronger in Perl could handle it. -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:30 PM 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-1677701-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
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-1677701-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
RE: Help with LookupAccountSID (again)
Sorry, forgot to copy the group. Here's what I sent to Barry: The Win32 API to do that is ConvertStringSidToSid: http://msdn.microsoft.com/en-us/library/windows/desktop/aa376402(v=vs.85).as px My Perl isn't strong enough to know how to call this from Perl, but I'm sure someone stronger in Perl could handle it. -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:30 PM 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-1677701-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
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-1677701-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