JeffreyHoward has asked for the wisdom of the Perl Monks concerning the following question:

We have a perl script in place that we use to set permissions on our Win NT 4.0 system(s), but can't figure out how to set the permissions if we have to add a Domain to the user (name).

The script uses Win32::FileSecurity module to access NT filesystem permissions. Setting permission however is done in two steps:

1.) A permission mask is generated from user friendly settings

while (($usr,$mask) = each %PERMISSIONS) #set the permissions

{$PERMISSIONS{$usr}=MakeMask($mask);}

2.) Permission mask is then applied to the file.

Set($file,\%$perm) ;

Here is a copy of the script that we are trying to execute:
use Win32::FileSecurity qw(MakeMask Get Set); #file premissions sub set_permission{ my($file, $perm)=@_; Set($file,\%$perm) ; } %PERMISSIONS=("CTSDEV\\Domain Admins"=>"F", "Everyone"=>"C", "Production Control"=>"F", "Systems & Technology"=>"C"); while (($usr,$mask) = each %PERMISSIONS) #set the permissions {$PERMISSIONS{$usr}=MakeMask($mask);} set_permission("\\\\ctscolfpadev\\acpt\\phrem\\bin\\test.exe",\%PERMIS +SIONS) or die "Just couldn't\n";
Any suggestions or help with this would be great!! Thanks...

Replies are listed 'Best First'.
(tye)Re: Setting Win NT permissions
by tye (Sage) on Apr 17, 2001 at 18:38 UTC

    There is a bug in the Win32::FileSecurity module. It would be easy to fix if the module had been written with all of the "interesting" code in Perl (I hate modules that write more than trivial amounts of code in C that could be done in Perl).

    Anyway, the problem is that they split the name at the \ and use the first part as a server name.

    The work-around is pretty easy; you use the name of a domain controller rather than the name of the domain. If you don't know the name of a domain controller, then do:

    use Win32::NetAdmin; Win32::NetAdmin::GetAnyDomainController("","CTSDEV",$dc) or die "Can't find domain controller for CTSDEV: $^E\n"; $PERMISSIONS{"$dc\\Domain Admins"}= "F";

            - tye (but my friends call me "Tye")

      I tried running what you sent, but I keep getting the following:

      Can't find domain controller for CTSDEV: The system could not find the environment option that was entere

      I even tried using the Domain Controller name in the original script, but after the script runs I don't get the Domain name before the group name.

Re: Setting Win NT permissions
by idnopheq (Chaplain) on Apr 18, 2001 at 06:58 UTC