Page 1 of 1

Checking what user has accessed a file (.Net)

Posted: 2008-03-31 05:15am
by atg
For a quick project I'm working on in VB.Net I want to track when users have accessed a file. Example:

testfile.txt exists on a drive. When a user opens or edits the file, I wish to record what time and who edited it.

I've been able to use the FileSystemWatcher to determine when the file is edited, etc, but I'm trying to work out how to determine what user accessed it.

As far as programming goes its only really a hobby for me so any help would be much appreciated.

Posted: 2008-03-31 08:30am
by Ace Pace
Probably relies on event logging of security events being enabled, but pull the event log and work backwards, whats the last user that logged on.
I'm pretty sure .Net has capability for that, I could look up MSDN for you.

Another method is probably getting the active user from the shell, this should be possible, though probably by importing another DLL. :?

Posted: 2008-03-31 09:34am
by Xon
Enable audit logging (local security policy) and then enable audit logging in on the files in question.

This will record accesses to various things, will generate a double-wide metric fuckton of eventlogs.

Posted: 2008-03-31 09:18pm
by atg
Xon wrote:Enable audit logging (local security policy) and then enable audit logging in on the files in question.

This will record accesses to various things, will generate a double-wide metric fuckton of eventlogs.
Sounds like the best way to go. Thanks for the advice.