Discuss this help topic in SecureBlackbox Forum

FTPS: Set the virtual root directory for individual connection

There are two ways of specifying the root for individual connection:

  1. Use internal users storage maintained by TElSimpleFTPSServer in its Users property and set BasePath property of each user before the server is activated;
  2. Create the instance of the filesystem adapter in OnAuthAttempt event handler and set its BasePath dynamically:

    C#:

    
    static void Main(string[] args)
    {
    	TElSimpleFTPSServer Server = new TElSimpleFTPSServer();
    	Server.OnAuthAttempt += ElSimpleFtpsServerOnOnAuthAttempt;
    	...
    }
    
    private static void ElSimpleFtpsServerOnOnAuthAttempt(object sender, string username, string password, ref bool allow)
    {
    	allow = false;
    
    	SBSimpleFTPSServer.TElSimpleFTPSServerSessionThread Sender = sender as TElSimpleFTPSServerSessionThread;
    	try
    	{
    		User user = UserRepository.Login(username, password);
    		allow = true;
    
    		// Create a new instance of the filesystem adapter
    		Sender.FileSystemAdapter = new MyCustomFileSystemAdapter(nil);
    
    		// set the virtual root dynamically
    		Sender.FileSystemAdapter.BasePath = UsersVirtualRootDir;
    
    		return;
    	}
    	catch
    	{
    	}
    }
    

Also it is possible to combine both ways. In this case the event result will override results of the internal check.

How To articles about server-side FTPS questions

Discuss this help topic in SecureBlackbox Forum