fwashbur has asked for the wisdom of the Perl Monks concerning the following question:
Hi Perl Monks
We have some code that has been working fine under Windows NT/XP but does not work on Windows 7. We are using Perl 5.6.1, and yes I know that using Perl 5.8 might be better as well as anything besides Windows for an OS, but we have a few million lines of Perl code running on several thousand machines around the world, so porting is difficult. Any help or insight that you could provide would be appreciated.
The following code is used to check permissions on a shared directory. It works from an XP system to a W7 system ie using path \\windows7\public, it works from XP to XP and XP to self, but if I use the same path on \\windows7 it fails to retrieve the security information.
my $GetFileSecurity = new Win32::API('Advapi32', 'GetFileSecurity', ['P', 'N', 'P', 'N', 'P'], 'N' ); sub GetFileSecurity { my $file = shift; my $bufSize = 1000; my $bufSD = pack("x$bufSize"); my $pbufNeeded = pack('x4'); my $strSD = ''; foreach my $infoRequest (1,2,4,8) { my $sd; if ($GetFileSecurity->Call($file, $infoRequest, $bufSD, $bufSize +, $pbufNeeded) ) { my $size = unpack('L', $pbufNeeded); my $binSD = substr($bufSD,0, $size); $strSD .= SD2Str($binSD); } } return $strSD; } my $ConvertSDToString = new Win32::API('Advapi32', 'ConvertSecurityDescriptorToStringSecur +ityDescriptor', ['P', 'N', 'N', 'P', 'P'], 'N' ); sub SD2Str { my $SD = shift; return undef if (!IsValidSD($SD)); my $rev = 1; my $info = 7; my $p1 = ' '; my $len = ' '; return '' if ( !$ConvertSDToString->Call($SD, $rev, $info, $p1, $le +n) ); my $str = unpack('p', $p1); return $str; }
Your help is greatly appreciated, thanks - Rick
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Calling Win32::API GetFileSecurity not working on Windows 7
by Illuminatus (Curate) on Sep 29, 2009 at 22:06 UTC | |
by fwashbur (Sexton) on Sep 30, 2009 at 00:25 UTC | |
|
Re: Calling Win32::API GetFileSecurity not working on Windows 7
by Anonymous Monk on Sep 30, 2009 at 04:47 UTC | |
by fwashbur (Sexton) on Sep 30, 2009 at 17:31 UTC |