|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
does anyone know how so toggle read only file access on an NT machine from inside a script?
thanks in advance. |
|
#2
|
|||
|
|||
|
Quote:
You are going to need to use the Win32::FileSecurity set(<file>,<%DACLhash>) command to set the permissions using a DACL hash variable or Descritionary Access Control List, value (read, full, etc). Whats a DACL ? "A discretionary ACL determines which users and groups can and cannot access the object, and it is controlled by the owner of the object or anyone that has been granted the right to change the permissions of the object. " ....These DACL's or priveleges are not like Win32's R, H , A ,S nor like Unix's UGO, rwx system. Anyways, its an example will clarify... use Win32::FileSecurity qw (MakeMask Set); # #Here are the various permission masks# $dir_perms_read = MakeMask (qw (READ GENERIC_READ GENERIC_EXECUTE)); $dir_perms_full = MakeMask (qw (FULL GENERIC_ALL)); ##Users# $f = "testuser"; $e = "everyone"; $fD = "\\PLU\\testuser";#permission hash for RWX on General $dir_RX{$f} = $dir_perms_read; $dir_RX{$e} = $dir_perms_read; $dir_RX{$fD} = $dir_perms_full;#here's where the work is done $filename = "d:/scripts/lab/perms/read.txt"; open (FILE, $filename) || die "Can't open file: $filename";@file = <FILE>; foreach $file (@file) { chomp($file); print %dir_RX,"\n"; #check the hash print ("Setting permissions on $file.\n"); Set($file, \%dir_RX) || die "Could not set the DACLfor $_: $!\n"; print ("Moving on to next file.\n"."\n"); } #--END-- Casey FeskensLab Manager/Software Support Specialist Computing and Telecommunication ServicesPacific Lutheran University Tacoma, WA 98447Phone: (253) 535-7525Fax: (253) 536-5099E-mail: feskencj@plu.edu |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > NT permissions from perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|