This is actually a somewhat peculiar case, thanks for bringing it to our attention.
This particular Exists
call was not made via the server, but rather from the FileServerUser constructor:
new FileServerUser(e.UserName, null, sftpFileSystem, virtualDirectory);
Purpose of the Exists
call is to check whether the virtualDirectory
actually exists, to prevent the server from failing later when SFTP protocol is getting initialized.
However, the FileServerUser
constructor is not aware of the context because it has not been set yet, so that single Exists
call can't really behave as documented. So, indeed, it's an expected (but undocumented) behavior.
I'm not quite sure how to best address this (apart from updating the documentation). But there is a workaround involving an undocumented SkipVirtualRootPathCheck option that disables the Exists
call. Instead of your FileServerUser
constructor call, use this:
var user = new FileServerUser(e.UserName, null);
Rebex.Security.Cryptography.CryptoHelper.SetOption(user, "SkipVirtualRootPathCheck", true);
user.SetFileSystem(sftpFileSystem, virtualDirectory);
This option was added to address another problem, but it's apparently useful here as well.