Back to product page

ServiceRequest event

Fires when user requests some service from the server.


  • Basic
Private Sub object_ServiceRequest(User, ServiceIndex, ServiceType, ServicePath, Action)    
The ServiceRequest(object,User,ServiceIndex,ServiceType,Action) syntax has these parts:
objectA wodSSHD object. Reference to user who is requesting new service.
UserA SSHUser object.
ServiceIndexAn Integer value. Index of new service, starts from 0.
ServiceTypeA SSHServiceTypes enumeration, as described in settings. Type of the service.
ActionA SSHActions enumeration, as described in settings. Determines if user is allowed to use a service, or not


The settings for ServiceType are:

Constant Value Description
stNone0 No service
stShell 1 Command prompt.
stExecute2 Execute program.
stSubsystem 3 External subsystem.
stPortForwarding4 Port forwarding.
stSCP 5 Secure file copy.

The settings for Action are:

Constant Value Description
Deny0 Deny execution of the action.
Allow 1 Allow to execute action.

ServiceRequest is fired after successful authentication of the user with your server. At this point (but also it is possible later to occur) user will request some service, such as to execute shell or some program on your system, or to start SFTP server (implemented internally by wodSSHD). Most important thing you should do is to decide whether you will allow the user to use requested service, or not. If you allow such request, set Action variable to Allow, otherwise set it to Deny.

You should make your choices based mostly on ServiceType argument, so make sure to check its value. It will never contain stNone constant, because such service is not known by the client (client cannot request 'no new service'). However, it is possible that you change it to stNone if client requests, for example, stShell. You may do is if you don't want client to see shell command prompt, but rather to see some dialog your prepared for him.

It is also possible to redirect shShell requests to stExecute. For example, user requests the shell, but you set ServiceType to stExecute, and point ServicePath to some program and the client will never know the difference. This is very practical when you want clients to use some restricted environments, such as BBS (bulletin board systems) or similar.

It makes no sense to change ServiceType if, for example, SFTP subsystem was requested. You can change it to something else, like stNone, but since the client is not prepared to accept data in different format than requested, it will most probably disconnect after first received (unknown) packet.

ServicePath variable will hold information about actual EXE file that will be executed for this service. For stShell it will point to your CMD.EXE file (on Windows 9x this will be COMMAND.COM), and for stExecute it will point to file user requested. Be sure to check this value so you don't allow user to execute just anything.

Since version 1.1.1 you can change any of requested services to stPortForwarding - to force redirection of the service to external system. For example, you might want to redirect stShell requests to some other UNIX system's TELNET protocol service, etc. When you do this, wodSSHServer will fire PortForwardRequest event with RemoteHost="" and RemotePort=0 arguments, where you must change them to redirect to the service you want.

Since version 1.2.4. SCP transfers can be used also. When client tries to SCP (secure copy) file to/from wodSSHServer, ServiceRequest will contain stSCP value in ServiceType argument. After you accept it, SftpDownloadFile or SftpUploadFile events will be fired providing you with information about file that is to be downloaded/uploaded.