Hi,
I have been trying to use the below remote python API to disconnect a user from the VPN but I get the message it's been unsuccessful when disconnecting the user.
Error: Failed to disconnect user 'xxx' from hub 'vpn'.
Has anyone been successful in doing this ?
Here's my Python code below:
import requests
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
def disconnect_user(host, port, admin_password, hub_name, username):
# Create the URL for the API endpoint
url = "https://{}:{}/api".format(host, port)
# Define the API parameters
params = {
'AdminPassword': admin_password,
'API': 'DisconnectSession',
'AccountName': username,
'HubName': hub_name
}
# Send the API request
response = requests.get(url, params=params, verify=False)
# Check the response status code
if response.status_code == 200:
print("User '{}' disconnected successfully from hub '{}'.".format(username, hub_name))
else:
print("Failed to disconnect user '{}' from hub '{}'.".format(username, hub_name))
# Usage example
host = 'ip address' # SoftEther VPN Server IP address
port = 'port' # SoftEther VPN Server Management Port
admin_password = 'password'
hub_name = 'vpn'
username = 'xxx'
disconnect_user(host, port, admin_password, hub_name, username)
Disconnect a VPN user using RPC API
-
- Posts: 1301
- Joined: Sun Feb 14, 2021 10:31 am
Re: Disconnect a VPN user using RPC API
- EnumSession like eg https://www.vpnusers.com/viewtopic.php? ... 563#p98563
- then pipe it to jq https://stedolan.github.io/jq/ to select session with a user
- and finally DeleteSession of the user