Identifying the user who does any operation on fileserver

.net , csharp Japan
  • 12 years ago

     Hi,

    I need to monitor my fileserver.I am using Filewatcher class for achieving that.Now i want to keep track of the user who has created,renamed or deletes any file or folders in the fileserver so that i can send a mail to him and can have the list which users have used the fileserver and when.

    I am not getting how can i keep track of the user as windows authentication wont work.Any idea is appreciable?

    I also have to run this application as a service.
    Since i am new to this could anybody help me by telling the steps to run the application as a service so that it monitors the server every 1 minute? 

  • 12 years ago

    Hi,

    I may have a partial solution. On XP and Vista (part of NTFS I believe), you have Auditing functionality. If you open the properties of your folder in Explorer, go to Security, then Advanced, you should see a new window with an Auditing tab. You can add a user, ("everyone" if you like), and then select the success and fail logging to enable. Back to the previous window, de-check "include inheritable auditing entries ..." and check "replace all existing ..."

    This will log all folder access to the event viewer under the Security group. Now you can write your service to filter and generate e-mails from this log using the EventLog component.

    Perhaps you can do all this programatically without the EventLog. I'd like to know if this will work for you.

  • 12 years ago

    Hmm i might have a solution for you. When the file is open via the network windows records this, or rather you can get that session information. including username etc.

     for that take a look at these api groups http://msdn.microsoft.com/en-us/library/bb525396(VS.85).aspx and http://msdn.microsoft.com/en-us/library/bb525380(VS.85).aspx

    how ever, as far as i know, you can't really subscribe to any callbacks for this. you're left poling for these. And as we all know, busywaits are expensive, so the next part of the solution comes in.

     use the FileSystemWatcher to monitor the root folder where your files are kept. on any activity, changed,deleted,rename etc, poll de apis (which return quite quickly). http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx

    i think these two in conjunction should do what you want.

    Also, a tip for the apis, use http://www.pinvoke.net to find the right .net syntax, quite a handy site, i myself use it alot :)

     Hope this helps.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“There's no test like production” - Anon