Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Set read-only
Message
From
28/01/1999 10:49:32
 
 
To
28/01/1999 09:34:42
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00181288
Message ID:
00181336
Views:
11
>I use SetFileAttributes API to set file's read-only attribute. I test 'read-only' from Dos command line and a file was read-only. I could not overwrite it with a copy. But in NT Explorer I overwrote it with no problem. Am I mssing something?

To clarify what Josh said a bit, the read-only flag can be overridden in Explorer; the flag is seen, but if the user has at least Change permissions on the file, Explorer can remove the read-only attribute and allow a copy or delete operation to take place.

BLocking this within Explorer is difficult at nbest. if the user has full access permission in the directory under Win9x or WinNT on a FAT partition, there is really nothing that can be done to prevent alteration or deletion of the file with any tool capable of using the same API call you used to set the read-only flag.

If this is an NTFS partition, you can set up file permissions on a file-by-file basis, so that only specific users have the necessary rights to alter or delete the file, even if they have write and change permissions in the directory. FAT partitions, even under WinNT, only support access right assignments at the directory level. If this is on and NT system on an NTFS partition, you can set the user permissions at the file level; I'd suggest buying a third party library to do this, as the API programming to manipulate ACLs and SDs is complex, and involves lots of pointers, so native VFP code isn't very good at it. I beleive that Paul Tatavu sells a product that might be able to help here.

You can also set access rights on the file level on NetWare volumes as well; check with your system administrator for details of how to use the GRANT and REVOKE commands to grant and revoke privileges. there's an API that is Novell-specific to manipulate the Novell equivalent of NT's permissions, and again, a third-party library is your best bet here (something like NETLIB, for example).
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform