diff --git a/actor/src/udsactor/http/public.py b/actor/src/udsactor/http/public.py index 53f17ecf..2c1ae352 100644 --- a/actor/src/udsactor/http/public.py +++ b/actor/src/udsactor/http/public.py @@ -72,7 +72,7 @@ class PublicProvider(handler.Handler): logger.debug('Received Pre connection') if 'user' not in self._params or 'protocol' not in self._params: raise Exception('Invalid preConnect parameters') - return self._service.preConnect(self._params['user'], self._params['protocol'], self._params.get('ip', 'unknown'), self._params.get('hostname', 'unknown')) + return self._service.preConnect(self._params['user'], self._params['protocol'], self._params.get('ip', 'unknown'), self._params.get('hostname', 'unknown'), self._params.get('udsuser', 'unknown')) def get_information(self) -> typing.Any: # Return something useful? :) diff --git a/actor/src/udsactor/service.py b/actor/src/udsactor/service.py index 2347e2c1..e114d1d1 100644 --- a/actor/src/udsactor/service.py +++ b/actor/src/udsactor/service.py @@ -489,13 +489,13 @@ class CommonService: # pylint: disable=too-many-instance-attributes ''' logger.info('Service stopped') - def preConnect(self, userName: str, protocol: str, ip: str, hostname: str) -> str: # pylint: disable=unused-argument + def preConnect(self, userName: str, protocol: str, ip: str, hostname: str, udsUserName: str) -> str: ''' Invoked when received a PRE Connection request via REST Base preconnect executes the preconnect command ''' if self._cfg.pre_command: - self.execute(self._cfg.pre_command + ' {} {} {} {}'.format(userName.replace('"', '%22'), protocol, ip, hostname), 'preConnect') + self.execute(self._cfg.pre_command + ' {} {} {} {} {}'.format(userName.replace('"', '%22'), protocol, ip, hostname, udsUserName), 'preConnect') return 'ok' diff --git a/actor/src/udsactor/windows/service.py b/actor/src/udsactor/windows/service.py index 8e295307..d1ded230 100644 --- a/actor/src/udsactor/windows/service.py +++ b/actor/src/udsactor/windows/service.py @@ -139,7 +139,7 @@ class UDSActorSvc(win32serviceutil.ServiceFramework, CommonService): logger.info('Using multiple step join because configuration requests to do so') self.multiStepJoin(name, domain, ou, account, password) - def preConnect(self, userName: str, protocol: str, ip: str, hostname: str) -> str: + def preConnect(self, userName: str, protocol: str, ip: str, hostname: str, udsUserName: str) -> str: logger.debug('Pre connect invoked') if protocol == 'rdp': # If connection is not using rdp, skip adding user @@ -168,7 +168,7 @@ class UDSActorSvc(win32serviceutil.ServiceFramework, CommonService): self._user = None logger.debug('User {} already in group'.format(userName)) - return super().preConnect(userName, protocol, ip, hostname) + return super().preConnect(userName, protocol, ip, hostname, udsUserName) def ovLogon(self, username: str, password: str) -> str: """ diff --git a/server/src/uds/core/managers/userservice/comms.py b/server/src/uds/core/managers/userservice/comms.py index e2b06381..48b6e019 100644 --- a/server/src/uds/core/managers/userservice/comms.py +++ b/server/src/uds/core/managers/userservice/comms.py @@ -140,7 +140,13 @@ def notifyPreconnect(userService: 'UserService', userName: str, protocol: str) - _requestActor( userService, 'preConnect', - {'user': userName, 'protocol': protocol, 'ip': ip, 'hostname': hostname}, + { + 'user': userName, + 'protocol': protocol, + 'ip': ip, + 'hostname': hostname, + 'udsuser': userService.user.name if userService.user else '', + }, ) except NoActorComms: pass # If no preconnect, warning will appear on UDS log