sub getEffectiveRights { my $object = $_[1]; my $objectType = $_[2]; my $binarySid = $_[3]; my $error = undef; my $result = undef; # Establish variables. my $psidOwner; my $psidGroup; my $pDacl; my $pSacl; my $pSecurityDescriptor; try { $logger->debug("Object: $object"); # Call GetNamedSecurityInfo. This is to get the DACL. ($psidOwner, $psidGroup, $pDacl, $pSacl, $pSecurityDescriptor) = Win32::Security::Raw::GetNamedSecurityInfo( $object, $objectType, 'DACL_SECURITY_INFORMATION'); print "returned from Win32::Security::Raw::GetNamedSecurityInfo\n"; unless (defined($pDacl)) { throw Error::Simple("An error occurred trying to access the discretionary access control entries for security object '" . $object . "'."); } # Build the trustee structure. my $trustee = System_Functions->buildTrusteeWithSid($binarySid); # Get the access mask. $result = System_Functions->getEffectiveRightsFromAcl($pDacl, $trustee); } catch Error::Simple with { $error = shift; print "error = $error\n"; } finally { # Clear memory. if (defined($pSecurityDescriptor)) { Win32::Security::Raw::LocalFree($pSecurityDescriptor); } }; if (defined($error)) { throw Error::Simple("Could not access '$object'. Verify that it exists and that you have permission to access it. $error"); } return $result; }