0 votes
by (160 points)
edited by

I want to prevent the users from crating subdirectories on my sftp server.

I tried PathAccessAuthorization, but I have no idea how I can find out whether the user is trying to create a file (allowed) or a folder (forbidden).

1 Answer

+1 vote
by (5.3k points)
edited by
 
Best answer

Hi Matthias,
welcome to the Rebex forum. You can use for this scenario our new API.

1) Create LocalFileSystemProvider

    private LocalFileSystemProvider createFileSystem()
    {
        var localFileSystem = new LocalFileSystemProvider(@"<<your path>>");
        //subscribe to CreatePreview event
        localFileSystem.GetFileSystemNotifier().CreatePreview += (sender, args) =>
        {
            if (args.Node.IsDirectory)
            {
                args.CancelOperation();
            }
        };

        return localFileSystem;
    }

2) Use FileSystemProvider.

 _fileSystem = createFileSystem();
 _user01 = new FileServerUser(_username, _password, _userVirtualRoot);
_server.Users.Add(_user01);
_user01.SetFileSystem(_fileSystem);

Please note that LocalFileSystemProvider is a part of the new file system API (https://www.rebex.net/file-server/features/virtual-file-systems.aspx), which is available since Version 2017 R4 (https://www.rebex.net/total-pack/history.aspx#2017R4)

...