Discuss this help topic in SecureBlackbox Forum

FTPS: Configure user authentication

There are two ways to authenticate server users available:

  1. Use internal users storage maintained by TElSimpleFTPSServer in its Users property:

    C#:

    
    	Server.Users.AddFTPSUser("UserName", "Password");
    	Server.Users.DeleteUser("UserName");
    
    Delphi:
    
    	Server.Users.AddFTPSUser('UserName', 'Password');
    	Server.Users.DeleteUser('UserName');
    

    TElSimpleFTPSServer will check the user password during authentication.
  2. Use the event based authentication using OnAuthAttempt event, the same as in TElFTPSServer:

    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