How to know the user context within a custom ReadWriteFileSystemProvider

0 votes
asked Sep 10 by scottpbutler11 (150 points)

We have implemented a custom File system provider derived from the ReadWriteFileSystemProvider class for our sftp erver. We would like to be able to log session information when a file/directory is created or deleted. I do not see any way to do this. For example, how could I do this in the following method we have overwritten?
protected override NodeBase Delete(NodeBase node)
{
...
}

Applies to: File Server, Rebex SFTP

1 Answer

0 votes
answered Sep 10 by renestein (3,870 points)

Hi,
you are looking for ServerSession.Current property.

 var session = ServerSession.Current;

In the 'Delete' method.

 protected override NodeBase Delete(NodeBase node)
    {
       var myContext = ServerSession.Current.Context;
      _fileSystemNodes.Remove(node.Path);
      return node;
    }

Remark for other visitors of the Rebex forum.
Please be aware that ServerSession.Current can be null when the FileSystemProvider is running outside the FileServer.

commented Sep 10 by scottpbutler11 (150 points)
Perfect!  Just what I was looking for.
...