I would be remiss in my monk duties if I did not begin with these cautions:

  1. You have a long, large Perl program in which you neither:
    1. use strict, nor
    2. use warnings (-w).
    In Perl programming, this is the equivalent of keeping a loaded gun pointed at your anesthetized foot. You *will* shoot yourself in the foot one day, and you may not even know it at the time it happens. *Please* take the time to adopt the strict and warnings habits, and to retrofit your code to work cleanly under their yoke. Most monks would be very happy to help teach you this.
  2. You posted large sample code, much of which was not relevant to your problem. To better understand why this is not in your own best interest, please read the "Post Only Relevant Code" section of How (Not) To Ask A Question.

Here is the first piece of the puzzle: From the Win32::AdminMisc FAQ, in the section on GetGroups:

If the 3rd parameter is an array reference then upon success the user names populate the array. If it is a hash reference then it is populated with the group name, comment, type (local or global) and if the it is a global group then the groups flags.

I wrote and ran this test code:
#!/usr/bin/perl -w use strict; use warnings 'all'; use Win32::AdminMisc; my $server = ''; # Use local machine. my %groups; Win32::AdminMisc::GetGroups($server, GROUP_TYPE_ALL, \%groups) or warn "Failed: $!, $^E"; foreach my $group (keys %groups) { printf "%s\t%s\n", $groups{$group}{type}, $group; } # Uncomment next two lines to see all data from %group hash. #use Data::Dumper; #print Dumper \%group;
I received this output:
global  None
local   Replicator
local   Users
local   Backup Operators
local   Administrators
local   Guests
local   Power Users

What do you get when you run this code on a server that you "right-clicked and selected" on? How does it differ from what you expected?

I can add this code:
use Win32::FileSecurity; my $filename = 'C:/WINNT/twain_32'; my %hash; Win32::FileSecurity::Get($filename,\%hash) or warn "Get failed: $!"; while ( my ( $ACL_owner, $mask ) = each %hash ) { $ACL_owner =~ s{.+\\}{}; my @perms; Win32::FileSecurity::EnumerateRights($mask, \@perms) or warn "Enumerate failed: $!"; my $ACL_owner_type = $groups{$ACL_owner}{type} || 'User'; print "$ACL_owner ($ACL_owner_type):\n"; @perms = $perms[0]; # only print one permission while testing. print "\t\t\t$_\n" foreach @perms; }
and receive this output:
Administrators (local):
                        DELETE
CREATOR OWNER (User):
                        GENERIC_ALL
Power Users (local):
                        DELETE
SYSTEM (User):
                        DELETE
Users (local):
                        READ_CONTROL

I think that solves part 2 of your question. Let me know if any of my code needs further explanation.

If you will answer the question I posed above (right after the first block of output), then perhaps the answer to part 1 will be clearer to myself or another monk.


In reply to Win32 ACLs: Local vs Global groups by Util
in thread Directory level access by blackadder

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.