lock a file
-
is it possible to lock a file so that only a certain application has privelege to write to it? how? i want to create an application that makes use of a log file such that the log file cannot be modified outside the application. Also, this means that only those users that have access to run my application will be able to modify the log file (through the application). thanks in advance.
I am a SysAdmin, I battle my own daemons.
-
is it possible to lock a file so that only a certain application has privelege to write to it? how? i want to create an application that makes use of a log file such that the log file cannot be modified outside the application. Also, this means that only those users that have access to run my application will be able to modify the log file (through the application). thanks in advance.
I am a SysAdmin, I battle my own daemons.
Have the application open the file and set the sharing appropriately: See: * File.Open[^] * FileShare[^]
Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: Introduction to AJAX (2nd May), SQL Server, Mock Objects My website
-
Have the application open the file and set the sharing appropriately: See: * File.Open[^] * FileShare[^]
Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: Introduction to AJAX (2nd May), SQL Server, Mock Objects My website
Hi Colin Angus Mackay, I think DenClancy wants that a file ( even if a simple text file ) must not be opened without a particular application. Is this possible ? What if an Admin user tries to open this file ? Actually I wanted to restrict access to some files, even if the files are simple text files (even to admin users). I heard about something called Access Control List. Is it applicable here ? I dont know the details of ACL. If possible, please reply in details. Thanks.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
-
Hi Colin Angus Mackay, I think DenClancy wants that a file ( even if a simple text file ) must not be opened without a particular application. Is this possible ? What if an Admin user tries to open this file ? Actually I wanted to restrict access to some files, even if the files are simple text files (even to admin users). I heard about something called Access Control List. Is it applicable here ? I dont know the details of ACL. If possible, please reply in details. Thanks.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
coolestCoder wrote:
Is this possible ?
As I pointed out, the application can deny others the ability to do anything but read the file. Or it can take exclusive control over the file too. See the previous links to FileShare.
coolestCoder wrote:
What if an Admin user tries to open this file ?
Yes, even an administrator - Try it with a SQL Server database file. You won't be able modify it regardless of who you are logged in as because the SQL Server process has control over it. Not even someone logged on as the same user as SQL Server can access the file.
coolestCoder wrote:
ctually I wanted to restrict access to some files, even if the files are simple text files (even to admin users).
You can change the permissions on a file as you need it. I'm not sure if you can lock an admin out though. If it is possible then it would only be a temporary situation as the admin would have the ability to grant themselves access again.
-
coolestCoder wrote:
Is this possible ?
As I pointed out, the application can deny others the ability to do anything but read the file. Or it can take exclusive control over the file too. See the previous links to FileShare.
coolestCoder wrote:
What if an Admin user tries to open this file ?
Yes, even an administrator - Try it with a SQL Server database file. You won't be able modify it regardless of who you are logged in as because the SQL Server process has control over it. Not even someone logged on as the same user as SQL Server can access the file.
coolestCoder wrote:
ctually I wanted to restrict access to some files, even if the files are simple text files (even to admin users).
You can change the permissions on a file as you need it. I'm not sure if you can lock an admin out though. If it is possible then it would only be a temporary situation as the admin would have the ability to grant themselves access again.
Hi! I think the real question is how to permanently lock a file without an application that has to keep the file handle open all the time. Sure you can set FileShare to None, but the moment your application ends anyone can access the file again. The original poster wanted a way to deny access to a file for everybody even after the application has finished.
Regards, mav -- Black holes are the places where God divided by 0...
-
is it possible to lock a file so that only a certain application has privelege to write to it? how? i want to create an application that makes use of a log file such that the log file cannot be modified outside the application. Also, this means that only those users that have access to run my application will be able to modify the log file (through the application). thanks in advance.
I am a SysAdmin, I battle my own daemons.
I think you could achieve something similar if you can create a separate user with a random password only your application knows and have your application set the access rights for the file so that only this particular user has access rights. But an administrator could take ownership of the file and thus modify the access rights anyway...
Regards, mav -- Black holes are the places where God divided by 0...