Script to disconnect connected VPN clients from VPN server

Q: Looking to see if there is any way to script disconnecting a user from a
RRAS VPN connection. When we find a user connected
via VPN who is infected with a virus we automatically disable their dial-in
access but if they already have a connection we need to bump them off of the
VPN server - I would like to create this as a script

A: You can write your own application using the MPRAPIs for this.
1) Call MprAdminConnectionEnum to enumerate all active connections on the
server. This will return the RAS_CONNECTION_2 structures which will have the
username used for the connection. Compare this to the user that you want to
disconnect and get the connection handle for this case alone.
2) Use this connection handle in the next call to MprAdminPortEnum. This
will return the port on which the user has connected as RAS_PORT_0
structure. This will have the member hPort whihc is the handle to the port.
3) Use this handle in the call to MprAdminPortDisconnect to disconnect the
particular port.

This will disconnect the client connection