You could do the if{...}elsif{...}elsif{...}else{...} things, but much simpler would be to set yourself up some hashes that will convert the strings to their bitmap constant values like this:

#! perl -sw use strict; use Win32::Perms; my %ACE_masks = ( FULL => FULL, # Full access (RWDXOP) ALL => ALL, # Same as FULL CHANGE => CHANGE, # Change access (RWDX) READ => READ, # Read access WRITE => WRITE, # Write access DELETE => DELETE, # Delete access EXECUTE => EXECUTE, # Execute access NO_ACCESS => NO_ACCESS, # No permissions specified ); my %ACE_types = ( ALLOW => ALLOW, # The permission mask is allowed GRANT => GRANT, # Same as ALLOW DENY => DENY, # Permission mask is denied AUDIT => AUDIT, # The permission mask is for auditin +g OWNER => OWNER, # The account specified is the OWNER + (the permission mask is ignored) GROUP => GROUP, # The account specified is the GROUP + (the permission mask is ignored) ); my %ACE_flags = ( DIRECTORY => DIRECTORY, # The permission is for a directory DIR => DIR, # Same as DIRECTORY KEY => KEY, # the permission is for a Registry k +ey CONTAINER => CONTAINER, # The permission is for a container +object (dir, Registry key, etc) FILE => FILE, # The permission is for a file NON_CONTAINER => NON_CONTAINER, # The permission is for +a non container object (file, etc) SUCCESS => SUCCESS, # If the type is AUDIT then this wil +l log a successful audit FAILURE => FAILURE, # If the type is AUDIT then this wil +l log a failed audit );

This is only a subset of those exported by Win32::Perms, but it may be enough for your needs.

You would use these in a snippet from your code like this:

... $perms->Add('MYDOMAIN\bloggJo', $ACE_masks{$ARGV[1]}|$ACE_masks{$ARGV[ +2]} ACCESS_ALLOWED_ACE_TYPE, OBJECT_INHERIT_ACE | CONTAINER_INHERIT_AC +E);

This will take the 2nd string that you supply on the command line as $ARGV[1] (ie. READ), use that as the key in the %ACE_masks hash and retreive the corresponding bit map. The same for the 3rd command line parm $ARGV[2] (WRITE) and do the same. It will then binary or (|) these together and then supply the result to Add().

If you need to supply a variable number of arguements, then you will need to loop over the @ARGV array, lookup the strings, oring the values into a scalar and then pass those.

If you get stuck with that, come back.


Well It's better than the Abottoire, but Yorkshire!

In reply to Re: Perms Perms Perms by BrowserUk
in thread Perms Perms Perms 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.