EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Setting BasePath using Authorization Username

Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages
Posted: 05/16/2013 17:14:45
by Tom Garrison (Priority Standard support level)
Joined: 05/16/2013
Posts: 15

I am setting up a server using TElSimpleFTPSServer and can't figure out how to set the BasePath for my FileAdapter using information from OnAuthAttempt. I would like to make the usename the BasePath. Currently I am reading this information from a config. I am using a custom FileAdapter class that inherits from TElCustomFileSystemAdapter.

Ideally pass the data from this method:

private static void AuthAttempt(object sender, string username, string password, ref bool allow)

to my custom FileAdapter class.

I can't figure out if the login info. is stored in context somewhere. Any help would be greatly appreciated.
Posted: 05/17/2013 00:21:24
by Vsevolod Ievgiienko (Team)

Thank you for contacting us.

You can set BasePath inside AuthAttempt event handler this way:

TElSimpleFTPSServerSessionThread thread = (TElSimpleFTPSServerSessionThread)Sender;
thread.FileSystemAdapter = new TElDiskFileSystemAdapter();
thread.FileSystemAdapter.BasePath = ...;

Each instance of TElSimpleFTPSServerSessionThread represents a single thread that serves a single user.
Posted: 05/17/2013 08:41:10
by Tom Garrison (Priority Standard support level)
Joined: 05/16/2013
Posts: 15


Thanks for your response. However, I am not using the TELDiskFileSystemAdapter. I am hooking into Azure, so I had to create my own custom one setting the blob storage location based on configuration. Now I would like to set it based on username.

So let's say I follow your example above:
.TElSimpleFTPSServerSessionThread thread = (TElSimpleFTPSServerSessionThread)Sender;
thread.FileSystemAdapter = new AzureFileAdapter();
thread.FileSystemAdapter.BasePath = ...;

How would I access the BasePath in the AzureFileAdapter constructor?

public AzureFileAdapter()
var cnString = CloudConfigurationManager.GetSetting("BlobStorage")
_storageAccount = CloudStorageAccount.Parse(cnString);
_blobClient = _storageAccount.CreateCloudBlobClient();

(CloudConfigurationManager.GetSetting("FTPContainer") + "/" + ????BasePath????);

Posted: 05/17/2013 08:48:46
by Vsevolod Ievgiienko (Team)

You can access it using FBasePath protected variable of TElCustomFileSystemAdapter but it won't be initialized while the constructor is being executed. You can pass it as a parameter to the constructor.

Please use code tag for the code.
Posted: 05/17/2013 09:14:35
by Tom Garrison (Priority Standard support level)
Joined: 05/16/2013
Posts: 15

I will give that a try Vsevolod. I'm a bit confused on passing it as a parameter in the constuctor. I have to set the FileAdapter when I spin up the FTPSErver. I won't have any data to pass during initialization. So I guess I can set a default base path when I spin it up and then update it during AuthAttempt?

This is how I am initializing the SimpleFTPSServer.

var adapter = new AzureFileAdapter();
            _server = new TElSimpleFTPSServer
                FileSystemAdapter = adapter,
                Port = port,
                Host = host,
                PassiveModeHost = passivehost,
                ImplicitSSL = false,
                DataPortRangeFrom = dataPortRangeFrom,
                DataPortRangeTo = dataPortRangeTo,
                AllowAnonymous = false,
                CertStorage = certStorage

Sorry about forgetting the code tags.
Posted: 05/17/2013 09:22:36
by Vsevolod Ievgiienko (Team)

You should not set FileSystemAdapter to an instance of AzureFileAdapter when you initialize TElSimpleFTPSServer. Instead you should do this inside AuthAttempt event handler:

TElSimpleFTPSServerSessionThread thread = (TElSimpleFTPSServerSessionThread)Sender;
thread.FileSystemAdapter = new AzureFileAdapter(username);
Posted: 05/17/2013 13:13:15
by Tom Garrison (Priority Standard support level)
Joined: 05/16/2013
Posts: 15

That worked thanks! I didn't realize I could initialize TEISimpleFTPSServer without FileSystemAdapter. I didn't see that in any of your documentation.
Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.



Topic viewed 960 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!