D
Dave
I have a program which has to do a series of checks on the client
computers before they are allowed to VPN in into our network. The
sequence of steps would be to run all the checks and then the user
connects through VPN to our office. A small service running on the
client computers will then send a message to the VPN server and the
VPN server will record it in a database. VPN server will also have a
service running which will check the connection requests it has
received against the open VPN connections, and if there is a
connection which is not there in the requests received database then
it will disconnect that user.
I have been able to write program to run the checks and to send a
message to the server. And I should be able to do the other tasks but
where I am stuck right now is how to disconnect the unauthorized VPN
connections. I can get the list of open VPN connections on the server
by running netstat and get the local host name and port number and the
remote host name and port number.
I tried using System.Net.Sockets and System.Runtime.Remoting.Channels
classes to create a connection to the open VPN port so that I can
close it, but as expected, the computer is not allowing the connection
to be made. The error message is -
Service cannot be started. System.Net.Sockets.SocketException: No
connection could be made because the target machine actively refused
it
at System.Net.Sockets.TcpClient.Connect(String hostname, Int32
port)
This service is running as 'Local System' on the computer. I would
appreciate if someone could help me out in finding a solution. Thank
you.
computers before they are allowed to VPN in into our network. The
sequence of steps would be to run all the checks and then the user
connects through VPN to our office. A small service running on the
client computers will then send a message to the VPN server and the
VPN server will record it in a database. VPN server will also have a
service running which will check the connection requests it has
received against the open VPN connections, and if there is a
connection which is not there in the requests received database then
it will disconnect that user.
I have been able to write program to run the checks and to send a
message to the server. And I should be able to do the other tasks but
where I am stuck right now is how to disconnect the unauthorized VPN
connections. I can get the list of open VPN connections on the server
by running netstat and get the local host name and port number and the
remote host name and port number.
I tried using System.Net.Sockets and System.Runtime.Remoting.Channels
classes to create a connection to the open VPN port so that I can
close it, but as expected, the computer is not allowing the connection
to be made. The error message is -
Service cannot be started. System.Net.Sockets.SocketException: No
connection could be made because the target machine actively refused
it
at System.Net.Sockets.TcpClient.Connect(String hostname, Int32
port)
This service is running as 'Local System' on the computer. I would
appreciate if someone could help me out in finding a solution. Thank
you.