forked from shaba/openuds
Adding udsuser to preconnect
This commit is contained in:
parent
0b05009d3f
commit
ffe9baa9a5
@ -72,7 +72,7 @@ class PublicProvider(handler.Handler):
|
|||||||
logger.debug('Received Pre connection')
|
logger.debug('Received Pre connection')
|
||||||
if 'user' not in self._params or 'protocol' not in self._params:
|
if 'user' not in self._params or 'protocol' not in self._params:
|
||||||
raise Exception('Invalid preConnect parameters')
|
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:
|
def get_information(self) -> typing.Any:
|
||||||
# Return something useful? :)
|
# Return something useful? :)
|
||||||
|
@ -489,13 +489,13 @@ class CommonService: # pylint: disable=too-many-instance-attributes
|
|||||||
'''
|
'''
|
||||||
logger.info('Service stopped')
|
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
|
Invoked when received a PRE Connection request via REST
|
||||||
Base preconnect executes the preconnect command
|
Base preconnect executes the preconnect command
|
||||||
'''
|
'''
|
||||||
if self._cfg.pre_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'
|
return 'ok'
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ class UDSActorSvc(win32serviceutil.ServiceFramework, CommonService):
|
|||||||
logger.info('Using multiple step join because configuration requests to do so')
|
logger.info('Using multiple step join because configuration requests to do so')
|
||||||
self.multiStepJoin(name, domain, ou, account, password)
|
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')
|
logger.debug('Pre connect invoked')
|
||||||
|
|
||||||
if protocol == 'rdp': # If connection is not using rdp, skip adding user
|
if protocol == 'rdp': # If connection is not using rdp, skip adding user
|
||||||
@ -168,7 +168,7 @@ class UDSActorSvc(win32serviceutil.ServiceFramework, CommonService):
|
|||||||
self._user = None
|
self._user = None
|
||||||
logger.debug('User {} already in group'.format(userName))
|
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:
|
def ovLogon(self, username: str, password: str) -> str:
|
||||||
"""
|
"""
|
||||||
|
@ -140,7 +140,13 @@ def notifyPreconnect(userService: 'UserService', userName: str, protocol: str) -
|
|||||||
_requestActor(
|
_requestActor(
|
||||||
userService,
|
userService,
|
||||||
'preConnect',
|
'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:
|
except NoActorComms:
|
||||||
pass # If no preconnect, warning will appear on UDS log
|
pass # If no preconnect, warning will appear on UDS log
|
||||||
|
Loading…
Reference in New Issue
Block a user