Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 6th, 2001, 12:54 PM
unobserved unobserved is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Posts: 11 unobserved User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to unobserved
does anyone know how so toggle read only file access on an NT machine from inside a script?

thanks in advance.

Reply With Quote
  #2  
Old April 9th, 2001, 05:22 AM
bigbirdie bigbirdie is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Toronto
Posts: 0 bigbirdie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by unobserved
does anyone know how so toggle read only file access on an NT machine from inside a script?

thanks in advance.




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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > NT permissions from perl


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT