add domain parameters when exists with RDP

This commit is contained in:
Luiz Costa 2024-06-03 14:41:15 +01:00
parent 9ebe41fd66
commit c026d95060

View File

@ -35,12 +35,13 @@ def create_session(name, protocol):
acc_doc = frappe.get_doc('IT User Account', doc.get('link')) acc_doc = frappe.get_doc('IT User Account', doc.get('link'))
username = acc_doc.username username = acc_doc.username
password = acc_doc.get_password('password') password = acc_doc.get_password('password')
domain = acc_doc.get('domain') if acc_doc.get('domain') else None
# Get IP # Get IP
ip_doc = frappe.get_doc('IP Address', doc.get('main_ip')) ip_doc = frappe.get_doc('IP Address', doc.get('main_ip'))
ip_address = ip_doc.ip_address ip_address = ip_doc.ip_address
uri = urllib.parse.quote_plus(f"{protocol}://{username if username else ''}{':' + password if password else ''}@{ip_address}{':' + str(PROTOCOL_PORT[protocol])}").lower() uri = f"{protocol}://{username if username else ''}{':' + password if password else ''}@{ip_address}{':' + str(PROTOCOL_PORT[protocol])}"
if protocol == 'RDP': if protocol == 'RDP':
uri = f"{uri}/?ignore-cert=true&disable-audio=true" uri = f"{uri}/?ignore-cert=true&disable-audio=true{'&domain=' + domain if domain else ''}"
url = f'{guaca_config.guacamole_server}/?#/?token={token}&quickconnect={uri}' url = f'{guaca_config.guacamole_server}/?#/?token={token}&quickconnect={urllib.parse.quote_plus(uri).lower()}'
return url return url