EldoS | Feel safer!

Software components for data protection, secure storage and transfer

How to tell which user is requesting write

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
#16216
Posted: 04/14/2011 13:55:33
by Andy Blum (Basic support level)
Joined: 04/14/2011
Posts: 3

I am evaluating the use of Secure Blackbox. I want to be able to tell which user is requesting to write the file within a SBSftpCommon.TElSFTPServerWriteEvent delegate implimentation.
#16217
Posted: 04/14/2011 14:41:08
by Ken Ivanov (EldoS Corp.)

Thank you for contacting us.

Each TElSSHServer or TElSFTPServer object corresponds to a single user - that is, you will have independent TElSSHServer and TElSFTPServer objects for every other connected user.

You can use the Tag property of TElSSHServer or TElSFTPUser to keep information about the user. For instance, you can assign this value inside the OnAuthAttempt event:
Code
private void SSHServer_OnAuthAttempt(object Sender, string Username, int AuthType, ref bool Accept)
{
    ...
    ((TElSSHServer)Sender).Tag = Username;
}


I suggest you to have a look at the SSH server sample. It illustrates one of the ways of handling this information.
#16218
Posted: 04/14/2011 15:04:43
by Andy Blum (Basic support level)
Joined: 04/14/2011
Posts: 3

That makes sense. However, what am I supposed to unbox the sender object to within the SFTPSession CLASS. There is no TelSSHServer object that I can see to be able to reference. I have read the whole SFTP Server example.
#16219
Posted: 04/14/2011 15:14:06
by Ken Ivanov (EldoS Corp.)

Well, you can put a reference to TElSSHServer object to TElSFTPServer.Tag property, and the username to the TElSSHServer.Tag property:

Code
private void SSHServer_OnAuthAttempt(object Sender, string Username, int AuthType, ref bool Accept)
{
    ...
    ((TElSSHServer)Sender).Tag = Username;
}

private void SSHServer_OnOpenSubsystem(object Sender, TElSSHTunnelConnection Connection, string Subsystem)
{
    ...
    sftpserver.Tag = Sender;
}


Then you'll be able to access the username in the following way:

TElSSHServer sshServer = (TElSSHServer)(sftpserver.Tag);
string username = (string)(sshServer.Tag)
#16220
Posted: 04/14/2011 15:23:47
by Andy Blum (Basic support level)
Joined: 04/14/2011
Posts: 3

I think we have some confusion as the TelSSHServer object is not available from the SFTPSession class. It is available from the SSHSession. What I am trying to do is to determine which user is writing the file. Is it better to just stay within the SSHSession class?

The goal I am trying to pursue is to be able to encrypt the data received on write.
#16221
Posted: 04/14/2011 15:38:21
by Ken Ivanov (EldoS Corp.)

Considering the sample (all my previous answers were general and unrelated to it), you can do it in the following way:

1) Add a public R/W SshSession property of SSHSession type to the SFTPSession class,

2) Assign this property from the TElSSHServer.OnOpenSubsystem event handler (right after creating the SFTPSession object),

3) Use the SshSession.Username property from SFTPSession class.
Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.

Reply

Statistics

Topic viewed 1442 times

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




|

Back to top

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

Got it!