Hello,

I'm trying to get the permissions on a share using WMI. I've used WMI successfully for many tasks, but this one is a bit problematic.

The issue is how to call GetSecurityDescriptor in ActivePerl. I found a posting (http://www.mail-archive.com/[email protected]/msg03336.html) which indicates this uses a call-by-reference interface, which requires different handling. However, this doesn't work for me, as no data is returned.

Any suggestions appreciated.  Following is my code.

Regards, Brian


$shareSecCol = $WMI->ExecQuery("Select * from Win32_LogicalShareSecuritySetting where Name = 'TestShare'");


foreach my $shareSecSetting (in($shareSecCol))
{
        print "Name: $shareSecSetting->{Name}\n"; ## prints successfully

        # Ask the security setting object for the security descriptor.
        # The call-by-reference interface forces us to use a "Variant"
        # object here.
        my $var = Win32::OLE::Variant->new (VT_DISPATCH|VT_BYREF);
        my $ret = $shareSecSetting->GetSecurityDescriptor ($var);

        # Get the Win32_SecurityDescriptor from the variant.
        my $sd = $var->Get();
        print "SD: $sd\n";    ## Nothing is printed; s/b an object

        # Get the ACL, which is just an array of Win32_ACE objects.
        my @dacl = @{$sd->{'DACL'}};
        foreach my $ace (@dacl)  ## This loop isn't entered
        {
                my $trustee = $ace->{'Trustee'};
                $name = $trustee->{'Name'};
                print "Name: $name\n";
        }
}
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to